forked from canonical/microcluster
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
example: Add system tests for microd/microctl
Signed-off-by: Wesley Hershberger <[email protected]>
- Loading branch information
1 parent
05982b6
commit c4cf5dc
Showing
4 changed files
with
45 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Misc test files | ||
example/test/system |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
# Environment variables | ||
Name | Default | Description | ||
:-- | :-- | :-- | ||
`DEBUG` | "" | Sets `set -x` | ||
`CLUSTER_INSPECT` | "" | Any `microd` processes are not killed when `main.sh` exits |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/bash | ||
|
||
if [ -n "${DEBUG:-}" ]; then | ||
set -x | ||
fi | ||
|
||
test_dir="$(realpath -e "$(dirname -- "${BASH_SOURCE[0]}")")/system" | ||
|
||
if [ -d "${test_dir}" ]; then | ||
rm -r "${test_dir}" | ||
fi | ||
|
||
members=("c1" "c2" "c3") | ||
|
||
for member in "${members[@]}"; do | ||
state_dir="${test_dir}/${member}" | ||
mkdir -p "${state_dir}" | ||
microd --state-dir "${state_dir}" & | ||
microctl --state-dir "${state_dir}" waitready | ||
done | ||
|
||
microctl --state-dir "${test_dir}/c1" init "c1" 127.0.0.1:9001 --bootstrap | ||
|
||
token_node2=$(microctl --state-dir "${test_dir}/c1" tokens add "c2") | ||
token_node3=$(microctl --state-dir "${test_dir}/c1" tokens add "c3") | ||
|
||
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}" | ||
|
||
# Clean up | ||
if [ -z "${CLUSTER_INSPECT:-}" ]; then | ||
kill %1 | ||
kill %2 | ||
kill %3 | ||
fi |