test: add remote runner vagrant scenario
This commit is contained in:
Executable
+55
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
controller_ip="${UPTIMELINK_VAGRANT_CONTROLLER_IP:-192.168.56.10}"
|
||||
controller_port="${UPTIMELINK_VAGRANT_CONTROLLER_PORT:-8080}"
|
||||
provider="${UPTIMELINK_VAGRANT_PROVIDER:-libvirt}"
|
||||
runner_id="${UPTIMELINK_VAGRANT_RUNNER_ID:-vagrant-runner-1}"
|
||||
runner_token="${UPTIMELINK_VAGRANT_RUNNER_TOKEN:-vagrant-token}"
|
||||
target_port="${UPTIMELINK_VAGRANT_TARGET_PORT:-18081}"
|
||||
|
||||
if ! command -v vagrant >/dev/null 2>&1; then
|
||||
echo 'Vagrant is required for scenario:uptimerunner-vagrant.' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "${provider}" in
|
||||
libvirt)
|
||||
if [[ "$(vagrant plugin list)" != *'vagrant-libvirt'* ]]; then
|
||||
echo 'The vagrant-libvirt plugin is required for UPTIMELINK_VAGRANT_PROVIDER=libvirt.' >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ -S /var/run/libvirt/libvirt-sock ] && [ ! -w /var/run/libvirt/libvirt-sock ]; then
|
||||
echo 'Cannot access /var/run/libvirt/libvirt-sock.' >&2
|
||||
if getent group libvirt | grep -q "$(id -un)"; then
|
||||
echo 'The current user is listed in libvirt, but this shell session has not picked up that group.' >&2
|
||||
echo "Retry without restarting using: sg libvirt -c 'pnpm scenario:uptimerunner-vagrant'" >&2
|
||||
else
|
||||
echo 'Add the current user to the libvirt group and start a new login session, or use another provider.' >&2
|
||||
echo 'Example: sudo usermod -aG libvirt "$USER"' >&2
|
||||
fi
|
||||
echo 'Alternative: UPTIMELINK_VAGRANT_PROVIDER=virtualbox pnpm scenario:uptimerunner-vagrant' >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
virtualbox)
|
||||
if ! command -v VBoxManage >/dev/null 2>&1; then
|
||||
echo 'VirtualBox is required for UPTIMELINK_VAGRANT_PROVIDER=virtualbox.' >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
cleanup() {
|
||||
vagrant ssh runner -c 'sudo systemctl stop uptimerunner.service >/dev/null 2>&1 || true' >/dev/null 2>&1 || true
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
vagrant up --provider="${provider}" --no-provision controller runner
|
||||
vagrant rsync
|
||||
vagrant provision controller
|
||||
vagrant provision runner
|
||||
|
||||
vagrant ssh controller -c "cd /uptime.link/testing && UPTIMELINK_CONTROLLER_HOST=0.0.0.0 UPTIMELINK_CONTROLLER_PORT=${controller_port} UPTIMELINK_RUNNER_ID=${runner_id} UPTIMELINK_RUNNER_TOKEN=${runner_token} UPTIMELINK_TARGET_PORT=${target_port} UPTIMELINK_CONTROLLER_URL=http://${controller_ip}:${controller_port} deno run --allow-all --sloppy-imports --config /uptime.link/uptimerunner/deno.json scenarios/uptimerunner-vagrant/controller.ts"
|
||||
Reference in New Issue
Block a user