Skip to content

Commit

Permalink
testsuite: add t0005-exec-jobid.t
Browse files Browse the repository at this point in the history
Problem: There are no tests of the flux-exec --jobid option.

Add a new sharness test for this option, since it requires that the
tests be able to run jobs, as opposed to the basic flux-exec testing,
which does not.
  • Loading branch information
grondo committed Dec 4, 2023
1 parent da7f721 commit 2e59e01
Show file tree
Hide file tree
Showing 2 changed files with 82 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 @@ -70,6 +70,7 @@ TESTSCRIPTS = \
t0004-event.t \
t0005-exec.t \
t0005-rexec.t \
t0005-exec-jobid.t \
t0007-ping.t \
t0008-attr.t \
t0009-dmesg.t \
Expand Down
81 changes: 81 additions & 0 deletions t/t0005-exec-jobid.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/bin/sh
#

test_description='Test exec command --jobid option
Test exec --jobid functionality
'

. `dirname $0`/sharness.sh
SIZE=4
test_under_flux ${SIZE} job

TMPDIR=$(cd /tmp && $(which pwd))

test_expect_success 'flux exec --jobid fails with invalid job id' '
test_expect_code 1 flux exec --jobid=f-o-o true 2>badid.err &&
test_debug "cat badid.err" &&
grep "error parsing jobid" badid.err
'
test_expect_success 'flux exec --jobid fails for nonexistent job id' '
test_expect_code 1 flux exec --jobid=f1 true 2>noid.err &&
test_debug "cat noid.err" &&
grep "not found" noid.err
'
test_expect_success 'run two jobs on different ranks' '
flux submit --wait-event=start --bcc=1-2 -N1 sleep inf &&
id1=$(flux job last [-1:]) &&
id2=$(flux job last) &&
test_debug "flux jobs -no \"{id} {ranks}\""
'
test_expect_success 'flux exec --jobid works' '
rank1=$(flux exec --jobid=$id1 flux getattr rank) &&
rank2=$(flux exec --jobid=$id2 flux getattr rank) &&
test_debug "echo flux exec --jobid=$id1 ran on rank $rank1" &&
test_debug "echo flux exec --jobid=$id2 ran on rank $rank2" &&
test $rank1 -eq $(flux jobs -no {ranks} $id1) &&
test $rank2 -eq $(flux jobs -no {ranks} $id2)
'
test_expect_success 'run one job on two ranks' '
jobid=$(flux submit --wait-event=start -N2 sleep inf)
'
test_expect_success 'flux exec --jobid on multi-node jobs runs on all ranks' '
flux exec --jobid=$jobid --label-io flux getattr rank >2node.out &&
test_debug "cat 2node.out" &&
grep "2: 2" 2node.out &&
grep "3: 3" 2node.out
'
test_expect_success 'flux exec --jobid works with --rank option' '
flux exec --jobid=$jobid -r 0 flux getattr rank &&
test $(flux exec --jobid=$jobid -r 0 flux getattr rank) -eq 2 &&
flux exec --jobid=$jobid -r 1 flux getattr rank &&
test $(flux exec --jobid=$jobid -r 1 flux getattr rank) -eq 3
'
test_expect_success 'flux exec --jobid fails with invalid --rank option' '
test_must_fail flux exec --jobid=$jobid -r 3 hostname &&
test_must_fail flux exec --jobid=$jobid -r 0-3 hostname
'
test_expect_success 'flux exec --jobid works with --exclude option' '
flux exec --jobid=$jobid -x 0 flux getattr rank &&
test $(flux exec --jobid=$jobid -x 0 flux getattr rank) -eq 3 &&
flux exec --jobid=$jobid -x 1 flux getattr rank &&
test $(flux exec --jobid=$jobid -x 1 flux getattr rank) -eq 2
'
test_expect_success 'flux exec --jobid fails with invalid --exclude option' '
test_must_fail flux exec --jobid=$jobid -x 3 hostname &&
test_must_fail flux exec --jobid=$jobid -x 0-3 hostname
'
test_expect_success 'flux exec --jobid fails if there are no ranks to target' '
test_must_fail flux exec --jobid=$jobid -x 0-1 hostname
'
test_expect_success 'cancel jobs' '
flux cancel --all &&
flux job wait-event $id1 clean
'
test_expect_success 'flux exec --jobid on inactive job fails' '
test_must_fail flux exec --jobid=$id1 hostname 2>inactive.err &&
test_debug "cat inactive.err" &&
grep "not currently running" inactive.err
'

test_done

0 comments on commit 2e59e01

Please sign in to comment.