Files
computer-playbook/scripts/tests/deploy/roundtrip.sh
kevinveenbirkenbachandClaude Opus 5 7bcba20f9d test(environment): derive the disable set instead of listing it
07_compose_minimal.sh claimed to disable 'all variable (group-conditional)
services' and then named seven by hand. tor was not among them, so a
deploy meant to be minimal pulled svc-net-tor, which hard-depends on
web-svc-mirror, whose group-conditional prometheus flag the closure
resolver treats as true — dragging the whole web stack in. Steps 12 and
13 passed no disable at all, which is why a mariadb swarm test deployed
keycloak, mailu, matomo, prometheus and dashboard.

The set is now derived from the contract the repo already enforces
(tests/integration/roles/meta/services/test_dynamic_flags.py): a key is
group-conditional when enabled OR shared is a Jinja expression. Checking
only enabled would miss mariadb, postgres, redis, memcached, typesense.

Exclusions are load-bearing, not cosmetic: dashboard because disabling
the primary app aborts init; javascript because it aliases cdn, which
web-app-dashboard declares a hard dependency with no runtime fallback;
mariadb and postgres because steps 12 and 13 test them.

variable_services assigns to a local first — disable="$(cmd)" does not
set the exit status of a simple command, so a failing CLI would have
yielded an empty disable set and steps 12/13 would have run the full
deploy and reported green.

roundtrip could not take disable at all; it now reaches both the compose
and the swarm leg.

Not verified by a deploy: 33 of the keys are new to step 07, and the
variant axis of svc-db-mariadb/svc-db-postgres collapses because tor is
its only dimension.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-06 10:31:05 +02:00

66 lines
2.4 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# Iterate one or more roles through every deploy mode in order, stopping at the
# first failure. Inputs (env):
# apps - space-separated role ids; defaults to one role per dna cluster
# (complexity clone == false), most complex first, when unset
# modes - mode sequence (default "compose swarm"; append "k8s" here once it exists)
# keep - true keeps each validated swarm cluster instead of releasing it
# disable - comma-separated provider keys removed from the test inventory
_repo_root="$(cd "$(dirname "$0")/../../.." && pwd)"
# shellcheck source=scripts/meta/env/load.sh
. "${_repo_root}/scripts/meta/env/load.sh"
if [ -z "${apps:-}" ]; then
apps="$("${PYTHON}" -m cli.meta.roles.applications.complexity \
--sort "desc weight" --filter "clone == false" --format string)"
fi
[ -n "${apps// /}" ] || {
echo "roundtrip: no roles to run" >&2
exit 2
}
modes="${modes:-compose swarm}"
_log_dir="${TMPDIR:-/tmp}" # nocheck: posix TMPDIR convention
read -ra _apps <<<"${apps//$'\n'/ }"
read -ra _modes <<<"$modes"
for app in "${_apps[@]}"; do
app_skip="$("${PYTHON}" -c "import sys; sys.path.insert(0, '${_repo_root}'); from utils.roles.meta_lookup import get_role_skip; print(' '.join(get_role_skip('${app}')))")"
for mode in "${_modes[@]}"; do
if [[ " ${app_skip} " == *" ${mode} "* ]]; then
echo "==> roundtrip: ${app} [${mode}] SKIPPED (meta/services.yml skip)"
continue
fi
log="${_log_dir}/roundtrip-${app}-${mode}.log"
echo "==> roundtrip: ${app} [${mode}] (log: ${log})"
case "$mode" in
compose)
make -C "$_repo_root" compose-deploy \
mode=reinstall apps="$app" full_cycle=true variant=0 \
disable="${disable:-}" 2>&1 | tee "$log"
;;
swarm)
ACT_PLATFORM_IMAGE=local/act-runner-fixed:latest \
make -C "$_repo_root" swarm-zombie app="$app" \
disable="${disable:-}" 2>&1 | tee "$log"
marker="==> swarm drill complete: app=${app}"
grep -qF "${marker}" "$log" || {
echo "roundtrip: ${app} [swarm] FAILED: swarm-zombie exited 0 but the drill never completed for ${app} (marker '${marker}' absent from ${log})" >&2
exit 1
}
[ "${keep:-false}" = true ] || make -C "$_repo_root" swarm-down name="$app"
;;
*)
echo "roundtrip: unknown mode '${mode}' (expected: compose | swarm)" >&2
exit 2
;;
esac
done
done
echo "==> roundtrip: all ${#_apps[@]} role(s) green across [${modes}]"