Add create-bootstrap test case

This commit is contained in:
Brian Picciano 2023-09-04 20:56:48 +02:00
parent 0a482607d5
commit 98e5f4c98c
4 changed files with 95 additions and 3 deletions

View File

@ -0,0 +1,20 @@
# shellcheck source=../utils/with-single-node-cluster.sh
source "$UTILS"/with-single-node-cluster.sh
adminBS="$XDG_DATA_HOME"/isle/bootstrap.yml
bs=create-bootstrap-out.yml
isle admin create-bootstrap \
--admin-path admin.yml \
--hostname secondus \
--ip 10.6.9.2 \
> "$bs"
[ "$(yq <"$bs" '.admin_creation_params')" = "$(yq <admin.yml '.creation_params')" ]
[ "$(yq <"$bs" '.hostname')" = "secondus" ]
[ "$(yq <"$bs" '.hosts.primus.nebula.signed_public_credentials')" \
= "$(yq <"$adminBS" '.nebula.signed_public_credentials')" ]
[ "$(yq <"$bs" '.hosts.primus.garage.instances|length')" = "3" ]

View File

@ -59,7 +59,7 @@ done
echo -e "number of tests: $(echo "$test_files" | wc -l)\n" echo -e "number of tests: $(echo "$test_files" | wc -l)\n"
for file in $test_files; do for file in $test_files; do
echo "$file" echo "Running test case: $file"
[ -z "$VERBOSE" ] && output="$TMPDIR/$file.log" || output=/dev/stdout [ -z "$VERBOSE" ] && output="$TMPDIR/$file.log" || output=/dev/stdout
@ -76,7 +76,17 @@ for file in $test_files; do
fi fi
exit 1 exit 1
fi fi
) ) || TESTS_FAILED=1
if [ -n "$TESTS_FAILED" ]; then break; fi
done done
echo -e '\nall tests succeeded!'
# Clean up any shared running clusters. Each cleanup script is responsible for
# figuring out if its shared cluster was actually instantiated during any tests.
echo "Running any cleanup tasks"
# shellcheck source=./utils/cleanup-single-node-cluster.sh
source "$UTILS"/cleanup-single-node-cluster.sh
if [ -z "$TESTS_FAILED" ]; then echo -e '\nall tests succeeded!'; fi

View File

@ -0,0 +1,14 @@
(
set -e
TMPDIR="$TMPDIR/shared/single-node.tmp"
if [ ! -d "$TMPDIR" ]; then exit 0; fi
lock_file="$TMPDIR/.run/isle/lock"
if [ ! -e "$lock_file" ]; then exit 0; fi
pid="$(cat "$lock_file")"
echo "killing shared single node cluster (process: $pid)"
kill "$pid"
while [ -e "$TMPDIR/.run/isle" ]; do sleep 1; done
)

View File

@ -0,0 +1,48 @@
set -e
TMPDIR="$TMPDIR/shared/single-node.tmp"
XDG_RUNTIME_DIR="$TMPDIR/.run"
XDG_DATA_HOME="$TMPDIR/.data"
mkdir -p "$TMPDIR" "$XDG_RUNTIME_DIR" "$XDG_DATA_HOME"
cd "$TMPDIR"
if [ ! -d "$XDG_RUNTIME_DIR/isle" ]; then
echo "Initializing shared single node cluster"
mkdir a
mkdir b
mkdir c
cat >daemon.yml <<EOF
vpn:
public_addr: 127.0.0.1:60000
tun:
device: isle-test-shared
storage:
allocations:
- data_path: a/data
meta_path: a/meta
capacity: 100
- data_path: b/data
meta_path: b/meta
capacity: 100
- data_path: c/data
meta_path: c/meta
capacity: 100
EOF
isle admin create-network \
--config-path daemon.yml \
--domain shared.test \
--hostname primus \
--ip-net "10.6.9.1/24" \
--name "testing" \
> admin.yml
isle daemon --config-path daemon.yml >daemon.log 2>&1 &
echo "Waiting for daemon (process $!) to initialize"
while ! isle hosts list >/dev/null; do sleep 1; done
fi