@@ -68,23 +68,24 @@ test_expect_success 'job-info: generate jobspec for simple test job' '
6868 flux run --dry-run -n1 -N1 sleep 300 > sleeplong.json
6969'
7070
71+ test_expect_success ' submit and cancel job for test use' '
72+ JOBID=$(submit_job)
73+ '
74+
7175test_expect_success ' flux job wait-event works' '
72- jobid=$(submit_job) &&
73- fj_wait_event $jobid submit > wait_event1.out &&
76+ fj_wait_event $JOBID submit > wait_event1.out &&
7477 grep submit wait_event1.out
7578'
7679
7780test_expect_success NO_CHAIN_LINT ' flux job wait-event errors on non-event' '
78- jobid=$(submit_job) &&
79- test_must_fail fj_wait_event $jobid foobar 2> wait_event2.err &&
81+ test_must_fail fj_wait_event $JOBID foobar 2> wait_event2.err &&
8082 grep "never received" wait_event2.err
8183'
8284
8385test_expect_success NO_CHAIN_LINT ' flux job wait-event does not see event after clean' '
84- jobid=$(submit_job) &&
85- kvsdir=$(flux job id --to=kvs $jobid) &&
86+ kvsdir=$(flux job id --to=kvs $JOBID) &&
8687 flux kvs eventlog append ${kvsdir}.eventlog foobar &&
87- test_must_fail fj_wait_event -v $jobid foobar 2> wait_event3.err &&
88+ test_must_fail fj_wait_event -v $JOBID foobar 2> wait_event3.err &&
8889 grep "never received" wait_event3.err
8990'
9091
@@ -93,22 +94,19 @@ test_expect_success 'flux job wait-event fails on bad id' '
9394'
9495
9596test_expect_success ' flux job wait-event --quiet works' '
96- jobid=$(submit_job) &&
97- fj_wait_event --quiet $jobid submit > wait_event4.out &&
97+ fj_wait_event --quiet $JOBID submit > wait_event4.out &&
9898 ! test -s wait_event4.out
9999'
100100
101101test_expect_success ' flux job wait-event --verbose works' '
102- jobid=$(submit_job) &&
103- fj_wait_event --verbose $jobid clean > wait_event5.out &&
102+ fj_wait_event --verbose $JOBID clean > wait_event5.out &&
104103 grep submit wait_event5.out &&
105104 grep start wait_event5.out &&
106105 grep clean wait_event5.out
107106'
108107
109108test_expect_success ' flux job wait-event --verbose doesnt show events after wait event' '
110- jobid=$(submit_job) &&
111- fj_wait_event --verbose $jobid submit > wait_event6.out &&
109+ fj_wait_event --verbose $JOBID submit > wait_event6.out &&
112110 grep submit wait_event6.out &&
113111 ! grep start wait_event6.out &&
114112 ! grep clean wait_event6.out
@@ -122,140 +120,123 @@ test_expect_success 'flux job wait-event --timeout works' '
122120'
123121
124122test_expect_success ' flux job wait-event --format=json works' '
125- jobid=$(submit_job) &&
126- fj_wait_event --format=json $jobid submit > wait_event_format1.out &&
123+ fj_wait_event --format=json $JOBID submit > wait_event_format1.out &&
127124 grep -q "\"name\":\"submit\"" wait_event_format1.out &&
128125 grep -q "\"userid\":$(id -u)" wait_event_format1.out
129126'
130127
131128test_expect_success ' flux job wait-event --format=text works' '
132- jobid=$(submit_job) &&
133- fj_wait_event --format=text $jobid submit > wait_event_format2.out &&
129+ fj_wait_event --format=text $JOBID submit > wait_event_format2.out &&
134130 grep -q "submit" wait_event_format2.out &&
135131 grep -q "userid=$(id -u)" wait_event_format2.out
136132'
137133
138134test_expect_success ' flux job wait-event --format=invalid fails' '
139- jobid=$(submit_job) &&
140- test_must_fail fj_wait_event --format=invalid $jobid submit
135+ test_must_fail fj_wait_event --format=invalid $JOBID submit
141136'
142137
143138test_expect_success ' flux job wait-event --time-format=raw works' '
144- jobid=$(submit_job) &&
145- fj_wait_event --time-format=raw $jobid submit > wait_event_time_format1.out &&
139+ fj_wait_event --time-format=raw $JOBID submit > wait_event_time_format1.out &&
146140 get_timestamp_field submit wait_event_time_format1.out | grep "\."
147141'
148142
149143test_expect_success ' flux job wait-event --time-format=iso works' '
150- jobid=$(submit_job) &&
151- fj_wait_event --time-format=iso $jobid submit > wait_event_time_format2.out &&
144+ fj_wait_event --time-format=iso $JOBID submit > wait_event_time_format2.out &&
152145 get_timestamp_field submit wait_event_time_format2.out | grep T | grep Z
153146'
154147
155148test_expect_success ' flux job wait-event --time-format=offset works' '
156- jobid=$(submit_job) &&
157- fj_wait_event --time-format=offset $jobid submit > wait_event_time_format3A.out &&
149+ fj_wait_event --time-format=offset $JOBID submit > wait_event_time_format3A.out &&
158150 get_timestamp_field submit wait_event_time_format3A.out | grep "0.000000" &&
159- fj_wait_event --time-format=offset $jobid exception > wait_event_time_format3B.out &&
151+ fj_wait_event --time-format=offset $JOBID exception > wait_event_time_format3B.out &&
160152 get_timestamp_field exception wait_event_time_format3B.out | grep -v "0.000000"
161153'
162154
163155test_expect_success ' flux job wait-event --time-format=invalid fails works' '
164- jobid=$(submit_job) &&
165- test_must_fail fj_wait_event --time-format=invalid $jobid submit
156+ test_must_fail fj_wait_event --time-format=invalid $JOBID submit
166157'
167158
168159test_expect_success ' flux job wait-event w/ match-context works (string w/ quotes)' '
169- jobid=$(submit_job) &&
170- fj_wait_event --match-context="type=\"cancel\"" $jobid exception > wait_event_context1.out &&
160+ fj_wait_event --match-context="type=\"cancel\"" $JOBID exception > wait_event_context1.out &&
171161 grep -q "exception" wait_event_context1.out &&
172162 grep -q "type=\"cancel\"" wait_event_context1.out
173163'
174164
175165test_expect_success ' flux job wait-event w/ match-context works (string w/o quotes)' '
176- jobid=$(submit_job) &&
177- fj_wait_event --match-context=type=cancel $jobid exception > wait_event_context2.out &&
166+ fj_wait_event --match-context=type=cancel $JOBID exception > wait_event_context2.out &&
178167 grep -q "exception" wait_event_context2.out &&
179168 grep -q "type=\"cancel\"" wait_event_context2.out
180169'
181170
182171test_expect_success ' flux job wait-event w/ match-context works (int)' '
183- jobid=$(submit_job) &&
184- fj_wait_event --match-context=flags=0 $jobid submit > wait_event_context3.out &&
172+ fj_wait_event --match-context=flags=0 $JOBID submit > wait_event_context3.out &&
185173 grep -q "submit" wait_event_context3.out &&
186174 grep -q "flags=0" wait_event_context3.out
187175'
188176
189177test_expect_success ' flux job wait-event w/ bad match-context fails (invalid key)' '
190- jobid=$(submit_job) &&
191- test_must_fail fj_wait_event --match-context=foo=bar $jobid exception
178+ test_must_fail fj_wait_event --match-context=foo=bar $JOBID exception
192179'
193180
194181test_expect_success ' flux job wait-event w/ bad match-context fails (invalid value)' '
195- jobid=$(submit_job) &&
196- test_must_fail fj_wait_event --match-context=type=foo $jobid exception
182+ test_must_fail fj_wait_event --match-context=type=foo $JOBID exception
183+ '
184+
185+ # Note: in test below, foo=0 would match severity=0 in buggy version
186+ test_expect_success ' flux job wait-event w/ bad match-context fails (issue #5845)' '
187+ test_must_fail fj_wait_event --match-context=foo=0 $JOBID exception
197188'
198189
199190test_expect_success ' flux job wait-event w/ bad match-context fails (invalid input)' '
200- jobid=$(submit_job) &&
201- test_must_fail fj_wait_event --match-context=foo $jobid exception
191+ test_must_fail fj_wait_event --match-context=foo $JOBID exception
202192'
203193
204194test_expect_success ' flux job wait-event -p works (eventlog)' '
205- jobid=$(submit_job) &&
206- fj_wait_event -p "eventlog" $jobid submit > wait_event_path1.out &&
195+ fj_wait_event -p "eventlog" $JOBID submit > wait_event_path1.out &&
207196 grep submit wait_event_path1.out
208197'
209198
210199test_expect_success ' flux job wait-event -p works (guest.exec.eventlog)' '
211- jobid=$(submit_job) &&
212- fj_wait_event -p "guest.exec.eventlog" $jobid done > wait_event_path2.out &&
200+ fj_wait_event -p "guest.exec.eventlog" $JOBID done > wait_event_path2.out &&
213201 grep done wait_event_path2.out
214202'
215203test_expect_success ' flux job wait-event -p works (exec)' '
216- fj_wait_event -p exec $jobid done > wait_event_path2.1.out &&
204+ fj_wait_event -p exec $JOBID done > wait_event_path2.1.out &&
217205 grep done wait_event_path2.1.out
218206'
219207test_expect_success ' flux job wait-event -p works (non-guest eventlog)' '
220- jobid=$(submit_job) &&
221- kvsdir=$(flux job id --to=kvs $jobid) &&
208+ kvsdir=$(flux job id --to=kvs $JOBID) &&
222209 flux kvs eventlog append ${kvsdir}.foobar.eventlog foobar &&
223- fj_wait_event -p "foobar.eventlog" $jobid foobar > wait_event_path3.out &&
210+ fj_wait_event -p "foobar.eventlog" $JOBID foobar > wait_event_path3.out &&
224211 grep foobar wait_event_path3.out
225212'
226213
227214test_expect_success ' flux job wait-event -p fails on invalid path' '
228- jobid=$(submit_job) &&
229- test_must_fail fj_wait_event -p "foobar" $jobid submit
215+ test_must_fail fj_wait_event -p "foobar" $JOBID submit
230216'
231217
232218test_expect_success ' flux job wait-event -p fails on invalid guest path' '
233- jobid=$(submit_job) &&
234- test_must_fail fj_wait_event -p "guest.foobar" $jobid submit
219+ test_must_fail fj_wait_event -p "guest.foobar" $JOBID submit
235220'
236221
237222test_expect_success ' flux job wait-event -p fails on path "guest."' '
238- jobid=$(submit_job) &&
239- test_must_fail fj_wait_event -p "guest." $jobid submit
223+ test_must_fail fj_wait_event -p "guest." $JOBID submit
240224'
241225
242226test_expect_success ' flux job wait-event -p and --waitcreate works (exec)' '
243- jobid=$(submit_job) &&
244- fj_wait_event --waitcreate -p exec $jobid done > wait_event_path4.out &&
227+ fj_wait_event --waitcreate -p exec $JOBID done > wait_event_path4.out &&
245228 grep done wait_event_path4.out
246229'
247230
248231test_expect_success ' flux job wait-event -p invalid and --waitcreate fails' '
249- jobid=$(submit_job) &&
250- test_must_fail fj_wait_event --waitcreate -p "guest.invalid" $jobid foobar 2> waitcreate1.err &&
232+ test_must_fail fj_wait_event --waitcreate -p "guest.invalid" $JOBID foobar 2> waitcreate1.err &&
251233 grep "not found" waitcreate1.err
252234'
253235
254236test_expect_success ' flux job wait-event -p hangs on non-guest eventlog' '
255- jobid=$(submit_job) &&
256- kvsdir=$(flux job id --to=kvs $jobid) &&
237+ kvsdir=$(flux job id --to=kvs $JOBID) &&
257238 flux kvs eventlog append ${kvsdir}.foobar.eventlog foo &&
258- test_expect_code 142 run_timeout -s ALRM 0.2 flux job wait-event -p "foobar.eventlog" $jobid bar
239+ test_expect_code 142 run_timeout -s ALRM 0.2 flux job wait-event -p "foobar.eventlog" $JOBID bar
259240'
260241
261242test_expect_success NO_CHAIN_LINT ' flux job wait-event -p guest.exec.eventlog works (live job)' '
@@ -312,8 +293,7 @@ test_expect_success 'flux job wait-event --count=0 errors' '
312293'
313294
314295test_expect_success ' flux job wait-event --count=1 works' '
315- jobid=$(submit_job) &&
316- fj_wait_event --count=1 ${jobid} clean
296+ fj_wait_event --count=1 ${JOBID} clean
317297'
318298
319299test_expect_success ' flux job wait-event --count=2 works' '
0 commit comments