Skip to content

Commit

Permalink
example/test: Allow creating arbitrary-sized clusters
Browse files Browse the repository at this point in the history
Signed-off-by: Wesley Hershberger <[email protected]>
  • Loading branch information
MggMuggins committed Jun 14, 2024
1 parent a809ad1 commit 539fcbc
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions example/test/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand All @@ -27,27 +27,35 @@ 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
echo "Pausing to inspect... press enter when done"
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

0 comments on commit 539fcbc

Please sign in to comment.