11#! /bin/sh
22
3- test_description=' Test flux job info service update lookup/ watch'
3+ test_description=' Test flux job info service lookup w/ update and update- watch'
44
55. $( dirname $0 ) /sharness.sh
66
77test_under_flux 1 job
88
99RPC=${FLUX_BUILD_DIR} /t/request/rpc
1010RPC_STREAM=${FLUX_BUILD_DIR} /t/request/rpc_stream
11+ INFO_LOOKUP=${FLUX_BUILD_DIR} /t/job-info/info_lookup
1112UPDATE_LOOKUP=${FLUX_BUILD_DIR} /t/job-info/update_lookup
1213UPDATE_WATCH=${FLUX_BUILD_DIR} /t/job-info/update_watch_stream
1314WAITFILE=" ${SHARNESS_TEST_SRCDIR} /scripts/waitfile.lua"
@@ -55,6 +56,26 @@ expiration_add() {
5556# Check and wait for expiration to reach VALUE.
5657#
5758check_expiration () {
59+ local jobid=$1
60+ local value=$2
61+ local i=0
62+ while (! ${INFO_LOOKUP} -c ${jobid} R | jq -e " .execution.expiration == ${value} " \
63+ && [ $i -lt 200 ] )
64+ do
65+ sleep 0.1
66+ i=$(( i + 1 ))
67+ done
68+ if [ " $i " -eq " 200" ]
69+ then
70+ return 1
71+ fi
72+ return 0
73+ }
74+
75+ # Usage: check_expiration_legacy jobid VALUE
76+ # Check and wait for expiration to reach VALUE.
77+ #
78+ check_expiration_legacy () {
5879 local jobid=$1
5980 local value=$2
6081 local i=0
@@ -71,33 +92,38 @@ check_expiration() {
7192 return 0
7293}
7394
74- test_expect_success ' job-info: update lookup with no update events works (job active)' '
95+ test_expect_success ' job-info: lookup current with no update events works (job active)' '
7596 jobid=$(flux submit --wait-event=start sleep 300) &&
7697 check_expiration $jobid 0.0 &&
98+ check_expiration_legacy $jobid 0.0 &&
7799 flux cancel $jobid
78100'
79101
80- test_expect_success ' job-info: update lookup with no update events works (job inactive)' '
102+ test_expect_success ' job-info: lookup current with no update events works (job inactive)' '
81103 jobid=$(flux submit --wait-event=clean hostname) &&
82- check_expiration $jobid 0.0
104+ check_expiration $jobid 0.0 &&
105+ check_expiration_legacy $jobid 0.0
83106'
84107
85- test_expect_success ' job-info: update lookup with update events works (job active)' '
108+ test_expect_success ' job-info: lookup current with update events works (job active)' '
86109 jobid=$(flux submit --wait-event=start sleep 300) &&
87110 update1=$(expiration_add $jobid 100) &&
88111 flux job eventlog $jobid &&
89112 check_expiration $jobid ${update1} &&
113+ check_expiration_legacy $jobid ${update1} &&
90114 update2=$(expiration_add $jobid 200) &&
91115 check_expiration $jobid ${update2} &&
116+ check_expiration_legacy $jobid ${update2} &&
92117 flux cancel $jobid
93118'
94119
95- test_expect_success ' job-info: update lookup with update events works (job inactive)' '
120+ test_expect_success ' job-info: lookup current with update events works (job inactive)' '
96121 jobid=$(flux submit --wait-event=start sleep 300) &&
97122 update1=$(expiration_add $jobid 100) &&
98123 update2=$(expiration_add $jobid 100) &&
99124 flux cancel $jobid &&
100- check_expiration $jobid ${update2}
125+ check_expiration $jobid ${update2} &&
126+ check_expiration_legacy $jobid ${update2}
101127'
102128
103129test_expect_success ' job-info: update watch with no update events works (job inactive)' '
@@ -262,23 +288,25 @@ test_expect_success NO_CHAIN_LINT 'job-info: update watch can be canceled (multi
262288 cat watch10B.out | jq -e ".execution.expiration == ${update1}"
263289'
264290
265- # If someone is already doing an update-watch on a jobid/key, update- lookup can
291+ # If someone is already doing an update-watch on a jobid/key, lookup w/ update can
266292# return the cached info
267- test_expect_success NO_CHAIN_LINT ' job-info: update lookup returns cached R from update watch' '
293+ test_expect_success NO_CHAIN_LINT ' job-info: lookup current returns cached R from update watch' '
268294 jobid=$(flux submit --wait-event=exec.shell.init sleep inf) &&
269295 watchers=$(get_update_watchers)
270296 ${UPDATE_WATCH} $jobid R > watch9.out &
271297 watchpid=$! &&
272298 wait_update_watchers $((watchers+1)) &&
273299 update1=$(expiration_add $jobid 100) &&
274300 ${WAITFILE} --count=2 --timeout=30 --pattern="expiration" watch9.out &&
275- ${UPDATE_LOOKUP} $jobid R > lookup9.out &&
301+ ${INFO_LOOKUP} -c $jobid R > lookup9A.out &&
302+ ${UPDATE_LOOKUP} $jobid R > lookup9B.out &&
276303 flux cancel $jobid &&
277304 wait $watchpid &&
278305 test $(cat watch9.out | wc -l) -eq 2 &&
279306 head -n1 watch9.out | jq -e ".execution.expiration == 0.0" &&
280307 tail -n1 watch9.out | jq -e ".execution.expiration == ${update1}" &&
281- cat lookup9.out | jq -e ".execution.expiration == ${update1}"
308+ cat lookup9A.out | jq -e ".execution.expiration == ${update1}" &&
309+ cat lookup9B.out | jq -e ".execution.expiration == ${update1}"
282310'
283311
284312#
@@ -327,7 +355,7 @@ test_expect_success NO_CHAIN_LINT 'job-info: non job owner cannot watch key (sec
327355 wait $watchpid
328356'
329357
330- # update- lookup cannot read cached watch data
358+ # lookup current cannot read cached watch data
331359test_expect_success NO_CHAIN_LINT ' job-info: non job owner cannot lookup key (piggy backed)' '
332360 jobid=`flux submit --wait-event=exec.shell.init sleep inf`
333361 watchers=$(get_update_watchers)
@@ -336,6 +364,7 @@ test_expect_success NO_CHAIN_LINT 'job-info: non job owner cannot lookup key (pi
336364 wait_update_watchers $((watchers+1)) &&
337365 ${WAITFILE} --count=1 --timeout=30 --pattern="expiration" lookupsecurity.out &&
338366 set_userid 9999 &&
367+ test_must_fail ${INFO_LOOKUP} -c $jobid R &&
339368 test_must_fail ${UPDATE_LOOKUP} $jobid R &&
340369 unset_userid &&
341370 flux cancel $jobid &&
0 commit comments