From c3e5893b594943f88db41ac0ae565f38f9f947ed Mon Sep 17 00:00:00 2001 From: James Corbett Date: Fri, 1 Dec 2023 21:35:24 -0800 Subject: [PATCH] test: add tests for resource.set-status rpc Problem: there are no tests to ensure that the "sched-fluxion-resource.set_status" service works properly. Add tests. --- t/CMakeLists.txt | 1 + t/Makefile.am | 1 + t/t4012-set-status.t | 84 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+) create mode 100755 t/t4012-set-status.t diff --git a/t/CMakeLists.txt b/t/CMakeLists.txt index e6473f11a..6bbedd349 100644 --- a/t/CMakeLists.txt +++ b/t/CMakeLists.txt @@ -77,6 +77,7 @@ set(ALL_TESTS t4009-match-update.t t4010-match-conf.t t4011-match-duration.t + t4012-set-status.t t5000-valgrind.t t6000-graph-size.t t6001-match-formats.t diff --git a/t/Makefile.am b/t/Makefile.am index a2c465111..bcb7a2ccf 100644 --- a/t/Makefile.am +++ b/t/Makefile.am @@ -95,6 +95,7 @@ TESTS = \ t4009-match-update.t \ t4010-match-conf.t \ t4011-match-duration.t \ + t4012-set-status.t \ t5000-valgrind.t \ t5100-issues-test-driver.t \ t6000-graph-size.t \ diff --git a/t/t4012-set-status.t b/t/t4012-set-status.t new file mode 100755 index 000000000..a6089b53b --- /dev/null +++ b/t/t4012-set-status.t @@ -0,0 +1,84 @@ +#!/bin/sh +#set -x + +test_description='Test the basic functionality of properties (get/set) within resource +' + +. `dirname $0`/sharness.sh + +grug="${SHARNESS_TEST_SRCDIR}/data/resource/grugs/tiny.graphml" +jobspec="${SHARNESS_TEST_SRCDIR}/data/resource/jobspecs/basics/test008.yaml" + +# +# test_under_flux is under sharness.d/ +# +test_under_flux 1 + +# +# print only with --debug +# + +test_debug ' + echo ${grug} +' + +test_expect_success 'loading resource module with a tiny machine config works' ' + load_resource \ +load-file=${grug} load-format=grug \ +prune-filters=ALL:core subsystems=containment policy=high +' + +test_expect_success 'set-status basic test works' ' + flux ion-resource find status=down | grep null && + flux ion-resource set-status /tiny0/rack0/node0 down && + flux ion-resource find status=down | grep node0 && + flux ion-resource set-status /tiny0/rack0/node0 up && + flux ion-resource find status=down | grep null +' + +test_expect_success 'bad resource path produces an error' ' + test_must_fail flux ion-resource set-status /foobar/not/a/vertex down +' + +test_expect_success 'bad status produces an error' ' + test_must_fail flux ion-resource set-status /tiny0/rack0/node0 foobar +' + +test_expect_success 'set-status not-so-basic test works' ' + flux ion-resource find status=down | grep null && + flux ion-resource set-status /tiny0/rack0/node0 down && + flux ion-resource find status=down | grep node0 && + flux ion-resource set-status /tiny0/rack0/node1 down && + flux ion-resource find status=down | grep "node\[0-1\]" && + flux ion-resource set-status /tiny0/rack0/node0 up && + flux ion-resource find status=down | grep node1 && + flux ion-resource set-status /tiny0/rack0/node1 up && + flux ion-resource find status=down | grep null +' + +test_expect_success 'jobs fail when all nodes are marked down' ' + flux ion-resource set-status /tiny0/rack0/node0 down && + flux ion-resource set-status /tiny0/rack0/node1 down && + flux ion-resource find status=up | grep null && + flux ion-resource match satisfiability $jobspec && + test_must_fail flux ion-resource match allocate $jobspec && + flux ion-resource set-status /tiny0/rack0/node0 up && + flux ion-resource set-status /tiny0/rack0/node1 up && + flux ion-resource find status=down | grep null +' + +test_expect_success 'jobs fail when all racks are marked down' ' + flux ion-resource find status=down | grep null && + flux ion-resource set-status /tiny0/rack0 down && + flux ion-resource find status=up | grep null && + flux ion-resource match satisfiability $jobspec && + test_must_fail flux ion-resource match allocate $jobspec && + flux ion-resource set-status /tiny0/rack0 up && + flux ion-resource find status=down | grep null +' + +test_expect_success 'removing resource works' ' + remove_resource +' + +test_done