From f891e61205f069fff8a66cc60b8371902e22d265 Mon Sep 17 00:00:00 2001 From: Daniel Milroy Date: Sun, 7 Jun 2020 12:05:03 -0700 Subject: [PATCH 1/6] resource: add enum class for resource status - add an extensible enum class to track resource status (i.e. up, down, drain, etc.) - add an unordered_map to associate a string to an enum value --- resource/schema/resource_data.cpp | 4 ++++ resource/schema/resource_data.hpp | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/resource/schema/resource_data.cpp b/resource/schema/resource_data.cpp index abe08719d..19bbe9349 100644 --- a/resource/schema/resource_data.cpp +++ b/resource/schema/resource_data.cpp @@ -106,6 +106,10 @@ resource_relation_t::~resource_relation_t () } +const resource_pool_t::string_to_status resource_pool_t::str_to_status = + { { "up", resource_pool_t::status_t::UP }, + { "down", resource_pool_t::status_t::DOWN } }; + } // Flux::resource_model } // Flux diff --git a/resource/schema/resource_data.hpp b/resource/schema/resource_data.hpp index c9a910be4..5b37c8248 100644 --- a/resource/schema/resource_data.hpp +++ b/resource/schema/resource_data.hpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include "resource/schema/color.hpp" #include "resource/schema/data_std.hpp" @@ -44,6 +45,14 @@ struct resource_pool_t { resource_pool_t &operator= (const resource_pool_t &o); ~resource_pool_t (); + enum class status_t : int { + UP = 0, + DOWN = 1 + }; + + typedef std::unordered_map string_to_status; + static const string_to_status str_to_status; + // Resource pool data std::string type; std::map paths; @@ -58,6 +67,7 @@ struct resource_pool_t { schedule_t schedule; //!< schedule data pool_infra_t idata; //!< scheduling infrastructure data + status_t status = status_t::UP; }; /*! Resource relationship type. From f6666900810c49f7d8eb8f8bc5b950db428a0632 Mon Sep 17 00:00:00 2001 From: Daniel Milroy Date: Mon, 8 Jun 2020 00:33:08 -0700 Subject: [PATCH 2/6] resource: set default resource status and read JGF status key - set the default status as "up" in the hwloc and JGF readers. - enable the JGF reader to unpack an optional "status" key --- resource/readers/resource_reader_hwloc.cpp | 1 + resource/readers/resource_reader_jgf.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/resource/readers/resource_reader_hwloc.cpp b/resource/readers/resource_reader_hwloc.cpp index f5340ae83..f9e7b9d0c 100644 --- a/resource/readers/resource_reader_hwloc.cpp +++ b/resource/readers/resource_reader_hwloc.cpp @@ -102,6 +102,7 @@ vtx_t resource_reader_hwloc_t::add_new_vertex (resource_graph_t &g, g[v].name = basename + istr; g[v].paths[subsys] = prefix + "/" + g[v].name; g[v].idata.member_of[subsys] = "*"; + g[v].status = resource_pool_t::status_t::UP; // Indexing for fast look-up m.by_path[g[v].paths[subsys]] = v; diff --git a/resource/readers/resource_reader_jgf.cpp b/resource/readers/resource_reader_jgf.cpp index fa871db74..3ba02236e 100644 --- a/resource/readers/resource_reader_jgf.cpp +++ b/resource/readers/resource_reader_jgf.cpp @@ -44,6 +44,7 @@ struct fetch_helper_t { int64_t size = 0; int64_t uniq_id = 0; int exclusive = 0; + resource_pool_t::status_t status = resource_pool_t::status_t::UP; const char *type = NULL; const char *name = NULL; const char *unit = NULL; @@ -186,11 +187,11 @@ int resource_reader_jgf_t::unpack_vtx (json_t *element, fetch_helper_t &f) m_err_msg += std::string (f.vertex_id) + ".\n"; goto done; } - if ( (json_unpack (metadata, "{ s:s s:s s:s s:I s:I s:I s:b s:s s:I }", + if ( (json_unpack (metadata, "{ s:s s:s s:s s:I s:I s:I s?:i s:b s:s s:I }", "type", &f.type, "basename", &f.basename, "name", &f.name, "id", &f.id, "uniq_id", &f.uniq_id, "rank", &f.rank, - "exclusive", &f.exclusive, + "status", &f.status, "exclusive", &f.exclusive, "unit", &f.unit, "size", &f.size)) < 0) { errno = EPROTO; m_err_msg += __FUNCTION__; @@ -245,6 +246,7 @@ vtx_t resource_reader_jgf_t::create_vtx (resource_graph_t &g, g[v].size = fetcher.size; g[v].uniq_id = fetcher.uniq_id; g[v].rank = fetcher.rank; + g[v].status = fetcher.status; g[v].id = fetcher.id; g[v].name = fetcher.name; g[v].properties = fetcher.properties; From f06424cf050f8dbadb035eb1be689da5f6567542 Mon Sep 17 00:00:00 2001 From: Daniel Milroy Date: Wed, 8 Jul 2020 09:58:14 -0700 Subject: [PATCH 3/6] resource: add capability to get resource by status - add get-status command that takes a resource path argument and prints the status of the specified resource to stdout. --- resource/utilities/command.cpp | 39 ++++++++++++++++++++++++++++++++++ resource/utilities/command.hpp | 2 ++ 2 files changed, 41 insertions(+) diff --git a/resource/utilities/command.cpp b/resource/utilities/command.cpp index 993f6ead6..7cc665882 100644 --- a/resource/utilities/command.cpp +++ b/resource/utilities/command.cpp @@ -56,6 +56,8 @@ command_t commands[] = { "resource-query> set-property resource PROPERTY=VALUE" }, { "get-property", "g", cmd_get_property, "Get all properties of a resource: " "resource-query> get-property resource" }, +{ "get-status", "e", cmd_get_status, "Get the graph resource vertex status: " +"resource-query> get-status PATH_TO_VERTEX" }, { "list", "l", cmd_list, "List all jobs: resource-query> list" }, { "info", "i", cmd_info, "Print info on a jobid: resource-query> info jobid" }, @@ -421,6 +423,43 @@ int cmd_get_property (std::shared_ptr &ctx, return 0; } +int cmd_get_status (std::shared_ptr &ctx, + std::vector &args) +{ + if (args.size () != 2) { + std::cerr << "ERROR: malformed command" << std::endl; + return 0; + } + std::string vtx_path = args[1]; + std::map::const_iterator it = + ctx->db->metadata.by_path.find (vtx_path); + resource_pool_t::string_to_status sts = resource_pool_t::str_to_status; + std::string status = ""; + + if (it == ctx->db->metadata.by_path.end ()) { + std::cout << "Could not find path " << vtx_path + << " in resource graph." << std::endl; + return 0; + } + + for (auto &status_it : sts) { + if (status_it.second == ctx->db->resource_graph[it->second].status) { + status = status_it.first; + break; + } + } + + if (status == "") { + std::cerr << "ERROR: vertex " << vtx_path + << " has unknown status." << std::endl; + return 0; + } + + std::cout << vtx_path << " is " << status << std::endl; + + return 0; +} + int cmd_list (std::shared_ptr &ctx, std::vector &args) { diff --git a/resource/utilities/command.hpp b/resource/utilities/command.hpp index 6e24f3f64..e205b8391 100644 --- a/resource/utilities/command.hpp +++ b/resource/utilities/command.hpp @@ -91,6 +91,8 @@ int cmd_set_property (std::shared_ptr &ctx, std::vector &args); int cmd_get_property (std::shared_ptr &ctx, std::vector &args); +int cmd_get_status (std::shared_ptr &ctx, + std::vector &args); int cmd_list (std::shared_ptr &ctx, std::vector &args); int cmd_info (std::shared_ptr &ctx, From d57257ad369b33823fe52dc629900dc12cc5bf6c Mon Sep 17 00:00:00 2001 From: Daniel Milroy Date: Mon, 8 Jun 2020 01:10:15 -0700 Subject: [PATCH 4/6] resource: add set-status command to resource-query - add set-status to resource-query. This command sets the resource status for the resource vertex at the path specified in the command argument. --- resource/utilities/command.cpp | 30 ++++++++++++++++++++++++++++++ resource/utilities/command.hpp | 2 ++ 2 files changed, 32 insertions(+) diff --git a/resource/utilities/command.cpp b/resource/utilities/command.cpp index 7cc665882..77f1953ad 100644 --- a/resource/utilities/command.cpp +++ b/resource/utilities/command.cpp @@ -56,6 +56,8 @@ command_t commands[] = { "resource-query> set-property resource PROPERTY=VALUE" }, { "get-property", "g", cmd_get_property, "Get all properties of a resource: " "resource-query> get-property resource" }, +{ "set-status", "t", cmd_set_status, "Set resource status on vertex: " +"resource-query> set-status PATH_TO_VERTEX {up|down}" }, { "get-status", "e", cmd_get_status, "Get the graph resource vertex status: " "resource-query> get-status PATH_TO_VERTEX" }, { "list", "l", cmd_list, "List all jobs: resource-query> list" }, @@ -423,6 +425,34 @@ int cmd_get_property (std::shared_ptr &ctx, return 0; } +int cmd_set_status (std::shared_ptr &ctx, + std::vector &args) +{ + if (args.size () != 3) { + std::cerr << "ERROR: malformed command" << std::endl; + return 0; + } + std::string vtx_path = args[1]; + std::string status = args[2]; + std::map::const_iterator it = + ctx->db->metadata.by_path.find (vtx_path); + resource_pool_t::string_to_status sts = resource_pool_t::str_to_status; + + if (it == ctx->db->metadata.by_path.end ()) { + std::cout << "Could not find path " << vtx_path + << " in resource graph." << std::endl; + return 0; + } + + auto status_it = sts.find (status); + if (status_it == sts.end ()) { + std::cerr << "ERROR: unrecognized status" << std::endl; + return 0; + } + + return ctx->traverser->mark (vtx_path, status_it->second); +} + int cmd_get_status (std::shared_ptr &ctx, std::vector &args) { diff --git a/resource/utilities/command.hpp b/resource/utilities/command.hpp index e205b8391..090dfc2e4 100644 --- a/resource/utilities/command.hpp +++ b/resource/utilities/command.hpp @@ -91,6 +91,8 @@ int cmd_set_property (std::shared_ptr &ctx, std::vector &args); int cmd_get_property (std::shared_ptr &ctx, std::vector &args); +int cmd_set_status (std::shared_ptr &ctx, + std::vector &args); int cmd_get_status (std::shared_ptr &ctx, std::vector &args); int cmd_list (std::shared_ptr &ctx, From 7ac8886d1400a74bf7c13e6ab9bf5621e6782716 Mon Sep 17 00:00:00 2001 From: Daniel Milroy Date: Mon, 6 Jul 2020 22:27:19 -0700 Subject: [PATCH 5/6] resource: add functions to update resource status via traverser - update resource status at a specified subtree root. --- resource/traversers/dfu.cpp | 14 ++++++- resource/traversers/dfu.hpp | 18 +++++++++ resource/traversers/dfu_impl.hpp | 19 +++++++++ resource/traversers/dfu_impl_update.cpp | 53 +++++++++++++++++++++++++ 4 files changed, 103 insertions(+), 1 deletion(-) diff --git a/resource/traversers/dfu.cpp b/resource/traversers/dfu.cpp index 9540de368..652fc0ba6 100644 --- a/resource/traversers/dfu.cpp +++ b/resource/traversers/dfu.cpp @@ -286,10 +286,22 @@ int dfu_traverser_t::remove (int64_t jobid) return -1; } - vtx_t root = get_graph_db ()->metadata.roots.at(dom); + vtx_t root = get_graph_db ()->metadata.roots.at (dom); return detail::dfu_impl_t::remove (root, jobid); } +int dfu_traverser_t::mark (const std::string &root_path, + resource_pool_t::status_t status) +{ + return detail::dfu_impl_t::mark (root_path, status); +} + +int dfu_traverser_t::mark (std::set &ranks, + resource_pool_t::status_t status) +{ + return detail::dfu_impl_t::mark (ranks, status); +} + /* * vi:tabstop=4 shiftwidth=4 expandtab */ diff --git a/resource/traversers/dfu.hpp b/resource/traversers/dfu.hpp index 54bcec709..04cc86fcd 100644 --- a/resource/traversers/dfu.hpp +++ b/resource/traversers/dfu.hpp @@ -148,6 +148,24 @@ class dfu_traverser_t : protected detail::dfu_impl_t */ int remove (int64_t jobid); + /*! Mark the resource status up|down|etc starting at subtree_root. + * + * \param root_path path to the root of the subtree to update. + * \param status new status value + * \return 0 on success; -1 on error. + * EINVAL: roots or by_path not found. + */ + int mark (const std::string &root_path, resource_pool_t::status_t status); + + /*! Mark the resource status up|down|etc for subgraph represented by ranks. + * + * \param ranks set of ranks representing the subgraph to update. + * \param status new status value + * \return 0 on success; -1 on error. + * EINVAL: roots or by_path not found. + */ + int mark (std::set &ranks, resource_pool_t::status_t status); + private: int schedule (Jobspec::Jobspec &jobspec, detail::jobmeta_t &meta, bool x, match_op_t op, vtx_t root, diff --git a/resource/traversers/dfu_impl.hpp b/resource/traversers/dfu_impl.hpp index ff17191a0..a93dbf6e1 100644 --- a/resource/traversers/dfu_impl.hpp +++ b/resource/traversers/dfu_impl.hpp @@ -243,6 +243,25 @@ class dfu_impl_t { */ int remove (vtx_t root, int64_t jobid); + /*! Update the resource status to up|down|etc starting at subtree_root. + * + * \param root_path path to the root of the subtree to update. + * \param status new status value + * \return 0 on success; -1 on error. + * EINVAL: graph, roots or match callback not set. + */ + int mark (const std::string &root_path, resource_pool_t::status_t status); + + /*! Update the resource status to up|down|etc for subgraph + * represented by ranks. + * + * \param ranks set of ranks representing the subgraphs to update. + * \param status new status value + * \return 0 on success; -1 on error. + * EINVAL: roots or by_path not found. + */ + int mark (std::set &ranks, resource_pool_t::status_t status); + private: /************************************************************************ diff --git a/resource/traversers/dfu_impl_update.cpp b/resource/traversers/dfu_impl_update.cpp index 19a59d4f5..8087d0ca5 100644 --- a/resource/traversers/dfu_impl_update.cpp +++ b/resource/traversers/dfu_impl_update.cpp @@ -565,6 +565,59 @@ int dfu_impl_t::remove (vtx_t root, int64_t jobid) return (root_has_jtag)? rem_dfv (root, jobid) : rem_exv (jobid); } +int dfu_impl_t::mark (const std::string &root_path, + resource_pool_t::status_t status) +{ + std::map::const_iterator vit_root = + m_graph_db->metadata.by_path.find (root_path); + + if (vit_root == m_graph_db->metadata.by_path.end ()) { + errno = EINVAL; + m_err_msg += __FUNCTION__; + m_err_msg += ": could not find subtree path (" + + root_path + ") in resource graph.\n"; + return -1; + } + (*m_graph)[vit_root->second].status = status; + + return 0; +} + +int dfu_impl_t::mark (std::set &ranks, + resource_pool_t::status_t status) +{ + std::map>::iterator vit; + std::string subtree_path = "", tmp_path = ""; + const std::string &dom = m_match->dom_subsystem (); + vtx_t subtree_root; + + for (auto &rank : ranks) { + // Now iterate through subgraphs keyed by rank and + // set status appropriately + vit = m_graph_db->metadata.by_rank.find (rank); + if (vit == m_graph_db->metadata.by_rank.end ()) { + errno = EINVAL; + m_err_msg += __FUNCTION__; + m_err_msg += ": could not find rank path in by_rank map.\n"; + return -1; + } + + subtree_root = vit->second.front (); + subtree_path = (*m_graph)[subtree_root].paths.at (dom); + for (vtx_t v : vit->second) { + // The shortest path string is the subtree root. + tmp_path = (*m_graph)[v].paths.at (dom); + if (tmp_path.length () < subtree_path.length ()) { + subtree_path = tmp_path; + subtree_root = v; + } + } + (*m_graph)[subtree_root].status = status; + } + + return 0; +} + /* * vi:tabstop=4 shiftwidth=4 expandtab */ From 44cf9657809a30cf47103910d4a224ee58e58c6b Mon Sep 17 00:00:00 2001 From: Daniel Milroy Date: Mon, 8 Jun 2020 23:33:39 -0700 Subject: [PATCH 6/6] testsuite: test get-status and set-status on tiny grug - test get-status output of default tiny GRUG on a resource vertex - test setting and getting status of a resource vertex --- t/Makefile.am | 1 + t/data/resource/commands/status/cmds01 | 2 + t/data/resource/commands/status/cmds02 | 2 + t/data/resource/commands/status/cmds03 | 2 + t/data/resource/commands/status/cmds04 | 2 + t/data/resource/commands/status/cmds05 | 2 + t/data/resource/commands/status/cmds06 | 2 + t/data/resource/commands/status/cmds07 | 5 ++ t/data/resource/commands/status/cmds08 | 6 ++ t/data/resource/expected/status/001.R.out | 1 + t/data/resource/expected/status/002.R.out | 4 ++ t/data/resource/expected/status/003.R.out | 4 ++ t/data/resource/expected/status/004.R.out | 1 + t/data/resource/expected/status/005.R.out | 4 ++ t/data/resource/expected/status/006.R.out | 1 + t/data/resource/expected/status/007.R.out | 8 +++ t/data/resource/expected/status/008.R.out | 10 +++ t/t3024-resource-status.t | 75 +++++++++++++++++++++++ 18 files changed, 132 insertions(+) create mode 100644 t/data/resource/commands/status/cmds01 create mode 100644 t/data/resource/commands/status/cmds02 create mode 100644 t/data/resource/commands/status/cmds03 create mode 100644 t/data/resource/commands/status/cmds04 create mode 100644 t/data/resource/commands/status/cmds05 create mode 100644 t/data/resource/commands/status/cmds06 create mode 100644 t/data/resource/commands/status/cmds07 create mode 100644 t/data/resource/commands/status/cmds08 create mode 100644 t/data/resource/expected/status/001.R.out create mode 100644 t/data/resource/expected/status/002.R.out create mode 100644 t/data/resource/expected/status/003.R.out create mode 100644 t/data/resource/expected/status/004.R.out create mode 100644 t/data/resource/expected/status/005.R.out create mode 100644 t/data/resource/expected/status/006.R.out create mode 100644 t/data/resource/expected/status/007.R.out create mode 100644 t/data/resource/expected/status/008.R.out create mode 100755 t/t3024-resource-status.t diff --git a/t/Makefile.am b/t/Makefile.am index 74d41626a..77787a18f 100644 --- a/t/Makefile.am +++ b/t/Makefile.am @@ -57,6 +57,7 @@ TESTS = \ t3021-resource-mtl3.t \ t3022-resource-update.t \ t3023-resource-update2.t \ + t3024-resource-status.t \ t4000-match-params.t \ t4001-match-allocate.t \ t4002-match-reserve.t \ diff --git a/t/data/resource/commands/status/cmds01 b/t/data/resource/commands/status/cmds01 new file mode 100644 index 000000000..565b9d2a9 --- /dev/null +++ b/t/data/resource/commands/status/cmds01 @@ -0,0 +1,2 @@ +get-status +quit diff --git a/t/data/resource/commands/status/cmds02 b/t/data/resource/commands/status/cmds02 new file mode 100644 index 000000000..018ad12fb --- /dev/null +++ b/t/data/resource/commands/status/cmds02 @@ -0,0 +1,2 @@ +get-status /dne +quit diff --git a/t/data/resource/commands/status/cmds03 b/t/data/resource/commands/status/cmds03 new file mode 100644 index 000000000..f85c0829f --- /dev/null +++ b/t/data/resource/commands/status/cmds03 @@ -0,0 +1,2 @@ +get-status /tiny0/rack0/node0 +quit diff --git a/t/data/resource/commands/status/cmds04 b/t/data/resource/commands/status/cmds04 new file mode 100644 index 000000000..ac1d036df --- /dev/null +++ b/t/data/resource/commands/status/cmds04 @@ -0,0 +1,2 @@ +set-status +quit diff --git a/t/data/resource/commands/status/cmds05 b/t/data/resource/commands/status/cmds05 new file mode 100644 index 000000000..3d42a20f4 --- /dev/null +++ b/t/data/resource/commands/status/cmds05 @@ -0,0 +1,2 @@ +set-status /dne down +quit diff --git a/t/data/resource/commands/status/cmds06 b/t/data/resource/commands/status/cmds06 new file mode 100644 index 000000000..f47f77604 --- /dev/null +++ b/t/data/resource/commands/status/cmds06 @@ -0,0 +1,2 @@ +set-status /tiny0/rack0/node0 dwn +quit diff --git a/t/data/resource/commands/status/cmds07 b/t/data/resource/commands/status/cmds07 new file mode 100644 index 000000000..aa35e36eb --- /dev/null +++ b/t/data/resource/commands/status/cmds07 @@ -0,0 +1,5 @@ +set-status /tiny0/rack0/node0 down +get-status /tiny0/rack0/node0 +set-status /tiny0/rack0/node0 up +get-status /tiny0/rack0/node0 +quit diff --git a/t/data/resource/commands/status/cmds08 b/t/data/resource/commands/status/cmds08 new file mode 100644 index 000000000..71e115884 --- /dev/null +++ b/t/data/resource/commands/status/cmds08 @@ -0,0 +1,6 @@ +get-status /cz0/pfs0/bandwidth0 +set-status /cz0/pfs0/bandwidth0 down +get-status /cz0/pfs0/bandwidth0 +set-status /cz0/pfs0/bandwidth0 up +get-status /cz0/pfs0/bandwidth0 +quit diff --git a/t/data/resource/expected/status/001.R.out b/t/data/resource/expected/status/001.R.out new file mode 100644 index 000000000..d6ec0a757 --- /dev/null +++ b/t/data/resource/expected/status/001.R.out @@ -0,0 +1 @@ +ERROR: malformed command diff --git a/t/data/resource/expected/status/002.R.out b/t/data/resource/expected/status/002.R.out new file mode 100644 index 000000000..ed65bc194 --- /dev/null +++ b/t/data/resource/expected/status/002.R.out @@ -0,0 +1,4 @@ +INFO: Loading a matcher: CA +resource-query> get-status /dne +Could not find path /dne in resource graph. +resource-query> quit diff --git a/t/data/resource/expected/status/003.R.out b/t/data/resource/expected/status/003.R.out new file mode 100644 index 000000000..cc5406a77 --- /dev/null +++ b/t/data/resource/expected/status/003.R.out @@ -0,0 +1,4 @@ +INFO: Loading a matcher: CA +resource-query> get-status /tiny0/rack0/node0 +/tiny0/rack0/node0 is up +resource-query> quit diff --git a/t/data/resource/expected/status/004.R.out b/t/data/resource/expected/status/004.R.out new file mode 100644 index 000000000..d6ec0a757 --- /dev/null +++ b/t/data/resource/expected/status/004.R.out @@ -0,0 +1 @@ +ERROR: malformed command diff --git a/t/data/resource/expected/status/005.R.out b/t/data/resource/expected/status/005.R.out new file mode 100644 index 000000000..6a6622a53 --- /dev/null +++ b/t/data/resource/expected/status/005.R.out @@ -0,0 +1,4 @@ +INFO: Loading a matcher: CA +resource-query> set-status /dne down +Could not find path /dne in resource graph. +resource-query> quit diff --git a/t/data/resource/expected/status/006.R.out b/t/data/resource/expected/status/006.R.out new file mode 100644 index 000000000..b35b72165 --- /dev/null +++ b/t/data/resource/expected/status/006.R.out @@ -0,0 +1 @@ +ERROR: unrecognized status diff --git a/t/data/resource/expected/status/007.R.out b/t/data/resource/expected/status/007.R.out new file mode 100644 index 000000000..949f5bd25 --- /dev/null +++ b/t/data/resource/expected/status/007.R.out @@ -0,0 +1,8 @@ +INFO: Loading a matcher: CA +resource-query> set-status /tiny0/rack0/node0 down +resource-query> get-status /tiny0/rack0/node0 +/tiny0/rack0/node0 is down +resource-query> set-status /tiny0/rack0/node0 up +resource-query> get-status /tiny0/rack0/node0 +/tiny0/rack0/node0 is up +resource-query> quit diff --git a/t/data/resource/expected/status/008.R.out b/t/data/resource/expected/status/008.R.out new file mode 100644 index 000000000..4763bc439 --- /dev/null +++ b/t/data/resource/expected/status/008.R.out @@ -0,0 +1,10 @@ +INFO: Loading a matcher: CA +resource-query> get-status /cz0/pfs0/bandwidth0 +/cz0/pfs0/bandwidth0 is up +resource-query> set-status /cz0/pfs0/bandwidth0 down +resource-query> get-status /cz0/pfs0/bandwidth0 +/cz0/pfs0/bandwidth0 is down +resource-query> set-status /cz0/pfs0/bandwidth0 up +resource-query> get-status /cz0/pfs0/bandwidth0 +/cz0/pfs0/bandwidth0 is up +resource-query> quit diff --git a/t/t3024-resource-status.t b/t/t3024-resource-status.t new file mode 100755 index 000000000..790fee502 --- /dev/null +++ b/t/t3024-resource-status.t @@ -0,0 +1,75 @@ +#!/bin/sh + +test_description='Test Resource Status On Tiny Machine Configuration' + +. $(dirname $0)/sharness.sh + +cmd_dir="${SHARNESS_TEST_SRCDIR}/data/resource/commands/status" +exp_dir="${SHARNESS_TEST_SRCDIR}/data/resource/expected/status" +grugs="${SHARNESS_TEST_SRCDIR}/data/resource/grugs/tiny.graphml" +grug_aux="${SHARNESS_TEST_SRCDIR}/data/resource/grugs/coarse_iobw.graphml" +query="../../resource/utilities/resource-query" + +# +# Selection Policy -- High ID first (-P high) +# The resource vertex with higher ID is preferred among its kind +# (e.g., node1 is preferred over node0 if available) +# + +test001_desc="error on malformed get-status " +test_expect_success "${test001_desc}" ' + ${query} -L ${grugs} -F jgf -S CA -P high < ${cmd_dir}/cmds01 \ +2> 001.R.out && + test_cmp 001.R.out ${exp_dir}/001.R.out +' + +test002_desc="exit on get-status of nonexistent resource " +test_expect_success "${test002_desc}" ' + ${query} -L ${grugs} -F jgf -S CA -P high < ${cmd_dir}/cmds02 \ +> 002.R.out && + test_cmp 002.R.out ${exp_dir}/002.R.out +' + +test003_desc="get resource vertex status " +test_expect_success "${test003_desc}" ' + ${query} -L ${grugs} -F jgf -S CA -P high < ${cmd_dir}/cmds03 \ +> 003.R.out && + test_cmp 003.R.out ${exp_dir}/003.R.out +' + +test004_desc="error on malformed get-status " +test_expect_success "${test004_desc}" ' + ${query} -L ${grugs} -F jgf -S CA -P high < ${cmd_dir}/cmds04 \ +2> 004.R.out && + test_cmp 004.R.out ${exp_dir}/004.R.out +' + +test005_desc="exit on set-status of nonexistent resource " +test_expect_success "${test005_desc}" ' + ${query} -L ${grugs} -F jgf -S CA -P high < ${cmd_dir}/cmds05 \ +> 005.R.out && + test_cmp 005.R.out ${exp_dir}/005.R.out +' + +test006_desc="error on set-status of nonexistent status " +test_expect_success "${test006_desc}" ' + ${query} -L ${grugs} -F jgf -S CA -P high < ${cmd_dir}/cmds06 \ +2> 006.R.out && + test_cmp 006.R.out ${exp_dir}/006.R.out +' + +test007_desc="change resource vertex status and get output " +test_expect_success "${test007_desc}" ' + ${query} -L ${grugs} -F jgf -S CA -P high < ${cmd_dir}/cmds07 \ +> 007.R.out && + test_cmp 007.R.out ${exp_dir}/007.R.out +' + +test008_desc="change aux hierarchy resource vertex status and get output " +test_expect_success "${test008_desc}" ' + ${query} -L ${grug_aux} -F jgf -S CA -P high < ${cmd_dir}/cmds08 \ +> 008.R.out && + test_cmp 008.R.out ${exp_dir}/008.R.out +' + +test_done