@@ -10,13 +10,17 @@ test -n "$FLUX_TESTS_LOGFILE" && set -- "$@" --logfile --debug
1010
1111test_expect_success ' initial program is run when rc1/rc3 are nullified' '
1212 flux start -o,-Slog-stderr-level=6 \
13- -o,-Sbroker.rc1_path=,-Sbroker.rc3_path= \
13+ -o,-Sbroker.rc1_path= \
14+ -o,-Sbroker.rc3_path= \
15+ -o,-Sbroker.shutdown_path= \
1416 /bin/true 2>normal.log
1517'
1618
1719test_expect_success ' rc1 failure causes instance failure' '
1820 test_expect_code 1 flux start \
19- -o,-Sbroker.rc1_path=/bin/false,-Sbroker.rc3_path= \
21+ -o,-Sbroker.rc1_path=/bin/false \
22+ -o,-Sbroker.rc3_path= \
23+ -o,-Sbroker.shutdown_path= \
2024 -o,-Slog-stderr-level=6 \
2125 sleep 3600 2>rc1_failure.log
2226'
@@ -25,7 +29,9 @@ test_expect_success 'rc1 bad path handled same as failure' '
2529 (
2630 SHELL=/bin/sh &&
2731 test_expect_code 127 flux start \
28- -o,-Sbroker.rc1_path=rc1-nonexist,-Sbroker.rc3_path= \
32+ -o,-Sbroker.rc1_path=rc1-nonexist \
33+ -o,-Sbroker.rc3_path= \
34+ -o,-Sbroker.shutdown_path= \
2935 -o,-Slog-stderr-level=6 \
3036 /bin/true 2>bad1.log
3137 )
@@ -35,15 +41,20 @@ test_expect_success 'default initial program is $SHELL' '
3541 run_timeout --env=SHELL=/bin/sh 60 \
3642 flux $SHARNESS_TEST_SRCDIR/scripts/runpty.py -i none \
3743 flux start -o,-Slog-stderr-level=6 \
38- -o,-Sbroker.rc1_path=,-Sbroker.rc3_path= \
44+ -o,-Sbroker.rc1_path= \
45+ -o,,-Sbroker.rc3_path= \
46+ -o,,-Sbroker.shutdown_path= \
3947 >shell.log &&
4048 grep "rc2.0: /bin/sh Exited" shell.log
4149'
4250
4351test_expect_success ' rc2 failure if stdin not a tty' '
4452 test_expect_code 1 \
45- flux start -o,-Slog-stderr-level=6 \
46- -o,-Sbroker.rc1_path=,-Sbroker.rc3_path= \
53+ flux start \
54+ -o,-Slog-stderr-level=6 \
55+ -o,-Sbroker.rc1_path= \
56+ -o,-Sbroker.rc3_path= \
57+ -o,-Sbroker.shutdown_path= \
4758 2>shell-notty.log &&
4859 grep "not a tty" shell-notty.log
4960'
@@ -59,67 +70,46 @@ test_expect_success 'broker.rc2_none terminates by signal without error' '
5970 for timeout in 0.5 1 2 4; do
6071 run_timeout -s ALRM $timeout flux start \
6172 -o,-Slog-stderr-level=6 \
62- -o,-Sbroker.rc1_path=,-Sbroker.rc3_path=,-Sbroker.rc2_none &&
73+ -o,-Sbroker.rc1_path= \
74+ -o,-Sbroker.rc3_path= \
75+ -o,-Sbroker.shutdown_path= \
76+ -o,-Sbroker.rc2_none &&
6377 break
6478 done
6579'
6680
67- test_expect_success ' flux admin cleanup-push /bin/true works' '
81+ test_expect_success ' shutdown= /bin/true works' '
6882 flux start -o,-Slog-stderr-level=6 \
69- -o,-Sbroker.rc1_path=,-Sbroker.rc3_path= \
70- flux admin cleanup-push /bin/true
71- '
72-
73- test_expect_success ' flux admin cleanup-push /bin/false causes instance failure' '
74- test_expect_code 1 flux start -o,-Slog-stderr-level=6 \
75- -o,-Sbroker.rc1_path=,-Sbroker.rc3_path= \
76- flux admin cleanup-push /bin/false
77- '
78-
79- test_expect_success ' cleanup does not run if rc1 fails' '
80- test_expect_code 1 flux start -o,-Slog-stderr-level=6 \
81- -o,-Sbroker.rc1_path=/bin/false,-Sbroker.rc3_path= \
82- flux admin cleanup-push memorable-string 2>nocleanup.err && \
83- test_must_fail grep memorable-string nocleanup.err
83+ -o,-Sbroker.rc1_path= \
84+ -o,-Sbroker.rc3_path= \
85+ -o,-Sbroker.shutdown_path=/bin/true \
86+ /bin/true
8487'
85-
86- test_expect_success ' flux admin cleanup-push (empty) fails' '
88+ test_expect_success ' shutdown=/bin/false causes instance failure' '
8789 test_expect_code 1 flux start \
88- -o,-Sbroker.rc1_path=,-Sbroker.rc3_path= \
89- flux admin cleanup-push "" 2>push.err &&
90- grep "cannot push an empty command line" push.err
90+ -o,-Slog-stderr-level=6 \
91+ -o,-Sbroker.rc1_path= \
92+ -o,-Sbroker.rc3_path= \
93+ -o,-Sbroker.shutdown_path=/bin/false \
94+ /bin/true
9195'
9296
93- test_expect_success ' flux admin cleanup-push with no commands fails' '
97+ test_expect_success ' shutdown does not run if rc1 fails' '
9498 test_expect_code 1 flux start \
95- -o,-Sbroker.rc1_path=,-Sbroker.rc3_path= \
96- flux admin cleanup-push </dev/null 2>push2.err &&
97- grep "commands array is empty" push2.err
98- '
99-
100- test_expect_success ' flux admin cleanup-push (stdin) works' '
101- echo /bin/true | flux start -o,-Slog-stderr-level=6 \
102- -o,-Sbroker.rc1_path=,-Sbroker.rc3_path= \
103- flux admin cleanup-push 2>push-stdin.err &&
104- grep cleanup.0 push-stdin.err
105- '
106-
107- test_expect_success ' flux admin cleanup-push (stdin) retains cmd block order' '
108- flux start -o,-Sbroker.rc1_path=,-Sbroker.rc3_path= \
10999 -o,-Slog-stderr-level=6 \
110- flux admin cleanup-push <<-EOT 2>hello.err &&
111- echo Hello world
112- echo Hello solar system
113- EOT
114- grep "cleanup.0: Hello world" hello.err &&
115- grep "cleanup.1: Hello solar system" hello.err
100+ -o,-Sbroker.rc1_path=/bin/false \
101+ -o,-Sbroker.rc3_path= \
102+ -o,-Sbroker.shutdown_path=memorable-string \
103+ /bin/true 2>nocleanup.err &&
104+ test_must_fail grep memorable-string nocleanup.err
116105'
117106
118- test_expect_success ' capture the environment for all three rc scripts' '
107+ test_expect_success ' capture the environment for all rc scripts' '
119108 SLURM_FOO=42 flux start \
120109 -o,-Slog-stderr-level=6 \
121110 -o,-Sbroker.rc1_path="bash -c printenv >rc1.env" \
122111 -o,-Sbroker.rc3_path="bash -c printenv >rc3.env" \
112+ -o,-Sbroker.shutdown_path="bash -c printenv >shutdown.env" \
123113 "bash -c printenv >rc2.env"
124114'
125115
@@ -166,6 +156,7 @@ test_expect_success 'capture the environment for instance run as a job' '
166156 -o,-Slog-stderr-level=6 \
167157 -o,-Sbroker.rc1_path="bash -c printenv >rc1.env2" \
168158 -o,-Sbroker.rc3_path="bash -c printenv >rc3.env2" \
159+ -o,-Sbroker.shutdown_path="bash -c printenv >shutdown.env2" \
169160 "bash -c printenv >rc2.env2"
170161'
171162
0 commit comments