Files
computer-playbook/scripts/tests/e2e/rerun-spec.sh
T
kevinveenbirkenbachandClaude Opus 5 677a63931c Merge branch 'feature/network/multi-network-serving' into feature/store-i18n
Resolves 68 conflicted files. The governing rule was our structure with their
network semantics: the tor boolean becomes a network mode (clearnet | tor |
multi) throughout the variant layer, while this branch's architecture and mesh
axes, its extracted modules and its i18n content stay.

Where the two sides covered different ground, both are kept rather than one
picked:

- ca_injected answers a ca_client on the deployment's TLS mode OR on an SSO
  issuer that resolves self-signed. 3a3e9ed2c9 records why: an issuer is not
  an object store, so keeping only one side drops the other's coverage.
- get_merged_domains keeps the loud refusal when svc-net-tor is deployed
  without a provisioned node, now gated on their tor_serves_host; their
  node_onion_of returns an empty string there, which would have served every
  onion-exclusive app on clearnet in silence.
- sso_cookie_domains stays the single source for oauth2-proxy's cookie scope.
  Their per-network branch omitted the issuer domain on the onion arm, which
  breaks the callback leg.
- The clearnet CSP batch carries --clearnet-timeout again; their batch dict
  hardcoded zero while the role still passes the flag.
- The dashboard keeps its i18n content dir, image, version and design
  resolution; their side reduced the logo sources to the bare service
  provider values.

Their side wins where it is measurably better: the onion mirror rewrite is
gated per vhost rather than per app, the Playwright onion decision reads the
pass's own domain instead of the role's canonical one, and the matomo
reinjection and dashboard config render per network sibling.

Eight files were broken by the merge without ever carrying a conflict marker,
because git marks only the lines both sides touched:

- utils/cache/domains.py lost the onionize block that sat between two hunks
- roles/sys-front-inj-all/templates/body_filter.lua.j2 called it
- web-app-bluesky, keycloak sso_proxy: the get_entity_name filter was renamed
- trigger/__main__.py, playwright_coverage.py and its test: the deleted tor
  module
- cli/administration/deploy/ci/timings.py read Label.tor
- plugins/filter/csp_filters.py called _aligned_url with four of six arguments
- tests/unit/python/utils/cache/test_domains.py referenced a renamed class
- tests/.../sys-ctl-hlth-csp/files/test_script.py mocked a function main no
  longer calls

Verified: the variant layer (155 tests, 65 subtests), ca_injected (18),
the CI layer (175), the domains cache including the restored guard (32),
retrigger inputs (9), timings and the CSP health script (53). make
quality-high clears autoformat; its remaining findings are tracked separately.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-10-23 09:53:41 +02:00

142 lines
4.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# Rerun a role-local Playwright spec against the live running stack.
#
# Preconditions:
# - The role has been deployed at least once, so the Playwright project is
# staged under $TEST_E2E_PLAYWRIGHT_STAGE_BASE_DIR/<role> with a rendered
# .env file.
# - The application under test is still running.
#
# The stage base comes from INFINITO_PLAYWRIGHT_STAGE_BASE_DIR (env handler);
# DiD nodes run this without a generated .env, so the script falls back to
# the same role-vars SPOT the handler reads.
#
# This script intentionally does NOT re-render .env. It restages the
# role-local Playwright files (spec + companions) from the repo and reruns
# Playwright via the same container image the deploy-time runner uses.
#
# Usage:
# scripts/tests/e2e/rerun-spec.sh <role> [playwright args...] # nocheck: self-path-reference
# scripts/tests/e2e/rerun-spec.sh web-app-nextcloud --grep "talk admin" # nocheck: self-path-reference
set -euo pipefail
if [[ $# -lt 1 ]]; then
echo "usage: $0 <role> [playwright args...]" >&2
exit 2
fi
role="$1"
shift
repo_root="$(cd "$(dirname "$0")/../../.." && pwd)"
role_playwright_dir="$repo_root/roles/$role/files/playwright"
spec_src="$role_playwright_dir/playwright.spec.js"
services_yml="$repo_root/roles/test-e2e-playwright/meta/services.yml"
stage_base="${INFINITO_PLAYWRIGHT_STAGE_BASE_DIR:-}"
if [[ -z "$stage_base" ]]; then
stage_base="$(awk '$1 == "TEST_E2E_PLAYWRIGHT_STAGE_BASE_DIR:" {gsub(/"/, "", $2); print $2}' \
"$repo_root/roles/test-e2e-playwright/vars/main.yml")"
fi
[[ -n "$stage_base" ]] || {
echo "TEST_E2E_PLAYWRIGHT_STAGE_BASE_DIR missing in roles/test-e2e-playwright/vars/main.yml (SPOT)" >&2
exit 2
}
# shellcheck source=/dev/null
source <(grep -E '^INFINITO_PLAYWRIGHT_REPORTS_BASE_DIR=' "$repo_root/.env")
reports_base="${INFINITO_PLAYWRIGHT_REPORTS_BASE_DIR:?INFINITO_PLAYWRIGHT_REPORTS_BASE_DIR missing in .env (SPOT)}"
stage_dir="$stage_base/$role"
reports_dir="$reports_base/$role"
env_file="$stage_dir/.env"
[[ -f "$spec_src" ]] || {
echo "missing spec: $spec_src" >&2
exit 1
}
[[ -d "$stage_dir" ]] || {
echo "missing staging dir (run deploy first): $stage_dir" >&2
exit 1
}
[[ -f "$env_file" ]] || {
echo "missing rendered env (run deploy first): $env_file" >&2
exit 1
}
image="${TEST_E2E_PLAYWRIGHT_IMAGE:-}"
if [[ -z "$image" ]]; then
base_image="$(awk '/^[[:space:]]*image:[[:space:]]/{print $2; exit}' "$services_yml")"
tag="$(awk -F'"' '/^[[:space:]]*version:[[:space:]]/{print $2; exit}' "$services_yml")"
image="${base_image}:${tag}"
fi
command -v docker >/dev/null || {
echo "docker not found in PATH" >&2
exit 1
}
mkdir -p "$stage_dir/tests" "$stage_dir/volume" "$reports_dir"
for role_js in "$role_playwright_dir"/*.js; do
[[ -f "$role_js" ]] || continue
cp "$role_js" "$stage_dir/tests/$(basename "$role_js")"
done
for helper_src in "$repo_root/roles/test-e2e-playwright/files"/*.js; do
[[ -f "$helper_src" ]] || continue
[[ "$(basename "$helper_src")" == "playwright.config.js" ]] && continue
cp "$helper_src" "$stage_dir/tests/$(basename "$helper_src")"
done
personas_dir="$repo_root/roles/test-e2e-playwright/files/personas"
if [[ -d "$personas_dir" ]]; then
mkdir -p "$stage_dir/tests/personas/utils"
for persona_file in "$personas_dir"/*.js; do
[[ -f "$persona_file" ]] || continue
cp "$persona_file" "$stage_dir/tests/personas/$(basename "$persona_file")"
done
for util_file in "$personas_dir"/utils/*.js; do
[[ -f "$util_file" ]] || continue
cp "$util_file" "$stage_dir/tests/personas/utils/$(basename "$util_file")"
done
fi
for sub in addons fixtures; do
sub_dir="$role_playwright_dir/$sub"
[[ -d "$sub_dir" ]] || continue
mkdir -p "$stage_dir/tests/$sub"
for sub_file in "$sub_dir"/*.js; do
[[ -f "$sub_file" ]] || continue
cp "$sub_file" "$stage_dir/tests/$sub/$(basename "$sub_file")"
done
done
cmd="${TEST_E2E_PLAYWRIGHT_COMMAND:-npm install --no-fund --no-audit && npx playwright test${*:+ $*}}"
if [[ "${TEST_E2E_PLAYWRIGHT_NETWORK_HOST:-}" == "true" ]]; then
net_args=(--network host)
proxy_host="127.0.0.1"
else
net_args=(--add-host=host.docker.internal:host-gateway)
proxy_host="host.docker.internal"
fi
proxy_env=()
base_url="$(sed -n 's/^APP_BASE_URL=//p' "$env_file" | tr -d '"')"
if [[ "$base_url" =~ \.onion(/|$) ]]; then
default_proxy="socks5://${proxy_host}:${INFINITO_TOR_SOCKS_PORT:?INFINITO_TOR_SOCKS_PORT unset (built by the env handler from svc-net-tor services.tor.ports.local.socks)}"
proxy_env=(-e "PLAYWRIGHT_PROXY=${PLAYWRIGHT_PROXY:-$default_proxy}")
fi
exec docker run --rm \
--ipc=host --shm-size=1g \
"${net_args[@]}" \
--env-file "$env_file" \
-e "INFINITO_PLAYWRIGHT_KEEP=${INFINITO_PLAYWRIGHT_KEEP:-}" \
-e "PLAYWRIGHT_GALLERY_VIEWS=${PLAYWRIGHT_GALLERY_VIEWS:-}" \
-e "PLAYWRIGHT_GALLERY_BEFORE=${PLAYWRIGHT_GALLERY_BEFORE:-}" \
"${proxy_env[@]}" \
-v "$stage_dir:/e2e" \
-v "$stage_dir/volume:/volume" \
-v "$reports_dir:/reports" \
-w /e2e \
"$image" \
/bin/bash -lc "$cmd"