Skip to content

Commit

Permalink
test: add tests for resource.set-status rpc
Browse files Browse the repository at this point in the history
Problem: there are no tests to ensure that the
"sched-fluxion-resource.set_status" service works properly.

Add tests.
  • Loading branch information
jameshcorbett committed Dec 12, 2023
1 parent 46d6d62 commit 1658f88
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
1 change: 1 addition & 0 deletions t/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions t/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
84 changes: 84 additions & 0 deletions t/t4012-set-status.t
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 1658f88

Please sign in to comment.