Skip to content

Commit

Permalink
test: Add basic test for cancel and info handlers within resource
Browse files Browse the repository at this point in the history
Test the functionality of the cancel and info handlers within
resource module using flux-resource front-end command.

Use the original HOME environment variable as sharness
interferes with Python's module search path.
Python uses HOME to determine its local site-package path,
and changing this leads to an incorrect search path.

Update Makefile rule.
  • Loading branch information
dongahn committed Sep 11, 2018
1 parent 3329fce commit 01380e0
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
1 change: 1 addition & 0 deletions t/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ TESTS = \
t3010-resource-power.t \
t4001-match-allocate.t \
t4002-match-reserve.t \
t4003-cancel-info.t \
t5000-valgrind.t

check_SCRIPTS = $(TESTS)
Expand Down
88 changes: 88 additions & 0 deletions t/t4003-cancel-info.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#!/bin/sh
#set -x

test_description='Test the basic functionality of cancel and info within resource
Ensure that the cancel and info handlers within the resource module works
'

ORIG_HOME=${HOME}

. `dirname $0`/sharness.sh

#
# sharness modifies $HOME environment variable, but this interferes
# with python's package search path, in particular its user site package.
#
HOME=${ORIG_HOME}

grug="${SHARNESS_TEST_SRCDIR}/data/resource/grugs/tiny.graphml"
jobspec="${SHARNESS_TEST_SRCDIR}/data/resource/jobspecs/basics/test001.yaml"

#
# test_under_flux is under sharness.d/
#
test_under_flux 1

#
# print only with --debug
#
test_debug '
echo ${grug} &&
echo ${jobspec}
'

test_expect_success 'loading resource module with a tiny machine config works' '
flux module load resource grug-conf=${grug} \
subsystems=containment policy=high
'

test_expect_success 'resource-cancel works' '
flux resource match allocate ${jobspec} &&
flux resource cancel 0 &&
flux resource match allocate ${jobspec} &&
flux resource cancel 1 &&
flux resource match allocate ${jobspec} &&
flux resource cancel 2 &&
flux resource match allocate ${jobspec} &&
flux resource cancel 3
'

test_expect_success 'resource-info on cancelled jobs works' '
flux resource info 0 > info.0 &&
flux resource info 1 > info.1 &&
flux resource info 2 > info.2 &&
flux resource info 3 > info.3 &&
grep CANCELLED info.0 &&
grep CANCELLED info.1 &&
grep CANCELLED info.2 &&
grep CANCELLED info.3
'

test_expect_success 'allocate works with 1-node/1-socket after cancels' '
flux resource match allocate ${jobspec} &&
flux resource match allocate ${jobspec} &&
flux resource match allocate ${jobspec} &&
flux resource match allocate ${jobspec}
'

test_expect_success 'resource-info on allocated jobs works' '
flux resource info 4 > info.4 &&
flux resource info 5 > info.5 &&
flux resource info 6 > info.6 &&
flux resource info 7 > info.7 &&
grep ALLOCATED info.4 &&
grep ALLOCATED info.5 &&
grep ALLOCATED info.6 &&
grep ALLOCATED info.7
'

test_expect_success 'cancel on nonexistent jobid is handled gracefully' '
test_expect_code 1 flux resource cancel 100000
'

test_expect_success 'removing resource works' '
flux module remove resource
'

test_done

0 comments on commit 01380e0

Please sign in to comment.