Skip to content

Commit ab783b1

Browse files
committed
testsuite: cover upstream peer warning
Problem: there is no test coverage demonstrating that the broker prints a warning if the configured upstream URI cannot be resolved. Add a test to t0013-config-file.t.
1 parent 6ec1d3a commit ab783b1

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

t/t0013-config-file.t

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/bin/sh
22
#
33

4+
# Append --logfile option if FLUX_TESTS_LOGFILE is set in environment:
5+
test -n "$FLUX_TESTS_LOGFILE" && set -- "$@" --logfile
6+
47
test_description='Test config file overlay bootstrap'
58

69
. `dirname $0`/sharness.sh
@@ -260,6 +263,43 @@ test_expect_success 'start size=3 instance with ipc:// and custom topology' '
260263
test_cmp conf8a.exp conf8a.out
261264
'
262265

266+
waitgrep() {
267+
local pattern=$1
268+
local file=$2
269+
local iter=$3
270+
while test $iter -gt 0; do
271+
grep "$pattern" $file 2>/dev/null && return 0
272+
sleep 0.3
273+
iter=$(($iter-1))
274+
done
275+
return 1
276+
}
277+
278+
# RFC 2606 reserves the .invalid domain for testing
279+
test_expect_success NO_CHAIN_LINT 'a warning is printed when upstream URI has unknown host' '
280+
mkdir conf8b &&
281+
cat <<-EOT >conf8b/bootstrap.toml &&
282+
[bootstrap]
283+
curve_cert = "testcert"
284+
[[bootstrap.hosts]]
285+
host = "fake0"
286+
connect = "tcp://foo.invalid:1234"
287+
[[bootstrap.hosts]]
288+
host = "fake1"
289+
EOT
290+
FLUX_FAKE_HOSTNAME=fake1 \
291+
flux broker -vv -Sbroker.rc1_path=,-Sbroker.rc3_path= \
292+
--config-path=conf8b 2>warn.err &
293+
echo $! >warn.pid &&
294+
waitgrep "unable to resolve upstream peer" warn.err 30
295+
'
296+
# In case warn.pid actually refers to a libtool wrapper, try pkill(1) -P
297+
# first to kill its children, then kill(1). See flux-framework/flux-core#5275.
298+
test_expect_success NO_CHAIN_LINT 'clean up broker from previous test' '
299+
warnpid=$(cat warn.pid) &&
300+
pkill -15 -P $warnpid || kill -15 $warnpid
301+
'
302+
263303
getport() {
264304
flux python -c \
265305
'from socket import socket; s=socket(); s.bind(("", 0)); print(s.getsockname()[1])'

0 commit comments

Comments
 (0)