Skip to content

Commit 25c4953

Browse files
committed
testsuite: add test for expiration update inheritance
Problem: No tests in the testsuite ensure that an expiration update of a job containing a Flux instance is inherited by the subinstance Fluxion scheduler. Add a test to t4011-match-duration.t that launches a subinstance, extends the duration of that instance, then ensures that new jobs submitted to the instance inherit the updated expiration.
1 parent 22400f7 commit 25c4953

File tree

1 file changed

+62
-2
lines changed

1 file changed

+62
-2
lines changed

t/t4011-match-duration.t

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ test_description='Test that parent duration is inherited according to RFC14'
77
#
88
# test_under_flux is under sharness.d/
99
#
10-
test_under_flux 1
10+
test_under_flux 2
1111

12+
flux setattr log-stderr-level 1
1213
export FLUX_URI_RESOLVE_LOCAL=t
1314

1415
# Ensure fluxion modules are loaded under flux-alloc(1)
@@ -34,6 +35,35 @@ test_expect_success 'load fluxion modules in parent instance' '
3435
load_qmanager &&
3536
test_debug "flux dmesg -H | grep version"
3637
'
38+
# Usage: job_manager_get_R ID
39+
# This needs to be a shell script since it will be run under flux-proxy(1):
40+
cat <<'EOF' >job_manager_get_R
41+
#!/bin/sh
42+
flux python -c \
43+
"import flux; \
44+
payload = {\"id\":$(flux job id $1),\"attrs\":[\"R\"]}; \
45+
print(flux.Flux().rpc(\"job-manager.getattr\", payload).get_str()) \
46+
"
47+
EOF
48+
chmod +x job_manager_get_R
49+
50+
export PATH=$(pwd):$PATH
51+
52+
subinstance_get_R() {
53+
flux proxy $1 flux kvs get resource.R
54+
}
55+
subinstance_get_expiration() {
56+
subinstance_get_R $1 | jq .execution.expiration
57+
}
58+
# Usage: subinstance_get_duration ID JOBID
59+
subinstance_get_job_duration() {
60+
flux proxy $1 job_manager_get_R $2 |
61+
jq '.R.execution | .expiration - .starttime'
62+
}
63+
subinstance_get_job_expiration() {
64+
flux proxy $1 job_manager_get_R $2 | jq '.R.execution.expiration'
65+
}
66+
3767
test_expect_success HAVE_JQ 'parent expiration is inherited when duration=0' '
3868
cat >get_R.sh <<-EOT &&
3969
#!/bin/sh
@@ -59,8 +89,38 @@ test_expect_success HAVE_JQ 'parent expiration is inherited when duration=0' '
5989
echo $exp2 | jq ". == $expiration" &&
6090
flux shutdown --quiet $jobid
6191
'
92+
# Check if running job updates are supported:
93+
id=$(flux submit sleep inf)
94+
flux update $id duration=1m && test_set_prereq FLUX_UPDATE_RUNNING
95+
flux cancel $id
96+
97+
test_expect_success FLUX_UPDATE_RUNNING \
98+
'expiration update is detected by subinstance scheduler' '
99+
id=$(flux alloc --bg -t5m -n2) &&
100+
exp1=$(subinstance_get_expiration $id) &&
101+
test_debug "echo instance expiration is $exp1" &&
102+
id1=$(flux proxy $id flux submit sleep 300) &&
103+
duration1=$(subinstance_get_job_duration $id $id1) &&
104+
test_debug "echo initial duration of subinstance job1 is $duration1" &&
105+
echo $duration1 | jq -e ". < 300" &&
106+
test_debug "echo updating duration of alloc job +5m" &&
107+
flux update $id duration=+5m &&
108+
test_debug "echo waiting for resource-update event" &&
109+
flux proxy $id flux kvs eventlog wait-event -vt 30 \
110+
resource.eventlog resource-update &&
111+
exp2=$(subinstance_get_expiration $id) &&
112+
test_debug "echo expiration updated from $exp1 to $exp2" &&
113+
echo $exp2 | jq -e ". == $exp1 + 300" &&
114+
id2=$(flux proxy $id flux submit sleep 300) &&
115+
duration2=$(subinstance_get_job_duration $id $id2) &&
116+
test_debug "echo duration of subinstance job2 is $duration2" &&
117+
echo $duration2 | jq -e ". > 300" &&
118+
flux proxy $id flux cancel --all &&
119+
flux shutdown --quiet $id
120+
'
62121
test_expect_success 'unload fluxion modules' '
63122
remove_qmanager &&
64-
remove_resource
123+
remove_resource &&
124+
flux module load sched-simple
65125
'
66126
test_done

0 commit comments

Comments
 (0)