Skip to content

Commit 1ae5151

Browse files
committed
testsuite: speed up t2231-job-info-eventlog-watch.t
Problem: Many tests in t2231-job-info-eventlog-watch.t submit and cancel a new job when using the same job would work fine. This makes the test much slower than necessary. Reuse the canceled job where possible. Rename the variable to JOBID to avoid collision with other uses of lowercase `jobid`.
1 parent 25c8f8e commit 1ae5151

File tree

1 file changed

+38
-63
lines changed

1 file changed

+38
-63
lines changed

t/t2231-job-info-eventlog-watch.t

Lines changed: 38 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
7175
test_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

7780
test_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

8385
test_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

9596
test_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

101101
test_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

109108
test_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,118 @@ test_expect_success 'flux job wait-event --timeout works' '
122120
'
123121

124122
test_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

131128
test_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

138134
test_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

143138
test_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

149143
test_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

155148
test_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

163155
test_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

168159
test_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

175165
test_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

182171
test_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

189177
test_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

194181
test_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
197183
'
198184

199185
test_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
186+
test_must_fail fj_wait_event --match-context=foo $JOBID exception
202187
'
203188

204189
test_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 &&
190+
fj_wait_event -p "eventlog" $JOBID submit > wait_event_path1.out &&
207191
grep submit wait_event_path1.out
208192
'
209193

210194
test_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 &&
195+
fj_wait_event -p "guest.exec.eventlog" $JOBID done > wait_event_path2.out &&
213196
grep done wait_event_path2.out
214197
'
215198
test_expect_success 'flux job wait-event -p works (exec)' '
216-
fj_wait_event -p exec $jobid done > wait_event_path2.1.out &&
199+
fj_wait_event -p exec $JOBID done > wait_event_path2.1.out &&
217200
grep done wait_event_path2.1.out
218201
'
219202
test_expect_success 'flux job wait-event -p works (non-guest eventlog)' '
220-
jobid=$(submit_job) &&
221-
kvsdir=$(flux job id --to=kvs $jobid) &&
203+
kvsdir=$(flux job id --to=kvs $JOBID) &&
222204
flux kvs eventlog append ${kvsdir}.foobar.eventlog foobar &&
223-
fj_wait_event -p "foobar.eventlog" $jobid foobar > wait_event_path3.out &&
205+
fj_wait_event -p "foobar.eventlog" $JOBID foobar > wait_event_path3.out &&
224206
grep foobar wait_event_path3.out
225207
'
226208

227209
test_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
210+
test_must_fail fj_wait_event -p "foobar" $JOBID submit
230211
'
231212

232213
test_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
214+
test_must_fail fj_wait_event -p "guest.foobar" $JOBID submit
235215
'
236216

237217
test_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
218+
test_must_fail fj_wait_event -p "guest." $JOBID submit
240219
'
241220

242221
test_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 &&
222+
fj_wait_event --waitcreate -p exec $JOBID done > wait_event_path4.out &&
245223
grep done wait_event_path4.out
246224
'
247225

248226
test_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 &&
227+
test_must_fail fj_wait_event --waitcreate -p "guest.invalid" $JOBID foobar 2> waitcreate1.err &&
251228
grep "not found" waitcreate1.err
252229
'
253230

254231
test_expect_success 'flux job wait-event -p hangs on non-guest eventlog' '
255-
jobid=$(submit_job) &&
256-
kvsdir=$(flux job id --to=kvs $jobid) &&
232+
kvsdir=$(flux job id --to=kvs $JOBID) &&
257233
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
234+
test_expect_code 142 run_timeout -s ALRM 0.2 flux job wait-event -p "foobar.eventlog" $JOBID bar
259235
'
260236

261237
test_expect_success NO_CHAIN_LINT 'flux job wait-event -p guest.exec.eventlog works (live job)' '
@@ -312,8 +288,7 @@ test_expect_success 'flux job wait-event --count=0 errors' '
312288
'
313289

314290
test_expect_success 'flux job wait-event --count=1 works' '
315-
jobid=$(submit_job) &&
316-
fj_wait_event --count=1 ${jobid} clean
291+
fj_wait_event --count=1 ${JOBID} clean
317292
'
318293

319294
test_expect_success 'flux job wait-event --count=2 works' '

0 commit comments

Comments
 (0)