Skip to content

Commit 34db805

Browse files
committed
testsuite: add tests for post-job-event
Problem: There's no tests for the `flux post-job-event` utility. Add a new sharness test t2815-post-job-event.t.
1 parent 1c474cf commit 34db805

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

t/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ TESTSCRIPTS = \
233233
t2812-flux-job-last.t \
234234
t2813-flux-watch.t \
235235
t2814-hostlist-cmd.t \
236+
t2815-post-job-event.t \
236237
t2900-job-timelimits.t \
237238
t3000-mpi-basic.t \
238239
t3001-mpi-personalities.t \

t/t2815-post-job-event.t

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/sh
2+
3+
test_description='Test flux post-job-event command'
4+
5+
. $(dirname $0)/sharness.sh
6+
7+
test_under_flux 1
8+
9+
test_expect_success 'run a test job' '
10+
JOBID=$(flux submit --wait-event=start sleep inf)
11+
'
12+
test_expect_success 'flux-post-job-event --help works' '
13+
flux post-job-event --help >help.out &&
14+
test_debug "cat help.out" &&
15+
grep "name of event to post" help.out
16+
'
17+
test_expect_success 'flux-post-job-event can post a simple event' '
18+
flux post-job-event $JOBID test &&
19+
flux job wait-event -t15 $JOBID test
20+
'
21+
test_expect_success 'flux-post-job-event can post an event with context' '
22+
flux post-job-event $JOBID test note=testing &&
23+
flux job wait-event -m note=testing -t15 $JOBID test
24+
'
25+
test_expect_success 'flux-post-job-event can post multiple context keys' '
26+
flux post-job-event $JOBID test note=test2 status=0 &&
27+
flux job wait-event -m note=test2 -t15 $JOBID test &&
28+
flux job wait-event -m status=0 -t15 $JOBID test
29+
'
30+
test_expect_success 'flux-post-job-event fails for invalid job' '
31+
test_must_fail flux post-job-event f123 test note="test event"
32+
'
33+
test_expect_success 'flux-post-job-event fails for inactive job' '
34+
flux cancel $JOBID &&
35+
flux job wait-event $JOBID clean &&
36+
test_must_fail flux post-job-event $JOBID test note="test event"
37+
'
38+
test_expect_success 'flux-post-job-event fails with invalid id' '
39+
test_must_fail flux post-job-event baz test
40+
'
41+
test_done

0 commit comments

Comments
 (0)