From 612d85a560170deb34fd383eec17e7f9138d1c9a Mon Sep 17 00:00:00 2001 From: Jim Garlick Date: Mon, 29 Jan 2018 11:04:53 -0800 Subject: [PATCH] t/t0013-config-file.t: test config file bootstrap --- t/Makefile.am | 13 ++++- t/conf.d/bad-missing.conf | 3 + t/conf.d/bad-rank.conf | 10 ++++ t/conf.d/bad-toml.conf | 1 + t/conf.d/priv2.0.conf | 11 ++++ t/conf.d/priv2.1.conf | 11 ++++ t/conf.d/private.conf | 8 +++ t/conf.d/shared.conf | 5 ++ t/conf.d/shared_ipc.conf | 7 +++ t/conf.d/shared_none.conf | 5 ++ t/t0013-config-file.t | 118 ++++++++++++++++++++++++++++++++++++++ 11 files changed, 191 insertions(+), 1 deletion(-) create mode 100644 t/conf.d/bad-missing.conf create mode 100644 t/conf.d/bad-rank.conf create mode 100644 t/conf.d/bad-toml.conf create mode 100644 t/conf.d/priv2.0.conf create mode 100644 t/conf.d/priv2.1.conf create mode 100644 t/conf.d/private.conf create mode 100644 t/conf.d/shared.conf create mode 100644 t/conf.d/shared_ipc.conf create mode 100644 t/conf.d/shared_none.conf create mode 100755 t/t0013-config-file.t diff --git a/t/Makefile.am b/t/Makefile.am index b20116e2afd6..4df295adaef6 100644 --- a/t/Makefile.am +++ b/t/Makefile.am @@ -44,6 +44,7 @@ TESTS = \ t0010-generic-utils.t \ t0011-content-cache.t \ t0012-content-sqlite.t \ + t0013-config-file.t \ t0014-runlevel.t \ t0015-cron.t \ t0016-cron-faketime.t \ @@ -119,6 +120,7 @@ check_SCRIPTS = \ t0010-generic-utils.t \ t0011-content-cache.t \ t0012-content-sqlite.t \ + t0013-config-file.t \ t0014-runlevel.t \ t0015-cron.t \ t0016-cron-faketime.t \ @@ -206,7 +208,16 @@ dist_check_DATA = \ hwloc-data/1N/shared/02-brokers/1.xml \ hwloc-data/1N/nonoverlapping/02-brokers/0.xml \ hwloc-data/1N/nonoverlapping/02-brokers/1.xml \ - valgrind/valgrind.supp + valgrind/valgrind.supp \ + conf.d/private.conf \ + conf.d/shared.conf \ + conf.d/shared_ipc.conf \ + conf.d/shared_none.conf \ + conf.d/bad-toml.conf \ + conf.d/bad-missing.conf \ + conf.d/bad-rank.conf \ + conf.d/priv2.0.conf \ + conf.d/priv2.1.conf dist_check_SCRIPTS = \ scripts/event-trace.lua \ diff --git a/t/conf.d/bad-missing.conf b/t/conf.d/bad-missing.conf new file mode 100644 index 000000000000..51f150aec673 --- /dev/null +++ b/t/conf.d/bad-missing.conf @@ -0,0 +1,3 @@ +session-id = "test" + +# missing tbon-endpoints array diff --git a/t/conf.d/bad-rank.conf b/t/conf.d/bad-rank.conf new file mode 100644 index 000000000000..2f36d3fdbabf --- /dev/null +++ b/t/conf.d/bad-rank.conf @@ -0,0 +1,10 @@ +session-id = "test" + +size = 1 + +# rank is out of range +rank = -1 + +tbon-endpoints = [ + "ipc://@test", +] diff --git a/t/conf.d/bad-toml.conf b/t/conf.d/bad-toml.conf new file mode 100644 index 000000000000..82744c50da42 --- /dev/null +++ b/t/conf.d/bad-toml.conf @@ -0,0 +1 @@ +bad-toml diff --git a/t/conf.d/priv2.0.conf b/t/conf.d/priv2.0.conf new file mode 100644 index 000000000000..5835b40694e9 --- /dev/null +++ b/t/conf.d/priv2.0.conf @@ -0,0 +1,11 @@ +session-id = "test2" + +size = 2 +rank = 0 + +# The @ prefix says use the "abstract namespace" +# See unix(7), zmq_ipc(7) +tbon-endpoints = [ + "ipc://@flux-test-2-0", + "ipc://@flux-test-2-1", +] diff --git a/t/conf.d/priv2.1.conf b/t/conf.d/priv2.1.conf new file mode 100644 index 000000000000..04d1fe3f8345 --- /dev/null +++ b/t/conf.d/priv2.1.conf @@ -0,0 +1,11 @@ +session-id = "test2" + +size = 2 +rank = 1 + +# The @ prefix says use the "abstract namespace" +# See unix(7), zmq_ipc(7) +tbon-endpoints = [ + "ipc://@flux-test-2-0", + "ipc://@flux-test-2-1", +] diff --git a/t/conf.d/private.conf b/t/conf.d/private.conf new file mode 100644 index 000000000000..ea1176f5df37 --- /dev/null +++ b/t/conf.d/private.conf @@ -0,0 +1,8 @@ +session-id = "test" + +size = 1 +rank = 0 + +tbon-endpoints = [ + "ipc://@flux-test-1-0", +] diff --git a/t/conf.d/shared.conf b/t/conf.d/shared.conf new file mode 100644 index 000000000000..309240e689c1 --- /dev/null +++ b/t/conf.d/shared.conf @@ -0,0 +1,5 @@ +session-id = "test" + +tbon-endpoints = [ + "tcp://127.0.0.1:8500", +] diff --git a/t/conf.d/shared_ipc.conf b/t/conf.d/shared_ipc.conf new file mode 100644 index 000000000000..79d66266e429 --- /dev/null +++ b/t/conf.d/shared_ipc.conf @@ -0,0 +1,7 @@ +session-id = "testipc" + +mcast-endpoint = "tbon" + +tbon-endpoints = [ + "ipc://@flux-testipc-1-0", +] diff --git a/t/conf.d/shared_none.conf b/t/conf.d/shared_none.conf new file mode 100644 index 000000000000..ff7d0a198550 --- /dev/null +++ b/t/conf.d/shared_none.conf @@ -0,0 +1,5 @@ +session-id = "testoops" + +tbon-endpoints = [ + "tcp://1.2.3.4:5", +] diff --git a/t/t0013-config-file.t b/t/t0013-config-file.t new file mode 100755 index 000000000000..37172fa72bec --- /dev/null +++ b/t/t0013-config-file.t @@ -0,0 +1,118 @@ +#!/bin/sh +# + +test_description='Test config file overlay bootstrap' + +. `dirname $0`/sharness.sh + +TCONFDIR=${FLUX_SOURCE_DIR}/t/conf.d + +# Avoid loading unnecessary modules in back to back broker tests +export FLUX_RC1_PATH= +export FLUX_RC3_PATH= + +# +# check boot.method +# + +test_expect_success 'flux broker with explicit PMI boot method works' ' + flux broker -Sboot.method=pmi /bin/true +' + +test_expect_success 'flux broker with unknown boot method fails' ' + test_must_fail flux broker -Sboot.method=badmethod /bin/true +' + +# +# check boot.config_file +# + +test_expect_success 'flux broker without boot.config_file fails' ' + test_must_fail flux broker -Sboot.method=config /bin/true +' + +test_expect_success 'flux broker with boot.config_file=/badfile fails' ' + test_must_fail flux broker -Sboot.method=config \ + -Sboot.config_file=/badfile /bin/true +' + +test_expect_success 'flux broker with boot.config_file=bad-toml fails' ' + test_must_fail flux broker -Sboot.method=config \ + -Sboot.config_file=${TCONFDIR}/bad-toml.conf /bin/true +' + +test_expect_success 'flux broker with missing required items fails' ' + test_must_fail flux broker -Sboot.method=config \ + -Sboot.config_file=${TCONFDIR}/bad-missing.conf /bin/true +' + +test_expect_success 'flux broker with boot.config_file=bad-rank fails' ' + test_must_fail flux broker -Sboot.method=config \ + -Sboot.config_file=${TCONFDIR}/bad-rank.conf /bin/true +' + +# +# trigger config_file boot failure due to incompat attr setting +# + +test_expect_success 'flux broker with incompat attrs fails' ' + test_must_fail flux broker -Sboot.method=config \ + -Sboot.config_file=${TCONFDIR}/shared.conf \ + -Ssession-id=xyz \ + /bin/true +' + +# N.B. set short shutdown grace to speed up test, as in t0001-basic + +# +# size=1 boot from config file +# N.B. "private" config sets rank and optionally size, while "shared" +# config requires broker to infer rank from position of a local interface's +# IP address in the tbon-endpoints array (which only works for size=1 in +# a single-node test). +# + +test_expect_success 'start size=1 with shared config file, expected attrs set' ' + run_timeout 5 flux broker -Sboot.method=config \ + -Sboot.config_file=${TCONFDIR}/shared.conf \ + --shutdown-grace=0.1 \ + flux lsattr -v >1s.out && + grep -q "session-id[ ]*test$" 1s.out && + grep -q "tbon.endpoint[ ]*tcp://127.0.0.1:8500$" 1s.out && + grep -q "mcast.endpoint[ ]*tbon$" 1s.out +' + +test_expect_success 'start size=1 with shared config file, ipc endpoint' ' + run_timeout 5 flux broker -Sboot.method=config \ + -Sboot.config_file=${TCONFDIR}/shared_ipc.conf \ + --shutdown-grace=0.1 \ + /bin/true +' + +test_expect_success 'start size=1 with shared config file, no endpoint' ' + test_must_fail flux broker -Sboot.method=config \ + -Sboot.config_file=${TCONFDIR}/shared_none.conf \ + /bin/true +' + +test_expect_success 'start size=1 with private config file' ' + run_timeout 5 flux broker -Sboot.method=config \ + -Sboot.config_file=${TCONFDIR}/private.conf /bin/true +' + +# +# size=2 boot from config file +# + +test_expect_success NO_CHAIN_LINT 'start size=2 with private config files' ' + flux broker -Sboot.method=config \ + -Sboot.config_file=${TCONFDIR}/priv2.1.conf & + run_timeout 5 flux broker -Sboot.method=config \ + -Sboot.config_file=${TCONFDIR}/priv2.0.conf \ + --shutdown-grace=0.1 \ + flux getattr size >2p.out && + echo 2 >2p.exp && + test_cmp 2p.exp 2p.out +' + +test_done