Skip to content

Commit ee903ce

Browse files
committed
testsuite: add job-info CURRENT flag coverage
Problem: There is no coverage for the job-info.lookup RPC's new CURRENT flag. Add coverage in t2233-job-info-update.t.
1 parent 5ad254f commit ee903ce

File tree

2 files changed

+49
-15
lines changed

2 files changed

+49
-15
lines changed

t/job-info/info_lookup.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,17 @@
2020
#include "src/common/libutil/log.h"
2121
#include "ccan/str/str.h"
2222

23-
#define OPTIONS "j"
23+
#define OPTIONS "jc"
2424
static const struct option longopts[] = {
2525
{"json-decode", no_argument, 0, 'j'},
26+
{"current", no_argument, 0, 'c'},
2627
{ 0, 0, 0, 0 },
2728
};
2829

2930
static void usage (void)
3031
{
31-
fprintf (stderr, "Usage: info_lookup [--json-decode] <jobid> <key> ...\n");
32+
fprintf (stderr, "Usage: info_lookup [--json-decode] "
33+
"[--current] <jobid> <key> ...\n");
3234
exit (1);
3335
}
3436

@@ -46,6 +48,9 @@ int main (int argc, char *argv[])
4648
case 'j': /* --json-decode */
4749
flags |= FLUX_JOB_LOOKUP_JSON_DECODE;
4850
break;
51+
case 'c': /* --current */
52+
flags |= FLUX_JOB_LOOKUP_CURRENT;
53+
break;
4954
default:
5055
usage ();
5156
break;
@@ -104,7 +109,7 @@ int main (int argc, char *argv[])
104109
free (s);
105110
}
106111
else {
107-
char *s;
112+
const char *s;
108113
if (flux_rpc_get_unpack (f, "{s:s}", argv[i], &s) < 0)
109114
log_msg_exit ("job-info.lookup: %s",
110115
future_strerror (f, errno));

t/t2233-job-info-update.t

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
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

77
test_under_flux 1 job
88

99
RPC=${FLUX_BUILD_DIR}/t/request/rpc
1010
RPC_STREAM=${FLUX_BUILD_DIR}/t/request/rpc_stream
11+
INFO_LOOKUP=${FLUX_BUILD_DIR}/t/job-info/info_lookup
1112
UPDATE_LOOKUP=${FLUX_BUILD_DIR}/t/job-info/update_lookup
1213
UPDATE_WATCH=${FLUX_BUILD_DIR}/t/job-info/update_watch_stream
1314
WAITFILE="${SHARNESS_TEST_SRCDIR}/scripts/waitfile.lua"
@@ -55,6 +56,26 @@ expiration_add() {
5556
# Check and wait for expiration to reach VALUE.
5657
#
5758
check_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

103129
test_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
331359
test_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

Comments
 (0)