Compare commits

...

2 Commits

Author SHA1 Message Date
Brian Picciano
5ee80b1b7d Add tests for DNS 2023-09-06 21:55:05 +02:00
Brian Picciano
96a3ecfe14 Perform garage tests on each of the running nodes 2023-09-06 21:06:03 +02:00
8 changed files with 78 additions and 20 deletions

View File

@ -170,6 +170,7 @@ in rec {
pkgs.busybox pkgs.busybox
pkgs.yq-go pkgs.yq-go
pkgs.jq pkgs.jq
pkgs.dig
]} ]}
export SHELL=${pkgs.bash}/bin/bash export SHELL=${pkgs.bash}/bin/bash
exec ${pkgs.bash}/bin/bash ${./tests}/entrypoint.sh "$@" exec ${pkgs.bash}/bin/bash ${./tests}/entrypoint.sh "$@"

View File

@ -8,8 +8,9 @@ this_user="$(whoami)"
echo "Requesting sudo in order to set thread capabilities, will drop back down to user '$this_user' immediately" echo "Requesting sudo in order to set thread capabilities, will drop back down to user '$this_user' immediately"
sudo -E capsh \ sudo -E capsh \
--caps="cap_net_admin+eip cap_setpcap,cap_setuid,cap_setgid+ep" \ --caps="cap_net_admin,cap_net_bind_service+eip cap_setpcap,cap_setuid,cap_setgid+ep" \
--keep=1 \ --keep=1 \
--user="$this_user" \ --user="$this_user" \
--addamb=cap_net_admin \ --addamb=cap_net_admin \
--addamb=cap_net_bind_service \
-- "$entrypoint" "$@" -- "$entrypoint" "$@"

3
tests/NOTES.txt Normal file
View File

@ -0,0 +1,3 @@
Ctrl+A X -> exits
qemu-system-aarch64 -M virt -nographic -cdrom tests/alpine-virt-3.17.3-aarch64.iso

View File

@ -0,0 +1,20 @@
# shellcheck source=../../utils/with-1-data-1-empty-node-cluster.sh
source "$UTILS"/with-1-data-1-empty-node-cluster.sh
function assert_a {
want_ip="$1"
hostname="$2"
r="$(dig @"$current_ip" +noall +answer "$hostname")"
echo "$r" | grep -q "$want_ip"
}
as_primus
assert_a "$primus_ip" primus.hosts.shared.test
# TODO This doesn't work at present, there would need to be some mechanism to
# block the test until secondus' bootstrap info can propagate to primus.
#assert_a "$secondus_ip" secondus.hosts.shared.test
as_secondus
assert_a "$primus_ip" primus.hosts.shared.test
assert_a "$secondus_ip" secondus.hosts.shared.test

View File

@ -1,13 +1,21 @@
# shellcheck source=../../utils/with-1-data-1-empty-node-cluster.sh # shellcheck source=../../utils/with-1-data-1-empty-node-cluster.sh
source "$UTILS"/with-1-data-1-empty-node-cluster.sh source "$UTILS"/with-1-data-1-empty-node-cluster.sh
status="$(isle garage cli status | tail -n+3)" function do_tests {
status="$(isle garage cli status | tail -n+3)"
[ "$(echo "$status" | wc -l)" = "3" ] [ "$(echo "$status" | wc -l)" = "3" ]
echo "$status" | grep -q '10.6.9.1:3900' echo "$status" | grep -q '10.6.9.1:3900'
echo "$status" | grep -q '10.6.9.1:3910' echo "$status" | grep -q '10.6.9.1:3910'
echo "$status" | grep -q '10.6.9.1:3920' echo "$status" | grep -q '10.6.9.1:3920'
buckets="$(isle garage cli bucket list | tail -n+2)" buckets="$(isle garage cli bucket list | tail -n+2)"
[ "$(echo "$buckets" | wc -l)" = 1 ] [ "$(echo "$buckets" | wc -l)" = 1 ]
echo "$buckets" | grep -q 'global-shared' echo "$buckets" | grep -q 'global-shared'
}
as_primus
do_tests
as_secondus
do_tests

View File

@ -1,8 +1,16 @@
# shellcheck source=../../utils/with-1-data-1-empty-node-cluster.sh # shellcheck source=../../utils/with-1-data-1-empty-node-cluster.sh
source "$UTILS"/with-1-data-1-empty-node-cluster.sh source "$UTILS"/with-1-data-1-empty-node-cluster.sh
files="$(isle garage mc -- tree --json garage)" function do_tests {
[ "$(echo "$files" | jq -s '.|length')" -ge "1" ] files="$(isle garage mc -- tree --json garage)"
[ "$(echo "$files" | jq -s '.|length')" -ge "1" ]
file="$(echo "$files" | jq -sr '.[0].key')" file="$(echo "$files" | jq -sr '.[0].key')"
[ "$(isle garage mc -- cat "garage/$file" | wc -c)" -gt "0" ] [ "$(isle garage mc -- cat "garage/$file" | wc -c)" -gt "0" ]
}
as_primus
do_tests
as_secondus
do_tests

View File

@ -8,4 +8,9 @@ XDG_DATA_HOME="$TMPDIR/.data"
mkdir -p "$TMPDIR" "$XDG_RUNTIME_DIR" "$XDG_DATA_HOME" mkdir -p "$TMPDIR" "$XDG_RUNTIME_DIR" "$XDG_DATA_HOME"
echo "export TMPDIR='$TMPDIR' XDG_RUNTIME_DIR='$XDG_RUNTIME_DIR' XDG_DATA_HOME='$XDG_DATA_HOME'" cat <<EOF
export TMPDIR="$TMPDIR"
export XDG_RUNTIME_DIR="$XDG_RUNTIME_DIR"
export XDG_DATA_HOME="$XDG_DATA_HOME"
cd "$TMPDIR"
EOF

View File

@ -1,13 +1,26 @@
set -e set -e
base="shared/1-data-1-empty" base="shared/1-data-1-empty"
primus_base="$base/primus" primus_base="$base/primus"
primus_ip="10.6.9.1"
secondus_base="$base/secondus" secondus_base="$base/secondus"
secondus_ip="10.6.9.2"
function as_primus {
current_ip="$primus_ip"
eval "$($SHELL "$UTILS/shared-daemon-env.sh" "$primus_base")"
}
function as_secondus {
current_ip="$secondus_ip"
eval "$($SHELL "$UTILS/shared-daemon-env.sh" "$secondus_base")"
}
# Even if it's already intialized, we want to put the caller in primus' # Even if it's already intialized, we want to put the caller in primus'
# environment # environment
eval "$($SHELL "$UTILS/shared-daemon-env.sh" "$primus_base")" as_primus
cd "$TMPDIR"
secondus_bootstrap="$(pwd)/secondus-bootstrap.yml" secondus_bootstrap="$(pwd)/secondus-bootstrap.yml"
@ -41,7 +54,7 @@ EOF
--config-path daemon.yml \ --config-path daemon.yml \
--domain shared.test \ --domain shared.test \
--hostname primus \ --hostname primus \
--ip-net "10.6.9.1/24" \ --ip-net "$current_ip/24" \
--name "testing" \ --name "testing" \
> admin.yml > admin.yml
@ -57,12 +70,11 @@ EOF
isle admin create-bootstrap \ isle admin create-bootstrap \
--admin-path admin.yml \ --admin-path admin.yml \
--hostname secondus \ --hostname secondus \
--ip 10.6.9.2 \ --ip "$secondus_ip" \
> "$secondus_bootstrap" > "$secondus_bootstrap"
( (
eval "$($SHELL "$UTILS/shared-daemon-env.sh" "$secondus_base")" as_secondus
cd "$TMPDIR"
cat >daemon.yml <<EOF cat >daemon.yml <<EOF
vpn: vpn: