Skip to content

Commit 144b94e

Browse files
committed
testsuite: cover user exceptions in job-list tests
Problem: There is no coverage for user exceptions in the job-list / flux-jobs tests. Solution: Add some additional coverage by adding a job ended with a user exception in t2260-job-list.t and t2800-jobs-cmd.t.
1 parent 7ae61c6 commit 144b94e

File tree

2 files changed

+48
-7
lines changed

2 files changed

+48
-7
lines changed

t/t2260-job-list.t

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,16 @@ test_expect_success 'submit jobs for job list testing' '
8888
flux job id $jobid > terminated.ids &&
8989
flux job id $jobid >> failedids &&
9090
#
91+
# Run a job that we will end with a user exception, copy its JOBID to both
92+
# inactive and failed and exception lists.
93+
#
94+
jobid=`flux submit --wait-event=start sleep inf` &&
95+
flux job raise --type=myexception --severity=0 -m "myexception" $jobid &&
96+
fj_wait_event $jobid clean &&
97+
echo $jobid >> inactiveids &&
98+
flux job id $jobid > exception.ids &&
99+
flux job id $jobid >> failedids &&
100+
#
91101
# Run a job that will timeout, copy its JOBID to both inactive and
92102
# timeout lists.
93103
#
@@ -189,7 +199,7 @@ test_expect_success 'flux job list inactive jobs results are correct' '
189199
flux job list -s inactive | jq .result | ${JOB_CONV} resulttostr > list_result_I.out &&
190200
echo "CANCELED" >> list_result_I.exp &&
191201
echo "TIMEOUT" >> list_result_I.exp &&
192-
for count in `seq 1 2`; do \
202+
for count in `seq 1 3`; do \
193203
echo "FAILED" >> list_result_I.exp; \
194204
done &&
195205
for count in `seq 1 4`; do \
@@ -471,7 +481,7 @@ test_expect_success 'flux job list-inactive w/ since (second to most recent time
471481
test_expect_success 'flux job list-inactive w/ since (oldest timestamp)' '
472482
timestamp=`cat list-inactive.out | tail -n 1 | jq .t_inactive` &&
473483
count=`flux job list-inactive --since=${timestamp} | wc -l` &&
474-
test $count -eq 23
484+
test $count -eq 24
475485
'
476486

477487
test_expect_success 'flux job list-inactive w/ since (middle timestamp #1)' '
@@ -1401,6 +1411,18 @@ test_expect_success 'flux job list outputs exceptions correctly (exception cance
14011411
echo $obj | jq -e ".exception_note == \"mecanceled\""
14021412
'
14031413

1414+
test_expect_success 'flux job list outputs exceptions correctly (user exception)' '
1415+
jobid=`flux submit sleep inf | flux job id` &&
1416+
echo $jobid > exceptions5.id &&
1417+
flux job raise --type=foo --severity=0 -m "foobar" $jobid &&
1418+
wait_jobid_state $jobid inactive &&
1419+
obj=$(flux job list -s inactive | grep $jobid) &&
1420+
echo $obj | jq -e ".exception_occurred == true" &&
1421+
echo $obj | jq -e ".exception_severity == 0" &&
1422+
echo $obj | jq -e ".exception_type == \"foo\"" &&
1423+
echo $obj | jq -e ".exception_note == \"foobar\""
1424+
'
1425+
14041426
test_expect_success 'reload the job-list module' '
14051427
flux module reload job-list
14061428
'
@@ -1410,6 +1432,7 @@ test_expect_success 'verify task count preserved across restart' '
14101432
jobid2=`cat exceptions2.id` &&
14111433
jobid3=`cat exceptions3.id` &&
14121434
jobid4=`cat exceptions4.id` &&
1435+
jobid5=`cat exceptions5.id` &&
14131436
obj=$(flux job list -s inactive | grep ${jobid1}) &&
14141437
echo $obj | jq -e ".success == true" &&
14151438
echo $obj | jq -e ".exception_occurred == false" &&
@@ -1430,7 +1453,12 @@ test_expect_success 'verify task count preserved across restart' '
14301453
echo $obj | jq -e ".exception_occurred == true" &&
14311454
echo $obj | jq -e ".exception_severity == 0" &&
14321455
echo $obj | jq -e ".exception_type == \"cancel\"" &&
1433-
echo $obj | jq -e ".exception_note == \"mecanceled\""
1456+
echo $obj | jq -e ".exception_note == \"mecanceled\"" &&
1457+
obj=$(flux job list -s inactive | grep ${jobid5}) &&
1458+
echo $obj | jq -e ".exception_occurred == true" &&
1459+
echo $obj | jq -e ".exception_severity == 0" &&
1460+
echo $obj | jq -e ".exception_type == \"foo\"" &&
1461+
echo $obj | jq -e ".exception_note == \"foobar\""
14341462
'
14351463

14361464
# expiration time

t/t2800-jobs-cmd.t

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,16 @@ test_expect_success 'submit jobs for job list testing' '
129129
flux job id $jobid > terminated.ids &&
130130
flux job id $jobid >> failedids &&
131131
#
132+
# Run a job that we will end with a user exception, copy its JOBID to both
133+
# inactive and failed and exception lists.
134+
#
135+
jobid=`flux submit --wait-event=start sleep inf` &&
136+
flux job raise --type=myexception --severity=0 -m "myexception" $jobid &&
137+
fj_wait_event $jobid clean &&
138+
echo $jobid >> inactiveids &&
139+
flux job id $jobid > exception.ids &&
140+
flux job id $jobid >> failedids &&
141+
#
132142
# Run a job that will timeout, copy its JOBID to both inactive and
133143
# timeout lists.
134144
#
@@ -533,8 +543,9 @@ test_expect_success 'flux-jobs --format={name} works' '
533543
echo "canceledjob" >> jobnameI.exp &&
534544
echo "sleep" >> jobnameI.exp &&
535545
echo "sleep" >> jobnameI.exp &&
546+
echo "sleep" >> jobnameI.exp &&
536547
echo "nosuchcommand" >> jobnameI.exp &&
537-
count=$(($(state_count inactive) - 4)) &&
548+
count=$(($(state_count inactive) - 5)) &&
538549
for i in `seq 1 $count`; do
539550
echo "hostname" >> jobnameI.exp
540551
done &&
@@ -626,7 +637,7 @@ test_expect_success 'flux-jobs --format={runtime:0.3f} works' '
626637
done &&
627638
test_cmp runtime-dotP.out runtime-dotP.exp &&
628639
flux jobs --filter=running,inactive -no "{runtime:0.3f}" > runtime-dotRI.out &&
629-
[ "$(grep -E "\.[0-9]{3}" runtime-dotRI.out | wc -l)" = "16" ]
640+
[ "$(grep -E "\.[0-9]{3}" runtime-dotRI.out | wc -l)" = "17" ]
630641
'
631642

632643
test_expect_success 'flux-jobs --format={contextual_time} works' '
@@ -803,6 +814,8 @@ test_expect_success 'flux-jobs --format={exception.*},{exception.*:h} works' '
803814
flux jobs --filter=inactive -no "$fmt" > exceptionI.out &&
804815
count=$(grep -c "^True,True,0,0,cancel,cancel,mecanceled,mecanceled$" exceptionI.out) &&
805816
test $count -eq $(state_count canceled) &&
817+
count=$(grep -c "^True,True,0,0,myexception,myexception,myexception,myexception$" exceptionI.out) &&
818+
test $count -eq $(state_count exception) &&
806819
count=$(grep -c "^True,True,0,0,exec,exec,.*No such file.*" exceptionI.out) &&
807820
test $count -eq $(state_count failed_exec) &&
808821
count=$(grep -c "^True,True,0,0,timeout,timeout,.*expired.*" exceptionI.out) &&
@@ -900,8 +913,8 @@ test_expect_success 'flux-jobs --format={waitstatus},{returncode}' '
900913
test_debug "echo exit 127 got $count, want $(state_count failed_exec)" &&
901914
test $count -eq $(state_count failed_exec) &&
902915
count=$(grep -c "^36608,143$" returncodeI.out) &&
903-
test_debug "echo exit 143 got $count, want $(state_count terminated)" &&
904-
test $count -eq $(state_count terminated) &&
916+
test_debug "echo exit 143 got $count, want $(state_count terminated exception)" &&
917+
test $count -eq $(state_count terminated exception) &&
905918
count=$(grep -c "^36352,142$" returncodeI.out) &&
906919
test_debug "echo exit 142 got $count, want $(state_count timeout)" &&
907920
test $count -eq $(state_count timeout) &&

0 commit comments

Comments
 (0)