-
Notifications
You must be signed in to change notification settings - Fork 49
/
t0001-basic.t
executable file
·300 lines (287 loc) · 10.5 KB
/
t0001-basic.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
#!/bin/sh
#
test_description='Test the very basics
Ensure the very basics of flux commands work.
This suite verifies functionality that may be assumed working by
other tests.
'
# Append --logfile option if FLUX_TESTS_LOGFILE is set in environment:
test -n "$FLUX_TESTS_LOGFILE" && set -- "$@" --logfile
. `dirname $0`/sharness.sh
test_expect_success 'TEST_NAME is set' '
test -n "$TEST_NAME"
'
test_expect_success 'run_timeout works' '
test_expect_code 142 run_timeout 1 sleep 2
'
test_expect_success 'test run_timeout with success' '
run_timeout 1 /bin/true
'
test_expect_success 'we can find a flux binary' '
flux --help >/dev/null
'
test_expect_success 'flux-keygen works' '
umask 077 && tmpkeydir=`mktemp -d` &&
flux keygen --secdir $tmpkeydir --force &&
rm -rf $tmpkeydir
'
#
# N.B. since we have many back to back flux-starts within this test,
# and each instance runs out the shutdown grace period per issue #1006,
# the net effect is a really slow test.
#
# Until #1006 is fixed, work around this by forcing an unnaturally
# short shutdown grace period. It means we're interrupting the tear
# down process, but perhaps that's not so much relevant to verifying
# basic functionality...
#
BUG1006="-o,--shutdown-grace=0.1"
test_expect_success 'broker --shutdown-grace option works' '
flux start -o,--shutdown-grace=0.1 /bin/true
'
test_expect_success 'flux-start in exec mode works' "
flux start ${BUG1006} 'flux comms info' | grep 'size=1'
"
test_expect_success 'flux-start in subprocess/pmi mode works (size 1)' "
flux start ${BUG1006} --size=1 'flux comms info' | grep 'size=1'
"
test_expect_success 'flux-start in subprocess/pmi mode works (size 2)' "
flux start ${BUG1006} --size=2 'flux comms info' | grep 'size=2'
"
test_expect_success 'flux-start with size 1 has no peers' "
flux start ${BUG1006} --size=1 'flux comms idle' > idle.out
! grep 'idle' idle.out
"
test_expect_success 'flux-start with size 2 has a peer' "
flux start ${BUG1006} --size=2 'flux comms idle' > idle.out
grep 'idle' idle.out
"
test_expect_success 'flux-start --size=1 --bootstrap=selfpmi works' "
flux start ${BUG1006} --size=1 --bootstrap=selfpmi /bin/true
"
test_expect_success 'flux-start --size=1 --boostrap=pmi fails' "
test_must_fail flux start ${BUG1006} --size=1 --bootstrap=pmi /bin/true
"
test_expect_success 'flux-start in exec mode passes through errors from command' "
test_must_fail flux start ${BUG1006} /bin/false
"
test_expect_success 'flux-start in subprocess/pmi mode passes through errors from command' "
test_must_fail flux start ${BUG1006} --size=1 /bin/false
"
test_expect_success 'flux-start in exec mode passes exit code due to signal' "
test_expect_code 130 flux start ${BUG1006} 'kill -INT \$\$'
"
test_expect_success 'flux-start in subprocess/pmi mode passes exit code due to signal' "
test_expect_code 130 flux start ${BUG1006} --size=1 'kill -INT \$\$'
"
test_expect_success 'flux-start in exec mode works as initial program' "
flux start --size=2 flux start ${BUG1006} flux comms info | grep size=1
"
test_expect_success 'flux-start in subprocess/pmi mode works as initial program' "
flux start --size=2 flux start ${BUG1006} --size=1 flux comms info | grep size=1
"
test_expect_success 'test_under_flux works' '
echo >&2 "$(pwd)" &&
mkdir -p test-under-flux && (
cd test-under-flux &&
cat >.test.t <<-EOF &&
#!/bin/sh
pwd
test_description="test_under_flux (in sub sharness)"
. "\$SHARNESS_TEST_SRCDIR"/sharness.sh
test_under_flux 2
test_expect_success "flux comms info" "
flux comms info
"
test_done
EOF
chmod +x .test.t &&
SHARNESS_TEST_DIRECTORY=`pwd` &&
export SHARNESS_TEST_SRCDIR SHARNESS_TEST_DIRECTORY FLUX_BUILD_DIR debug &&
./.test.t --verbose --debug >out 2>err
) &&
grep "size=2" test-under-flux/out
'
test_expect_success 'flux-start -o,--setattr ATTR=VAL can set broker attributes' '
ATTR_VAL=`flux start ${BUG1006} -o,--setattr=foo-test=42 flux getattr foo-test` &&
test $ATTR_VAL -eq 42
'
test_expect_success 'tbon.endpoint can be read' '
ATTR_VAL=`flux start flux getattr tbon.endpoint` &&
echo $ATTR_VAL | grep "^tcp"
'
test_expect_success 'tbon.endpoint can be set and %h works' '
ATTR_VAL=`flux start -o,--setattr=tbon.endpoint='tcp://%h:*' flux getattr tbon.endpoint` &&
echo $ATTR_VAL | grep "^tcp"
'
test_expect_success 'tbon.endpoint with %B works' '
ATTR_VAL=`flux start -o,--setattr=tbon.endpoint='ipc://%B/req' flux getattr tbon.endpoint` &&
echo $ATTR_VAL | grep "^ipc"
'
test_expect_success 'tbon.endpoint fails on bad endpoint' '
! flux start -o,--setattr=tbon.endpoint='foo://bar' flux getattr tbon.endpoint
'
test_expect_success 'mcast.endpoint can be read' '
ATTR_VAL=`flux start flux getattr mcast.endpoint` &&
echo $ATTR_VAL | grep "^tbon$"
'
test_expect_success 'mcast.endpoint works with ipc endpoints' '
flux start -o,--setattr=tbon.endpoint='ipc://%B/req' -o,--setattr=mcast.endpoint='ipc://%B/event' flux getattr mcast.endpoint
'
test_expect_success 'mcast.endpoint fails on bad endpoint' '
! flux start -o,--setattr=mcast.endpoint='foo://bar' flux getattr mcast.endpoint
'
test_expect_success 'broker.rundir override works' '
RUNDIR=`mktemp -d` &&
DIR=`flux start ${BUG1006} -o,--setattr=broker.rundir=$RUNDIR flux getattr broker.rundir` &&
test "$DIR" = "$RUNDIR" &&
test -d $RUNDIR &&
rmdir $RUNDIR
'
test_expect_success 'broker persist-directory works' '
PERSISTDIR=`mktemp -d` &&
flux start ${BUG1006} -o,--setattr=persist-directory=$PERSISTDIR /bin/true &&
test -d $PERSISTDIR &&
test `ls -1 $PERSISTDIR|wc -l` -gt 0 &&
rm -rf $PERSISTDIR
'
test_expect_success 'broker persist-filesystem works' '
PERSISTFS=`mktemp -d` &&
PERSISTDIR=`flux start ${BUG1006} -o,--setattr=persist-filesystem=$PERSISTFS flux getattr persist-directory` &&
test -d $PERSISTDIR &&
test `ls -1 $PERSISTDIR|wc -l` -gt 0 &&
rm -rf $PERSISTDIR &&
test -d $PERSISTFS &&
rmdir $PERSISTFS
'
test_expect_success 'broker persist-filesystem is ignored if persist-directory set' '
PERSISTFS=`mktemp -d` &&
PERSISTDIR=`mktemp -d` &&
DIR=`flux start ${BUG1006} -o,--setattr=persist-filesystem=$PERSISTFS,--setattr=persist-directory=$PERSISTDIR \
flux getattr persist-directory` &&
test "$DIR" = "$PERSISTDIR" &&
test `ls -1 $PERSISTDIR|wc -l` -gt 0 &&
rmdir $PERSISTFS &&
rm -rf $PERSISTDIR
'
# Use -eq hack to test that BROKERPID is a number
test_expect_success 'broker broker.pid attribute is readable' '
BROKERPID=`flux start ${BUG1006} flux getattr broker.pid` &&
test -n "$BROKERPID" &&
test "$BROKERPID" -eq "$BROKERPID"
'
test_expect_success 'broker broker.pid attribute is immutable' '
test_must_fail flux start ${BUG1006} -o,--setattr=broker.pid=1234 flux getattr broker.pid
'
test_expect_success 'broker --verbose option works' '
flux start ${BUG1006} -o,-v /bin/true
'
test_expect_success 'broker --heartrate option works' '
flux start ${BUG1006} -o,--heartrate=0.1 /bin/true
'
test_expect_success 'broker --k-ary option works' '
flux start ${BUG1006} -s4 -o,--k-ary=1 /bin/true &&
flux start ${BUG1006} -s4 -o,--k-ary=2 /bin/true &&
flux start ${BUG1006} -s4 -o,--k-ary=3 /bin/true &&
flux start ${BUG1006} -s4 -o,--k-ary=4 /bin/true
'
test_expect_success 'flux-help command list can be extended' '
mkdir help.d &&
cat <<-EOF > help.d/test.json &&
[{ "category": "test", "command": "test", "description": "a test" }]
EOF
flux help 2>&1 | sed "0,/^$/d" >help.expected &&
cat <<-EOF >>help.expected &&
Common commands from flux-test:
test a test
EOF
FLUX_CMDHELP_PATTERN="help.d/*" flux help 2>&1 | sed "0,/^$/d" > help.out &&
test_cmp help.expected help.out &&
cat <<-EOF > help.d/test2.json &&
[{ "category": "test2", "command": "test2", "description": "a test two" }]
EOF
cat <<-EOF >>help.expected &&
Common commands from flux-test2:
test2 a test two
EOF
FLUX_CMDHELP_PATTERN="help.d/*" flux help 2>&1 | sed "0,/^$/d" > help.out &&
test_cmp help.expected help.out
'
test_expect_success 'flux-help command can display manpages for subcommands' '
PWD=$(pwd) &&
mkdir -p man/man1 &&
cat <<-EOF > man/man1/flux-foo.1 &&
.TH FOO "1" "January 1962" "Foo utils" "User Commands"
.SH NAME
foo \- foo bar baz
EOF
MANPATH=${PWD}/man FLUX_IGNORE_NO_DOCS=y flux help foo | grep "^FOO(1)"
'
test_expect_success 'flux-help command can display manpages for api calls' '
PWD=$(pwd) &&
mkdir -p man/man3 &&
cat <<-EOF > man/man3/flux_foo.3 &&
.TH FOO "3" "January 1962" "Foo api call" "Flux Programming Interface"
.SH NAME
flux_foo \- Call the flux_foo interface
EOF
MANPATH=${PWD}/man FLUX_IGNORE_NO_DOCS=y flux help flux_foo | grep "^FOO(3)"
'
test_expect_success 'flux-help returns nonzero exit code from man(1)' '
man notacommand >/dev/null 2>&1
code=$?
test_expect_code $code eval FLUX_IGNORE_NO_DOCS=y flux help notacommand
'
test_expect_success 'flux appends colon to missing or unset MANPATH' '
(unset MANPATH && flux /usr/bin/printenv | grep "MANPATH=.*:$") &&
MANPATH= flux /usr/bin/printenv | grep "MANPATH=.*:$"
'
test_expect_success 'builtin test_size_large () works' '
size=$(test_size_large) &&
test -n "$size" &&
size=$(FLUX_TEST_SIZE_MAX=2 test_size_large) &&
test "$size" = "2" &&
size=$(FLUX_TEST_SIZE_MIN=123 FLUX_TEST_SIZE_MAX=1000 test_size_large) &&
test "$size" = "123"
'
waitfile=${SHARNESS_TEST_SRCDIR}/scripts/waitfile.lua
test_expect_success 'scripts/waitfile works' '
flux start $waitfile -v -t 5 -p "hello" waitfile.test.1 &
p=$! &&
echo "hello" > waitfile.test.1 &&
wait $p
'
test_expect_success 'scripts/waitfile works after <1s' '
flux start $waitfile -v -t 2 -p "hello" -P- waitfile.test.2 <<-EOF &
-- open file at 250ms, write pattern at 500ms
f:timer{ timeout = 250,
handler = function () tf = io.open ("waitfile.test.2", "w") end
}
f:timer{ timeout = 500,
handler = function () tf:write ("hello\n"); tf:flush() end
}
EOF
p=$! &&
wait $p
'
test_expect_success 'scripts/waitfile works after 1s' '
flux start $waitfile -v -t 5 -p "hello" -P- waitfile.test.3 <<-EOF &
-- Wait 250ms and create file, at .5s write a line, at 1.1s write pattern:
f:timer{ timeout = 250,
handler = function () tf = io.open ("waitfile.test.3", "w") end
}
f:timer{ timeout = 500,
handler = function () tf:write ("line one"); tf:flush() end
}
f:timer{ timeout = 1100,
handler = function () tf:write ("hello\n"); tf:flush() end
}
EOF
p=$! &&
wait $p
'
# test for issue #1025
test_expect_success 'instance can stop cleanly with subscribers (#1025)' '
flux start ${BUG1006} -s2 --bootstrap=selfpmi bash -c "nohup flux event sub hb &"
'
test_done