Skip to content

Commit

Permalink
testsuite: add job-info jobspec update coverage
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
chu11 committed Feb 1, 2024
1 parent 53a2751 commit 2fa2070
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions t/t2233-job-info-update.t
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,57 @@ test_expect_success NO_CHAIN_LINT 'job-info: lookup current returns cached R fro
cat lookup9B.out | jq -e ".execution.expiration == ${update1}"
'

#
# lookup w/ current and update-watch works with jobspec
#

# Usage: check_duration jobid VALUE
# Check and wait for duration to reach VALUE.
#
check_duration() {
local jobid=$1
local value=$2
local i=0
while (! ${INFO_LOOKUP} -c ${jobid} jobspec | jq -e ".attributes.system.duration == ${value}" \
&& [ $i -lt 200 ] )
do
sleep 0.1
i=$((i + 1))
done
if [ "$i" -eq "200" ]
then
return 1
fi
return 0
}

test_expect_success 'job-info: lookup current works with jobspec' '
jobid=$(flux submit --urgency=hold true) &&
check_duration $jobid 0 &&
flux update $jobid duration=100s &&
check_duration $jobid 100.0 &&
flux update $jobid duration=200s &&
check_duration $jobid 200.0 &&
flux cancel $jobid
'

test_expect_success NO_CHAIN_LINT 'job-info: update watch works with jobspec' '
jobid=$(flux submit --urgency=hold true) &&
flux update $jobid duration=100s &&
watchers=$(get_update_watchers)
${UPDATE_WATCH} $jobid jobspec > watchjobspec.out &
watchpid=$! &&
wait_update_watchers $((watchers+1)) &&
${WAITFILE} --count=1 --timeout=30 --pattern="duration" watchjobspec.out &&
flux update $jobid duration=200s &&
${WAITFILE} --count=2 --timeout=30 --pattern="duration" watchjobspec.out &&
flux cancel $jobid &&
wait $watchpid &&
test $(cat watchjobspec.out | wc -l) -eq 2 &&
head -n1 watchjobspec.out | jq -e ".attributes.system.duration == 100.0" &&
tail -n1 watchjobspec.out | jq -e ".attributes.system.duration == 200.0"
'

#
# security tests
#
Expand All @@ -327,6 +378,7 @@ test_expect_success 'job-info: non job owner cannot lookup key' '
jobid=`flux submit --wait-event=start sleep inf` &&
set_userid 9999 &&
test_must_fail ${UPDATE_LOOKUP} $jobid R &&
test_must_fail ${INFO_LOOKUP} -u $jobid jobspec &&
unset_userid &&
flux cancel $jobid
'
Expand All @@ -335,6 +387,7 @@ test_expect_success 'job-info: non job owner cannot watch key' '
jobid=`flux submit --wait-event=start sleep inf` &&
set_userid 9999 &&
test_must_fail ${UPDATE_WATCH} $jobid R &&
test_must_fail ${UPDATE_WATCH} $jobid jobspec &&
unset_userid &&
flux cancel $jobid
'
Expand Down

0 comments on commit 2fa2070

Please sign in to comment.