isle/tests/utils/with-1-data-1-empty-node-cluster.sh

93 lines
2.2 KiB
Bash
Raw Normal View History

set -e
base="shared/1-data-1-empty"
2023-09-06 19:55:05 +00:00
primus_base="$base/primus"
2023-09-06 19:55:05 +00:00
primus_ip="10.6.9.1"
secondus_base="$base/secondus"
2023-09-06 19:55:05 +00:00
secondus_ip="10.6.9.2"
function as_primus {
2023-09-06 19:55:05 +00:00
current_ip="$primus_ip"
eval "$($SHELL "$UTILS/shared-daemon-env.sh" "$primus_base")"
}
function as_secondus {
2023-09-06 19:55:05 +00:00
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'
# environment
as_primus
secondus_bootstrap="$(pwd)/secondus-bootstrap.json"
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-primus
storage:
allocations:
- data_path: a/data
meta_path: a/meta
capacity: 1
- data_path: b/data
meta_path: b/meta
capacity: 1
- data_path: c/data
meta_path: c/meta
capacity: 1
EOF
echo "Creating 1-data-1-empty network"
isle admin create-network \
--config-path daemon.yml \
--domain shared.test \
--hostname primus \
2023-09-06 19:55:05 +00:00
--ip-net "$current_ip/24" \
--name "testing" \
> admin.json
isle daemon --config-path daemon.yml >daemon.log 2>&1 &
pid="$!"
echo "Waiting for primus daemon (process $pid) to initialize"
$SHELL "$UTILS/register-cleanup.sh" "$pid" "1-data-1-empty-node-cluster/primus"
while ! isle hosts list >/dev/null; do sleep 1; done
echo "Creating secondus bootstrap"
isle admin create-bootstrap \
--admin-path admin.json \
--hostname secondus \
2023-09-06 19:55:05 +00:00
--ip "$secondus_ip" \
> "$secondus_bootstrap"
(
as_secondus
cat >daemon.yml <<EOF
vpn:
tun:
device: isle-secondus
EOF
isle daemon -c daemon.yml -b "$secondus_bootstrap" >daemon.log 2>&1 &
pid="$!"
echo "Waiting for secondus daemon (process $!) to initialize"
$SHELL "$UTILS/register-cleanup.sh" "$pid" "1-data-1-empty-node-cluster/secondus"
while ! isle hosts list >/dev/null; do sleep 1; done
)
fi