Skip to content

Commit 003f8e7

Browse files
committed
testsuite: add job-info jobspec update coverage
Problem: There is no coverage for job-info lookups w/ the current flag or update-watch for the jobspec key. Add some coverage in t2233-job-info-update.t.
1 parent cb9fa72 commit 003f8e7

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

t/t2233-job-info-update.t

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,57 @@ test_expect_success NO_CHAIN_LINT 'job-info: lookup current returns cached R fro
309309
cat lookup9B.out | jq -e ".execution.expiration == ${update1}"
310310
'
311311

312+
#
313+
# lookup w/ current and update-watch works with jobspec
314+
#
315+
316+
# Usage: check_duration jobid VALUE
317+
# Check and wait for duration to reach VALUE.
318+
#
319+
check_duration() {
320+
local jobid=$1
321+
local value=$2
322+
local i=0
323+
while (! ${INFO_LOOKUP} -c ${jobid} jobspec | jq -e ".attributes.system.duration == ${value}" \
324+
&& [ $i -lt 200 ] )
325+
do
326+
sleep 0.1
327+
i=$((i + 1))
328+
done
329+
if [ "$i" -eq "200" ]
330+
then
331+
return 1
332+
fi
333+
return 0
334+
}
335+
336+
test_expect_success 'job-info: lookup current works with jobspec' '
337+
jobid=$(flux submit --urgency=hold true) &&
338+
check_duration $jobid 0 &&
339+
flux update $jobid duration=100s &&
340+
check_duration $jobid 100.0 &&
341+
flux update $jobid duration=200s &&
342+
check_duration $jobid 200.0 &&
343+
flux cancel $jobid
344+
'
345+
346+
test_expect_success NO_CHAIN_LINT 'job-info: update watch works with jobspec' '
347+
jobid=$(flux submit --urgency=hold true) &&
348+
flux update $jobid duration=100s &&
349+
watchers=$(get_update_watchers)
350+
${UPDATE_WATCH} $jobid jobspec > watchjobspec.out &
351+
watchpid=$! &&
352+
wait_update_watchers $((watchers+1)) &&
353+
${WAITFILE} --count=1 --timeout=30 --pattern="duration" watchjobspec.out &&
354+
flux update $jobid duration=200s &&
355+
${WAITFILE} --count=2 --timeout=30 --pattern="duration" watchjobspec.out &&
356+
flux cancel $jobid &&
357+
wait $watchpid &&
358+
test $(cat watchjobspec.out | wc -l) -eq 2 &&
359+
head -n1 watchjobspec.out | jq -e ".attributes.system.duration == 100.0" &&
360+
tail -n1 watchjobspec.out | jq -e ".attributes.system.duration == 200.0"
361+
'
362+
312363
#
313364
# security tests
314365
#
@@ -327,6 +378,7 @@ test_expect_success 'job-info: non job owner cannot lookup key' '
327378
jobid=`flux submit --wait-event=start sleep inf` &&
328379
set_userid 9999 &&
329380
test_must_fail ${UPDATE_LOOKUP} $jobid R &&
381+
test_must_fail ${INFO_LOOKUP} -u $jobid jobspec &&
330382
unset_userid &&
331383
flux cancel $jobid
332384
'
@@ -335,6 +387,7 @@ test_expect_success 'job-info: non job owner cannot watch key' '
335387
jobid=`flux submit --wait-event=start sleep inf` &&
336388
set_userid 9999 &&
337389
test_must_fail ${UPDATE_WATCH} $jobid R &&
390+
test_must_fail ${UPDATE_WATCH} $jobid jobspec &&
338391
unset_userid &&
339392
flux cancel $jobid
340393
'

0 commit comments

Comments
 (0)