From 539fcbc4b937e8c622780472b73851b1f1024fc0 Mon Sep 17 00:00:00 2001 From: Wesley Hershberger Date: Thu, 13 Jun 2024 16:10:41 -0500 Subject: [PATCH] example/test: Allow creating arbitrary-sized clusters Signed-off-by: Wesley Hershberger --- example/test/main.sh | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/example/test/main.sh b/example/test/main.sh index a83015e4..7c55c0f0 100755 --- a/example/test/main.sh +++ b/example/test/main.sh @@ -18,7 +18,7 @@ if [ -d "${test_dir}" ]; then rm -r "${test_dir}" fi -members=("c1" "c2" "c3") +members=("c1" "c2" "c3" "c4" "c5") for member in "${members[@]}"; do state_dir="${test_dir}/${member}" @@ -27,20 +27,23 @@ for member in "${members[@]}"; do microctl --state-dir "${state_dir}" waitready done -# Ensure only valid member names are used +# Ensure only valid member names are used for bootstrap ! microctl --state-dir "${test_dir}/c1" init "c/1" 127.0.0.1:9001 --bootstrap microctl --state-dir "${test_dir}/c1" init "c1" 127.0.0.1:9001 --bootstrap -# Ensure only valid member names are used +# Ensure only valid member names are used for join token_node2=$(microctl --state-dir "${test_dir}/c1" tokens add "c/2") -! microctl --state-dir "${test_dir}/c1" init "c/2" 127.0.0.1:9003 --token "${token_node2}" +! microctl --state-dir "${test_dir}/c1" init "c/2" 127.0.0.1:9002 --token "${token_node2}" -token_node2=$(microctl --state-dir "${test_dir}/c1" tokens add "c2") -token_node3=$(microctl --state-dir "${test_dir}/c1" tokens add "c3") +indx=2 +for member in "${members[@]:1}"; do + token=$(microctl --state-dir "${test_dir}/c1" tokens add "${member}") -microctl --state-dir "${test_dir}/c2" init "c2" 127.0.0.1:9002 --token "${token_node2}" -microctl --state-dir "${test_dir}/c3" init "c3" 127.0.0.1:9003 --token "${token_node3}" + microctl --state-dir "${test_dir}/${member}" init "${member}" "127.0.0.1:900${indx}" --token "${token}" + + indx=$((indx + 1)) +done # Clean up if [ -n "${CLUSTER_INSPECT:-}" ]; then @@ -48,6 +51,11 @@ if [ -n "${CLUSTER_INSPECT:-}" ]; then read -r fi -kill %1 -kill %2 -kill %3 +for member in "${members[@]}"; do + microctl --state-dir "${test_dir}/${member}" shutdown +done + +kill 0 + +sleep 1 +