Menu
Public repository / 4fe4eb7c1983febeca1ce0b127f5eed7640d5be0
AkurAI-EC2 / tests/test_release_retired.sh
Latest change 4fe4eb7c1983febeca1ce0b127f5eed7640d5be0 - release: refuse manifests marked retired = "<reason>" by Ólafur Búi Ólafsson
#!/usr/bin/env bash
# A manifest with `retired = "<reason>"` must make every release mode refuse before any gate or
# network call, and say why.
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
TMP="$(mktemp -d)"
trap 'rm -rf "$TMP"' EXIT
# Never reach a real host, even when the guard under test is missing: stub ssh/scp/rsync/aws first on PATH.
mkdir -p "$TMP/stub"
for tool in ssh scp rsync aws; do printf '#!/bin/sh\necho "stub-$0 $*" >> "%s/network.log"\nexit 99\n' "$TMP" > "$TMP/stub/$tool"; chmod +x "$TMP/stub/$tool"; done
export PATH="$TMP/stub:$PATH"
mkdir -p "$TMP/app"
printf '1.0.0\n' > "$TMP/app/VERSION"
printf 'name = "old-app"\ndomain = "-"\nport = 8197\nbuild = "touch built"\nartifact = "built"\nretired = "moved to titan; deploy with ./deploy.sh"\n' > "$TMP/app/akurai-deploy.toml"
for m in publish update release; do
if out="$("$ROOT/bin/akurai-ec2" release --mode "$m" --yes -C "$TMP/app" 2>&1)"; then
echo "FAIL: $m released a retired app"; echo "$out"; exit 1
fi
grep -q "old-app is retired on EC2: moved to titan; deploy with ./deploy.sh" <<<"$out" || { echo "FAIL: $m gave the wrong error"; echo "$out"; exit 1; }
[ ! -e "$TMP/app/built" ] || { echo "FAIL: $m ran the build before refusing"; exit 1; }
done
[ ! -s "$TMP/network.log" ] || { echo "FAIL: release reached the network"; cat "$TMP/network.log"; exit 1; }
grep -q '^1.0.0$' "$TMP/app/VERSION" || { echo "FAIL: VERSION was bumped"; exit 1; }
echo "release retired test: PASS"