Download this file
| 1 | #!/usr/bin/env bash |
| 2 | # Gives one app an empty database before it is measured. Deleting an |
| 3 | # instance parks its data, and the hostname can't be reused until an |
| 4 | # operator purges it, so this runs in two steps: |
| 5 | # scripts/fresh-instance.sh delete <slug> then an operator purges the host |
| 6 | # scripts/fresh-instance.sh create <slug> recreate, wait for the recorded version |
| 7 | # Bakeoff test data only. Paul's call, 2026-10-24. |
| 8 | set -euo pipefail |
| 9 | step=$1 slug=$2 |
| 10 | cd "$(dirname "$0")/.." |
| 11 | app=todo-$slug host=todo-$slug.bfj.oncarlos.com |
| 12 | want=$(python3 -c "import json; print(json.load(open('results/$slug.json'))['Version'])") |
| 13 | if [ "$step" = delete ]; then |
| 14 | carlos instances delete --account bfj --app "$app" --host "$host" --message "Empty the database before measuring (bakeoff)" |
| 15 | exit 0 |
| 16 | fi |
| 17 | carlos instances create --account bfj --app "$app" --host "$host" --channel edge --message "Recreate with an empty database (bakeoff)" |
| 18 | for _ in $(seq 1 60); do |
| 19 | got=$(curl -s --max-time 10 "https://$host/api/version" || true) |
| 20 | [ "$got" = "$want" ] && { echo "$slug: fresh instance serving $got"; carlos instances list --account bfj --app "$app" | tail -1; exit 0; } |
| 21 | sleep 5 |
| 22 | done |
| 23 | echo "$slug: fresh instance not serving $want after 5 minutes (last: $got)" >&2 |
| 24 | exit 1 |
| 25 | |