diff --git a/Makefile b/Makefile index ea845c88de..f1715bccdf 100644 --- a/Makefile +++ b/Makefile @@ -22,79 +22,11 @@ act-debug: .PHONY: act-runner-image # Build local/act-runner-fixed: the stock act runner image with /var/run removed so a recent Docker engine accepts act's job-setup content copy. -# Usage: ACT_PLATFORM_IMAGE=local/act-runner-fixed:latest make act-swarm-zombie app= +# Usage: ACT_PLATFORM_IMAGE=local/act-runner-fixed:latest make swarm-zombie app= # Note: see docs/agents/action/iteration/workflow.md. act-runner-image: @bash scripts/tests/deploy/act/build_runner_image.sh -.PHONY: act-swarm-clean -# Reclaim ALL leftover act-swarm state (DinD nodes, NFS sidecars, lab networks, act outer containers) from aborted/wedged roundtrip runs, across every cluster id. -# Note: removes what the docker CLI can; D-state remnants (wedged kernel NFS) need a host docker restart under sudo, or are reported in a no-priv sandbox. -# Note: run BETWEEN swarm runs; it would kill an in-flight one. -act-swarm-clean: - @bash scripts/tests/deploy/swarm/clean_all.sh - -.PHONY: act-swarm-clean-stale-nfs -# Recover stale in-namespace NFS mounts from wedged act-swarm nfs-server containers. -# Usage: make act-swarm-clean-stale-nfs [cid=] [mount=/mnt/gtest] -# Note: needs sudo; may restart containerd/docker only if docker rm still cannot reap the container. -act-swarm-clean-stale-nfs: - @CID='$(cid)' NFS_MOUNT='$(mount)' bash scripts/tests/deploy/swarm/clean_stale_nfs.sh - -.PHONY: act-swarm-down -# Release a named swarm-test cluster (DinD nodes, lab network, act outer container). -# Param name: REQUIRED cluster id matching the one act-swarm-zombie used (the app id when no name= was passed). -# Note: Safe to run multiple times. -act-swarm-down: - @test -n '$(name)' || { echo 'usage: make act-swarm-down name= (the app id if you did not pass name=)'; exit 2; } - @SWARM_NAME='$(name)' INFINITO_KEEP_SWARM_NODES=false bash scripts/tests/deploy/swarm/13_cleanup.sh - @bash scripts/tests/deploy/act/down_act_outer.sh - -.PHONY: act-swarm-exec -# Run a one-off command inside one of the swarm-test DinD nodes. -# Param node: full container name (e.g. -swarm-mgr-01 | -nfs-server; cluster = name= or the app id). -# Param cmd: shell pipeline executed inside that container. -act-swarm-exec: - @node='$(node)' cmd='$(cmd)' bash scripts/tests/deploy/act/exec_node.sh - -.PHONY: act-swarm-playwright -# Rerun a role-local Playwright spec against the live swarm-test cluster (no redeploy). -# Note: nodes hold a frozen bootstrap copy (not a compose-style mount), so the working-tree's modified+untracked files are copied into the node before rerunning via the same rerun-spec.sh engine as compose-playwright; solve ALL of a role's tests (no pw= narrowing) before any redeploy. -# Usage: make act-swarm-playwright role= name= [pw="--grep "] [keep=true] [node=] -# Example: make act-swarm-playwright role=web-svc-logout name=web-app-baserow pw="--grep baserow" keep=true -act-swarm-playwright: - @: $${role:?role= required, e.g. role=web-svc-logout} - @test -n '$(name)' || { echo 'name= required (the app id when no name= was passed to act-swarm-zombie)'; exit 2; } - @node='$(or $(node),$(name)-swarm-mgr-01)' bash scripts/tests/deploy/act/copy_worktree_to_node.sh - @node='$(or $(node),$(name)-swarm-mgr-01)' cmd='cd /opt/infinito-nexus && TEST_E2E_PLAYWRIGHT_NETWORK_HOST=true $(if $(keep),INFINITO_PLAYWRIGHT_KEEP=$(keep) )bash scripts/tests/e2e/rerun-spec.sh $(role) $(pw)' bash scripts/tests/deploy/act/exec_node.sh - -.PHONY: act-swarm-shell -# Drop into an interactive shell on one of the swarm-test DinD nodes. -# Param name: REQUIRED cluster id (the app id when no name= was passed); node defaults to -swarm-mgr-01. -# Param node: full container name to target (overrides the default). -act-swarm-shell: - @test -n '$(name)' || { echo 'usage: make act-swarm-shell name= [node=]'; exit 2; } - @SWARM_NAME='$(name)' node='$(node)' bash scripts/tests/deploy/act/shell_node.sh - -.PHONY: act-swarm-zombie -# Run a swarm matrix-app test and leave the cluster alive afterwards for post-mortem inspection. -# Param app: matrix application id (e.g. web-app-baserow). -# Param disable: optional comma-separated provider keys removed from the test inventory (e.g. matomo,dashboard,prometheus,email,css). -# Param name: optional cluster-id prefix for the container + network names (parallel/named clusters); release with the same name=. -# Note: Use `make act-swarm-exec` / `make act-swarm-shell` to inspect, `make act-swarm-down` to release. -act-swarm-zombie: - @test -n '$(app)' || { echo 'usage: make act-swarm-zombie app= [name=] [disable=]'; exit 2; } - @SWARM_NAME='$(or $(name),$(app))' INFINITO_KEEP_SWARM_NODES=false bash scripts/tests/deploy/swarm/13_cleanup.sh - @bash scripts/tests/deploy/act/down_act_outer.sh - @ACT_RM=false \ - ACT_BIND=true \ - ACT_ENV='INFINITO_KEEP_SWARM_NODES=true;INFINITO_APP_DISCOVERY_RUNNER=host;disable=$(disable);SWARM_NAME=$(or $(name),$(app))' \ - ACT_WORKFLOW=.github/workflows/test-deploy-swarm.yml \ - ACT_JOB=swarm \ - ACT_MATRIX='apps:$(app)' \ - ACT_INPUTS='whitelist=$(app)' \ - bash scripts/tests/deploy/act/workflow.sh - .PHONY: act-workflow # Run the act-based workflow deploy check. act-workflow: @@ -186,7 +118,7 @@ clean-pycache-dirs: .PHONY: clean-stale-nfs # Recover stale in-namespace NFS mounts from wedged act-swarm nfs-server containers. # Usage: make clean-stale-nfs [cid=] [mount=/mnt/gtest] -clean-stale-nfs: act-swarm-clean-stale-nfs +clean-stale-nfs: swarm-clean-stale-nfs .PHONY: clean-sudo # Remove ignored files from the working tree with sudo. @@ -554,6 +486,74 @@ setup: fix-dockerignore dotenv setup-clean: clean setup @echo "Full build with cleanup before was executed." +.PHONY: swarm-clean +# Reclaim ALL leftover act-swarm state (DinD nodes, NFS sidecars, lab networks, act outer containers) from aborted/wedged roundtrip runs, across every cluster id. +# Note: removes what the docker CLI can; D-state remnants (wedged kernel NFS) need a host docker restart under sudo, or are reported in a no-priv sandbox. +# Note: run BETWEEN swarm runs; it would kill an in-flight one. +swarm-clean: + @bash scripts/tests/deploy/swarm/clean_all.sh + +.PHONY: swarm-clean-stale-nfs +# Recover stale in-namespace NFS mounts from wedged act-swarm nfs-server containers. +# Usage: make swarm-clean-stale-nfs [cid=] [mount=/mnt/gtest] +# Note: needs sudo; may restart containerd/docker only if docker rm still cannot reap the container. +swarm-clean-stale-nfs: + @CID='$(cid)' NFS_MOUNT='$(mount)' bash scripts/tests/deploy/swarm/clean_stale_nfs.sh + +.PHONY: swarm-down +# Release a named swarm-test cluster (DinD nodes, lab network, act outer container). +# Param name: REQUIRED cluster id matching the one swarm-zombie used (the app id when no name= was passed). +# Note: Safe to run multiple times. +swarm-down: + @test -n '$(name)' || { echo 'usage: make swarm-down name= (the app id if you did not pass name=)'; exit 2; } + @SWARM_NAME='$(name)' INFINITO_KEEP_SWARM_NODES=false bash scripts/tests/deploy/swarm/13_cleanup.sh + @bash scripts/tests/deploy/act/down_act_outer.sh + +.PHONY: swarm-exec +# Run a one-off command inside one of the swarm-test DinD nodes. +# Param node: full container name (e.g. -swarm-mgr-01 | -nfs-server; cluster = name= or the app id). +# Param cmd: shell pipeline executed inside that container. +swarm-exec: + @node='$(node)' cmd='$(cmd)' bash scripts/tests/deploy/act/exec_node.sh + +.PHONY: swarm-playwright +# Rerun a role-local Playwright spec against the live swarm-test cluster (no redeploy). +# Note: nodes hold a frozen bootstrap copy (not a compose-style mount), so the working-tree's modified+untracked files are copied into the node before rerunning via the same rerun-spec.sh engine as compose-playwright; solve ALL of a role's tests (no pw= narrowing) before any redeploy. +# Usage: make swarm-playwright role= name= [pw="--grep "] [keep=true] [node=] +# Example: make swarm-playwright role=web-svc-logout name=web-app-baserow pw="--grep baserow" keep=true +swarm-playwright: + @: $${role:?role= required, e.g. role=web-svc-logout} + @test -n '$(name)' || { echo 'name= required (the app id when no name= was passed to swarm-zombie)'; exit 2; } + @node='$(or $(node),$(name)-swarm-mgr-01)' bash scripts/tests/deploy/act/copy_worktree_to_node.sh + @node='$(or $(node),$(name)-swarm-mgr-01)' cmd='cd /opt/infinito-nexus && TEST_E2E_PLAYWRIGHT_NETWORK_HOST=true $(if $(keep),INFINITO_PLAYWRIGHT_KEEP=$(keep) )bash scripts/tests/e2e/rerun-spec.sh $(role) $(pw)' bash scripts/tests/deploy/act/exec_node.sh + +.PHONY: swarm-shell +# Drop into an interactive shell on one of the swarm-test DinD nodes. +# Param name: REQUIRED cluster id (the app id when no name= was passed); node defaults to -swarm-mgr-01. +# Param node: full container name to target (overrides the default). +swarm-shell: + @test -n '$(name)' || { echo 'usage: make swarm-shell name= [node=]'; exit 2; } + @SWARM_NAME='$(name)' node='$(node)' bash scripts/tests/deploy/act/shell_node.sh + +.PHONY: swarm-zombie +# Run a swarm matrix-app test and leave the cluster alive afterwards for post-mortem inspection. +# Param app: matrix application id (e.g. web-app-baserow). +# Param disable: optional comma-separated provider keys removed from the test inventory (e.g. matomo,dashboard,prometheus,email,css). +# Param name: optional cluster-id prefix for the container + network names (parallel/named clusters); release with the same name=. +# Note: Use `make swarm-exec` / `make swarm-shell` to inspect, `make swarm-down` to release. +swarm-zombie: + @test -n '$(app)' || { echo 'usage: make swarm-zombie app= [name=] [disable=]'; exit 2; } + @SWARM_NAME='$(or $(name),$(app))' INFINITO_KEEP_SWARM_NODES=false bash scripts/tests/deploy/swarm/13_cleanup.sh + @bash scripts/tests/deploy/act/down_act_outer.sh + @ACT_RM=false \ + ACT_BIND=true \ + ACT_ENV='INFINITO_KEEP_SWARM_NODES=true;INFINITO_APP_DISCOVERY_RUNNER=host;disable=$(disable);SWARM_NAME=$(or $(name),$(app))' \ + ACT_WORKFLOW=.github/workflows/test-deploy-swarm.yml \ + ACT_JOB=swarm \ + ACT_MATRIX='apps:$(app)' \ + ACT_INPUTS='whitelist=$(app)' \ + bash scripts/tests/deploy/act/workflow.sh + .PHONY: system-purge # Run the broad low-hardware cleanup routine. system-purge: diff --git a/docs/agents/action/iteration/playwright.md b/docs/agents/action/iteration/playwright.md index fa9b3ccd3a..f45776d01d 100644 --- a/docs/agents/action/iteration/playwright.md +++ b/docs/agents/action/iteration/playwright.md @@ -4,8 +4,8 @@ This page defines the inner loop for iterating on a role-local `files/playwright ## Definitions -- **Inner loop**: the edit-rerun cycle on `roles//files/playwright/playwright.spec.js` driven by `make compose-playwright role=`, without a redeploy. On the act-swarm test cluster the equivalent is `make act-swarm-playwright role=`, which first copies the working-tree's modified files into the node's frozen bootstrap copy (swarm nodes are not bind-mounted like compose). - - If any `make act-swarm-*` target aborts at **Set up job** with `mkdirat var/run...` on a recent Docker engine, point act at a fixed runner image per [Workflow Loop](workflow.md#act-fails-at-set-up-job-on-recent-docker). +- **Inner loop**: the edit-rerun cycle on `roles//files/playwright/playwright.spec.js` driven by `make compose-playwright role=`, without a redeploy. On the act-swarm test cluster the equivalent is `make swarm-playwright role=`, which first copies the working-tree's modified files into the node's frozen bootstrap copy (swarm nodes are not bind-mounted like compose). + - If any `make swarm-*` target aborts at **Set up job** with `mkdirat var/run...` on a recent Docker engine, point act at a fixed runner image per [Workflow Loop](workflow.md#act-fails-at-set-up-job-on-recent-docker). - **Staging dir**: `TEST_E2E_PLAYWRIGHT_STAGE_BASE_DIR/` (default `/tmp/test-e2e-playwright/`). Contains the rendered `.env` and the Playwright project from the last deploy. - **Baseline deploy**: a successful `make compose-deploy mode=reinstall apps= full_cycle=true` run as defined in [Compose Loop](compose.md). - **Pass**: `make compose-playwright role=` exits `0` AND every MUST in [Contributing `playwright.spec.js`](../../../contributing/artefact/files/role/playwright.specs.js.md) holds for the resulting run. @@ -53,7 +53,7 @@ To validate a hypothesis without redeploying — e.g. rerun the Playwright image You MUST NOT report the task complete until all of the following hold: -1. `make compose-playwright role=` (or `make act-swarm-playwright role=` against the swarm cluster) exited `0` on its last invocation, run WITHOUT any `pw="--grep …"` narrowing, so the entire spec (every test and every persona) ran and ALL passed. Redeploying while only a grepped subset is green and other tests are red or unrun is FORBIDDEN: the full suite MUST be green in the container first. +1. `make compose-playwright role=` (or `make swarm-playwright role=` against the swarm cluster) exited `0` on its last invocation, run WITHOUT any `pw="--grep …"` narrowing, so the entire spec (every test and every persona) ran and ALL passed. Redeploying while only a grepped subset is green and other tests are red or unrun is FORBIDDEN: the full suite MUST be green in the container first. 2. Every MUST in [Contributing `playwright.spec.js`](../../../contributing/artefact/files/role/playwright.specs.js.md) holds, including the live-application assertion and the logged-out final state. 3. A final `make compose-deploy mode=reinstall apps= full_cycle=true` run has completed with the spec passing against the freshly provisioned stack. Inner-loop passes alone do NOT satisfy this gate. diff --git a/docs/agents/action/iteration/roundtrip.md b/docs/agents/action/iteration/roundtrip.md index 362d0920fd..a641efbf02 100644 --- a/docs/agents/action/iteration/roundtrip.md +++ b/docs/agents/action/iteration/roundtrip.md @@ -6,7 +6,7 @@ For debugging the compose deploy of one role, see [Compose Loop](compose.md); fo ## When to use - Use the roundtrip loop to **confirm parity**: a role (or a set of roles) must come up green in compose AND swarm. It is the end-of-change regression sweep, not the place to debug a fresh failure. -- While you are actively debugging one mode, use the focused loops instead: [Compose Loop](compose.md) for the compose deploy, [Swarm Loop](swarm.md) plus the `act-swarm-*` targets for the swarm deploy. Return to the roundtrip once both modes pass in isolation. +- While you are actively debugging one mode, use the focused loops instead: [Compose Loop](compose.md) for the compose deploy, [Swarm Loop](swarm.md) plus the `swarm-*` targets for the swarm deploy. Return to the roundtrip once both modes pass in isolation. ## Rules @@ -14,7 +14,7 @@ For debugging the compose deploy of one role, see [Compose Loop](compose.md); fo - With no `apps=`, the loop defaults to **every application, most-complex first** (the `complexity` CLI: `infinito meta roles applications complexity --sort total --order desc --format string`). That is a large run (one compose plus one swarm deploy per app), so narrow it with `apps=` while iterating. - The mode sequence defaults to `compose swarm` and is overridable with `modes="compose swarm"`. The order is always compose first, so the cheaper mode fails fast before the expensive swarm rebuild. Append `k8s` here once that mode exists. - Per step the output is streamed to `${TMPDIR:-/tmp}/roundtrip--.log`. Tell the operator the exact `tail -f` path for the running step. -- The compose step runs `compose-deploy mode=reinstall apps= full_cycle=true variant=0`; the swarm step runs `act-swarm-zombie app=`, so the cluster is named `-swarm-mgr-01` etc. via the mandatory `SWARM_NAME` (the app id is the default cluster id). Each validated swarm cluster is released afterwards unless you pass `keep=true`. +- The compose step runs `compose-deploy mode=reinstall apps= full_cycle=true variant=0`; the swarm step runs `swarm-zombie app=`, so the cluster is named `-swarm-mgr-01` etc. via the mandatory `SWARM_NAME` (the app id is the default cluster id). Each validated swarm cluster is released afterwards unless you pass `keep=true`. - `make autoformat` and `make test` MUST be green before a roundtrip; the loop does not re-run them per app. - **A blocked mode is NEVER a reason to silently switch to another.** If a mode cannot run (the swarm NFS wedge below, a wedged daemon, a missing host capability), STOP the whole sweep, report the blocker together with the exact recovery command, and wait for it to be cleared. You MUST NOT fall back to a `modes=compose`-only (or any reduced) sweep to look productive: it hides the unmet swarm parity and never satisfies the compose-AND-swarm gate. Resume the full sweep only once the blocker is gone. @@ -24,12 +24,12 @@ The roundtrip is a gate, not a debugger: when a step goes red it stops and leave - Read `${TMPDIR:-/tmp}/roundtrip--.log` to see which app and mode failed, and the first error. - If the **compose** step failed, switch to the [Compose Loop](compose.md): reproduce with `make compose-deploy mode=update apps=`, inspect via `make compose-exec` / `make compose-inner-run`, apply the real fix in the repository, then re-run the roundtrip. -- If the **swarm** step failed, the cluster is left up (fail-fast skips the release). Inspect it with `make act-swarm-exec node=-swarm-mgr-01 cmd='...'` or `make act-swarm-shell name=` per the [Swarm Loop](swarm.md), confirm the fix on the live cluster, then re-run. Release it manually with `make act-swarm-down name=` when done. +- If the **swarm** step failed, the cluster is left up (fail-fast skips the release). Inspect it with `make swarm-exec node=-swarm-mgr-01 cmd='...'` or `make swarm-shell name=` per the [Swarm Loop](swarm.md), confirm the fix on the live cluster, then re-run. Release it manually with `make swarm-down name=` when done. - Validate every candidate fix on live state BEFORE the next roundtrip; a swarm rebuild costs tens of minutes (same rule as the focused loops). In-cluster edits are validation only, the repo change is the real fix. - Once the failing mode is green in its focused loop, re-run the full roundtrip to re-confirm parity across all modes. ## Gotchas - On a recent Docker engine the swarm step can abort at job setup; run `make act-runner-image` once and prefix the run with `ACT_PLATFORM_IMAGE=local/act-runner-fixed:latest` (see [Workflow Loop](workflow.md)). -- The swarm-test nfs-server serves shared storage from userspace `nfs-ganesha` (the `ganesha` flavor of `svc-storage-nfs-server`, selected when `RUNTIME in ['dev', 'act']`), which runs inside the privileged DinD node and never touches the host kernel `nfsd`, so an interrupted export cannot wedge the host. Production keeps the `kernel` flavor on real hosts, where `nfsd` is not shared across clusters. If a swarm step ever hangs at `Reload NFS exports` from a stuck kernel-NFS mount, you MUST recover with `make act-swarm-clean` on the host (needs sudo): it removes what the docker CLI can, then runs `umount -f -l /var/lib/infinito` + `exportfs -ua` + `systemctl restart docker`. The no-sudo sandbox only prints those commands, so the host recovery is mandatory and the sweep MUST stop until it is done; never fall back to compose-only. -- Distinct `SWARM_NAME` per app means several apps can keep their clusters in parallel under `keep=true`; release each one with `make act-swarm-down name=`. +- The swarm-test nfs-server serves shared storage from userspace `nfs-ganesha` (the `ganesha` flavor of `svc-storage-nfs-server`, selected when `RUNTIME in ['dev', 'act']`), which runs inside the privileged DinD node and never touches the host kernel `nfsd`, so an interrupted export cannot wedge the host. Production keeps the `kernel` flavor on real hosts, where `nfsd` is not shared across clusters. If a swarm step ever hangs at `Reload NFS exports` from a stuck kernel-NFS mount, you MUST recover with `make swarm-clean` on the host (needs sudo): it removes what the docker CLI can, then runs `umount -f -l /var/lib/infinito` + `exportfs -ua` + `systemctl restart docker`. The no-sudo sandbox only prints those commands, so the host recovery is mandatory and the sweep MUST stop until it is done; never fall back to compose-only. +- Distinct `SWARM_NAME` per app means several apps can keep their clusters in parallel under `keep=true`; release each one with `make swarm-down name=`. diff --git a/docs/agents/action/iteration/swarm.md b/docs/agents/action/iteration/swarm.md index 09087f0a02..6517eba588 100644 --- a/docs/agents/action/iteration/swarm.md +++ b/docs/agents/action/iteration/swarm.md @@ -1,16 +1,16 @@ # Swarm Loop -Iterate on a swarm deploy of a role through Act and the `act-swarm-*` targets. +Iterate on a swarm deploy of a role through Act and the `swarm-*` targets. For the compose deploy of the same role, see [Compose Loop](compose.md). For the cross-mode parity gate, see [Roundtrip Loop](roundtrip.md). When Act aborts at "Set up job" on a recent Docker engine, see [Workflow Loop](workflow.md). ## Inspect before redeploy -An `act-swarm-zombie` run rebuilds a full DinD cluster over tens of minutes, so you MUST confirm a fix on the live cluster before redeploying. +An `swarm-zombie` run rebuilds a full DinD cluster over tens of minutes, so you MUST confirm a fix on the live cluster before redeploying. - Before every redeploy you MUST fully resolve the failure in swarm and reach at least **95% confidence that your fix actually fixes it**. That confidence MUST come from inspecting the live cluster in-container: reproduce the failure, walk the fix path, and confirm the corrected behaviour on the running services. Never redeploy on a guess — a swarm redeploy costs tens of minutes. -- The run leaves the cluster up (`INFINITO_KEEP_SWARM_NODES=true`). You MUST reproduce the failure on it via `make act-swarm-exec` / `make act-swarm-shell`, then release it with `make act-swarm-down`. +- The run leaves the cluster up (`INFINITO_KEEP_SWARM_NODES=true`). You MUST reproduce the failure on it via `make swarm-exec` / `make swarm-shell`, then release it with `make swarm-down`. - You MAY confirm an early-stage fix (config render, realm import) while the run is still going. - In-cluster edits are validation only. You MUST apply the real fix in the repository before the next redeploy. - You MUST NOT commit during an active iteration, because a live deploy makes the pre-commit hook stash the files it reads. If a commit is unavoidable, you MUST pass `--no-verify`. @@ -20,5 +20,5 @@ An `act-swarm-zombie` run rebuilds a full DinD cluster over tens of minutes, so ## NFS server flavor The swarm-test nfs-server uses the userspace `nfs-ganesha` (`ganesha`) flavor for local runtimes (`RUNTIME in ['dev', 'act']`) and the `kernel` flavor for real GitHub Actions CI and production, so CI exercises the production flavor. Kernel `nfsd` in a privileged DinD node is wedge-prone: the export can be present yet the controller mount returns ENOENT, and `exportfs` can stick in D-state. -If a swarm step hangs at `Reload NFS exports` from a stuck kernel-NFS mount, you MUST recover with `make act-swarm-clean` on the host; see the NFS gotcha in [Roundtrip Loop](roundtrip.md). +If a swarm step hangs at `Reload NFS exports` from a stuck kernel-NFS mount, you MUST recover with `make swarm-clean` on the host; see the NFS gotcha in [Roundtrip Loop](roundtrip.md). You MUST NOT fall back to a compose-only sweep while swarm is blocked. diff --git a/docs/agents/action/iteration/workflow.md b/docs/agents/action/iteration/workflow.md index 34ca616dde..8aa1abd7e1 100644 --- a/docs/agents/action/iteration/workflow.md +++ b/docs/agents/action/iteration/workflow.md @@ -19,4 +19,4 @@ For the swarm deploy loop, see [Swarm Loop](swarm.md). `make act-*` aborts with `failed to copy content to container: mkdirat var/run...` because the stock runner image's `/var/run` symlink trips Docker 28/29's stricter `docker cp`. -Fix: run `make act-runner-image` once, then prefix any act target with `ACT_PLATFORM_IMAGE=local/act-runner-fixed:latest` (e.g. `ACT_PLATFORM_IMAGE=local/act-runner-fixed:latest make act-swarm-zombie app=`). +Fix: run `make act-runner-image` once, then prefix any act target with `ACT_PLATFORM_IMAGE=local/act-runner-fixed:latest` (e.g. `ACT_PLATFORM_IMAGE=local/act-runner-fixed:latest make swarm-zombie app=`). diff --git a/scripts/tests/deploy/act/copy_worktree_to_node.sh b/scripts/tests/deploy/act/copy_worktree_to_node.sh index 460dba5d41..059a7ed210 100755 --- a/scripts/tests/deploy/act/copy_worktree_to_node.sh +++ b/scripts/tests/deploy/act/copy_worktree_to_node.sh @@ -4,16 +4,13 @@ set -euo pipefail : "${node:?node= must be set, e.g. node=swarm-mgr-01}" if ! docker inspect --format '{{.State.Running}}' "${node}" 2>/dev/null | grep -q '^true$'; then - echo "ERROR: container '${node}' is not running. Run \`make act-swarm-zombie app=\` first." >&2 + echo "ERROR: container '${node}' is not running. Run \`make swarm-zombie app=\` first." >&2 exit 1 fi repo_root="$(cd "$(dirname "$0")/../../../.." && pwd)" cd "${repo_root}" -# Mirror 04_bootstrap_nodes.sh: tar the working-tree's modified+untracked files into the -# node's frozen bootstrap copy at /opt/infinito-nexus (the nodes are not bind-mounted, so a -# repo edit is otherwise invisible on the node). git ls-files -z -m -o --exclude-standard | tar --null -cf - -T - | docker exec -i "${node}" tar -C /opt/infinito-nexus -xpf - diff --git a/scripts/tests/deploy/act/exec_node.sh b/scripts/tests/deploy/act/exec_node.sh index 9dada70985..119d70f43f 100755 --- a/scripts/tests/deploy/act/exec_node.sh +++ b/scripts/tests/deploy/act/exec_node.sh @@ -9,9 +9,8 @@ if ! docker inspect --format '{{.State.Running}}' "${node}" 2>/dev/null | grep - echo "Available swarm-test containers (if any):" >&2 docker ps --format ' {{.Names}}\t{{.Status}}' | grep -E 'swarm-|nfs-server' >&2 || - echo " (none — run \`make act-swarm-zombie app=\` first)" >&2 + echo " (none — run \`make swarm-zombie app=\` first)" >&2 exit 1 fi -# --noprofile --norc mirrors `make compose-exec` so a quoted pipeline survives one make-level cmd= expansion. docker exec -i "${node}" bash --noprofile --norc -c "${cmd}" diff --git a/scripts/tests/deploy/act/shell_node.sh b/scripts/tests/deploy/act/shell_node.sh index 946e61294b..869f30eced 100755 --- a/scripts/tests/deploy/act/shell_node.sh +++ b/scripts/tests/deploy/act/shell_node.sh @@ -11,7 +11,7 @@ if ! docker inspect --format '{{.State.Running}}' "${node}" 2>/dev/null | grep - echo "Available swarm-test containers (if any):" >&2 docker ps --format ' {{.Names}}\t{{.Status}}' | grep -E 'swarm-|nfs-server' >&2 || - echo " (none — run \`make act-swarm-zombie app=\` first)" >&2 + echo " (none — run \`make swarm-zombie app=\` first)" >&2 exit 1 fi diff --git a/scripts/tests/deploy/roundtrip.sh b/scripts/tests/deploy/roundtrip.sh index a6687395ca..920f9e2bcc 100755 --- a/scripts/tests/deploy/roundtrip.sh +++ b/scripts/tests/deploy/roundtrip.sh @@ -43,12 +43,12 @@ for app in "${_apps[@]}"; do ;; swarm) ACT_PLATFORM_IMAGE=local/act-runner-fixed:latest \ - make -C "$_repo_root" act-swarm-zombie app="$app" 2>&1 | tee "$log" + make -C "$_repo_root" swarm-zombie app="$app" 2>&1 | tee "$log" grep -q "Matrix-deploy ${app}: provision/deploy/e2e/verify per round" "$log" || { echo "roundtrip: ${app} [swarm] FAILED: swarm deploy job did not run (empty matrix); see ${log}" >&2 exit 1 } - [ "${keep:-false}" = true ] || make -C "$_repo_root" act-swarm-down name="$app" + [ "${keep:-false}" = true ] || make -C "$_repo_root" swarm-down name="$app" ;; *) echo "roundtrip: unknown mode '${mode}' (expected: compose | swarm)" >&2 diff --git a/scripts/tests/deploy/swarm/13_cleanup.sh b/scripts/tests/deploy/swarm/13_cleanup.sh index 75bf1f1c67..60315f9379 100755 --- a/scripts/tests/deploy/swarm/13_cleanup.sh +++ b/scripts/tests/deploy/swarm/13_cleanup.sh @@ -3,8 +3,8 @@ set +e if [ "${INFINITO_KEEP_SWARM_NODES}" = "true" ]; then echo "INFINITO_KEEP_SWARM_NODES=true -> preserving swarm cluster for post-mortem inspection." - echo "Inspect: make act-swarm-exec node=swarm-mgr-01 cmd='docker service ls'" - echo "Release: make act-swarm-down" + echo "Inspect: make swarm-exec node=swarm-mgr-01 cmd='docker service ls'" + echo "Release: make swarm-down" exit 0 fi diff --git a/scripts/tests/deploy/swarm/clean_all.sh b/scripts/tests/deploy/swarm/clean_all.sh index 2c4dbff40d..e6ce167406 100755 --- a/scripts/tests/deploy/swarm/clean_all.sh +++ b/scripts/tests/deploy/swarm/clean_all.sh @@ -36,14 +36,14 @@ _select_names() { docker ps -a --format '{{.Names}}' --filter "name=${_act_name}" 2>/dev/null } -echo ">>> act-swarm-clean: leftover containers" +echo ">>> swarm-clean: leftover containers" _ctrs="$(_select_ids | sort -u)" if [ -n "${_ctrs}" ]; then # shellcheck disable=SC2086 # intentional word-split of the id list docker rm -f ${_ctrs} 2>&1 | sed 's/^/ /' || true fi -echo ">>> act-swarm-clean: leftover networks" +echo ">>> swarm-clean: leftover networks" _nets="$(docker network ls --format '{{.Name}}' | grep -E "${INFINITO_SWARM_LAB_NET_NAME}" || true)" if [ -n "${_nets}" ]; then # shellcheck disable=SC2086 # intentional word-split of the network list @@ -53,11 +53,11 @@ docker network prune -f >/dev/null 2>&1 || true _left="$(_select_names | sort -u)" if [ -z "${_left}" ]; then - echo ">>> act-swarm-clean: done, no remnants" + echo ">>> swarm-clean: done, no remnants" exit 0 fi -echo ">>> act-swarm-clean: D-state remnants survived docker rm -f:" +echo ">>> swarm-clean: D-state remnants survived docker rm -f:" echo " ${_left//$'\n'/$'\n' }" if sudo -n true 2>/dev/null; then echo ">>> clearing wedged kernel NFS on host (sudo)" diff --git a/scripts/tests/e2e/rerun-spec.sh b/scripts/tests/e2e/rerun-spec.sh index 649dcbd6ae..872e544aca 100755 --- a/scripts/tests/e2e/rerun-spec.sh +++ b/scripts/tests/e2e/rerun-spec.sh @@ -95,9 +95,6 @@ done cmd="${TEST_E2E_PLAYWRIGHT_COMMAND:-npm install --no-fund --no-audit && npx playwright test${*:+ $*}}" -# Swarm reruns need the node's network namespace to reach cross-app canonical domains -# (mirrors roles/test-e2e-playwright/tasks/02_run_one.yml); compose uses host-gateway. -# The act-swarm-playwright helper sets the flag; compose-playwright leaves it unset. if [[ "${TEST_E2E_PLAYWRIGHT_NETWORK_HOST:-}" == "true" ]]; then net_args=(--network host) else diff --git a/scripts/tests/environment/07_deploy_minimal.sh b/scripts/tests/environment/07_compose_minimal.sh similarity index 78% rename from scripts/tests/environment/07_deploy_minimal.sh rename to scripts/tests/environment/07_compose_minimal.sh index cd41feaa17..bb5b5bba54 100755 --- a/scripts/tests/environment/07_deploy_minimal.sh +++ b/scripts/tests/environment/07_compose_minimal.sh @@ -11,8 +11,8 @@ source "${SCRIPT_DIR}/utils/cache.sh" echo "Snapshotting cache counters before the deploy." CACHE_BEFORE="$(cache_snapshot)" -echo "Deploying dashboard with matomo disabled to verify the disable= make arg suppresses the shared service in the inventory." -make compose-deploy mode=reinstall apps="${DASHBOARD_APP}" disable="matomo" +echo "Deploying dashboard with all variable (group-conditional) services disabled to speed up the deploy and verify disable= suppresses them from the inventory." +make compose-deploy mode=reinstall apps="${DASHBOARD_APP}" disable="sso,asset,simpleicons,logout,matomo,css,prometheus" inspect echo "Actively probing both caches to confirm pull-through works end-to-end." @@ -32,5 +32,5 @@ echo "Verifying the dashboard is reachable (matomo was disabled, not the dashboa assert_http_status 200 "${DASHBOARD_URL}" echo "Verifying matomo is not reachable because it was excluded from the inventory." -# Expect 000 because curl aborts in TLS before HTTP when the excluded hostname is missing from the certificate SANs. +# Exception: Expect 000 because curl aborts in TLS before HTTP when the excluded hostname is missing from the certificate SANs. assert_http_status 000 "${MATOMO_URL}" diff --git a/scripts/tests/environment/08_deploy_performance.sh b/scripts/tests/environment/08_compose_performance.sh similarity index 86% rename from scripts/tests/environment/08_deploy_performance.sh rename to scripts/tests/environment/08_compose_performance.sh index 5f8ac530f1..e5d0266b3c 100755 --- a/scripts/tests/environment/08_deploy_performance.sh +++ b/scripts/tests/environment/08_compose_performance.sh @@ -17,5 +17,5 @@ echo "Verifying matomo is now reachable after its dedicated deploy." assert_http_status 200 "${MATOMO_URL}" echo "Verifying the dashboard is no longer reachable after the matomo-only fresh deploy." -# Expect 000 because curl aborts in TLS before HTTP when the removed hostname is missing from the certificate SANs. +# Exception: Expect 000 because curl aborts in TLS before HTTP when the removed hostname is missing from the certificate SANs. assert_http_status 000 "${DASHBOARD_URL}" diff --git a/scripts/tests/environment/09_deploy_reuse.sh b/scripts/tests/environment/09_compose_reuse.sh similarity index 100% rename from scripts/tests/environment/09_deploy_reuse.sh rename to scripts/tests/environment/09_compose_reuse.sh diff --git a/scripts/tests/environment/12_swarm.sh b/scripts/tests/environment/12_swarm.sh new file mode 100755 index 0000000000..756e29c732 --- /dev/null +++ b/scripts/tests/environment/12_swarm.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +# Swarm-specific deploy of the MariaDB database role (svc-db-mariadb) via the swarm-* make targets. +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# shellcheck source=scripts/tests/environment/utils/common.sh +source "${SCRIPT_DIR}/utils/common.sh" + +cd "${REPO_ROOT}" + +echo "Deploying the MariaDB database role ${MARIADB_APP} on a throwaway swarm cluster." +make swarm-zombie app="${MARIADB_APP}" + +echo "Releasing the swarm cluster." +make swarm-down name="${MARIADB_APP}" diff --git a/scripts/tests/environment/13_roundtrip.sh b/scripts/tests/environment/13_roundtrip.sh new file mode 100755 index 0000000000..be952d84c9 --- /dev/null +++ b/scripts/tests/environment/13_roundtrip.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +# Full compose+swarm roundtrip of the PostgreSQL database role (svc-db-postgres). +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# shellcheck source=scripts/tests/environment/utils/common.sh +source "${SCRIPT_DIR}/utils/common.sh" + +cd "${REPO_ROOT}" + +echo "Running the full compose+swarm roundtrip against the PostgreSQL database role ${POSTGRES_APP}." +make roundtrip apps="${POSTGRES_APP}" diff --git a/scripts/tests/environment/README.md b/scripts/tests/environment/README.md index d68dc4af9d..6f07af9028 100644 --- a/scripts/tests/environment/README.md +++ b/scripts/tests/environment/README.md @@ -16,10 +16,13 @@ The entry point is [00_orchestrator.sh](00_orchestrator.sh). | [04_bootstrap.sh](04_bootstrap.sh) | Bootstraps the development environment and starts the stack | | [05_commit.sh](05_commit.sh) | Validates pre-commit hook enforcement and `--no-verify` bypass | | [06_test.sh](06_test.sh) | Runs the full validation suite | -| [07_deploy_minimal.sh](07_deploy_minimal.sh) | Deploys on minimal hardware with service exclusion | -| [08_deploy_performance.sh](08_deploy_performance.sh) | Deploys the full application set on performance hardware | -| [09_deploy_reuse.sh](09_deploy_reuse.sh) | Redeploys reusing existing inventory and packages | +| [07_compose_minimal.sh](07_compose_minimal.sh) | Compose deploy on minimal hardware with service exclusion | +| [08_compose_performance.sh](08_compose_performance.sh) | Compose deploy of the full application set on performance hardware | +| [09_compose_reuse.sh](09_compose_reuse.sh) | Compose redeploy reusing existing inventory and packages | | [10_teardown.sh](10_teardown.sh) | Shuts down the stack and reverses environment changes | +| [11_console.sh](11_console.sh) | Smoke-tests the interactive console REPL | +| [12_swarm.sh](12_swarm.sh) | Swarm deploy of the MariaDB database role (svc-db-mariadb) | +| [13_roundtrip.sh](13_roundtrip.sh) | Compose+swarm roundtrip of the PostgreSQL database role (svc-db-postgres) | | [utils/common.sh](utils/common.sh) | Shared bootstrap, constants, and generic helpers (HTTP assertion, inventory inspection) | | [utils/cache.sh](utils/cache.sh) | Cache-stack assertions and probes (registry-cache, package-cache, DiD inner-build) | diff --git a/scripts/tests/environment/utils/cache.sh b/scripts/tests/environment/utils/cache.sh index ad8da69e30..74dedfc06e 100755 --- a/scripts/tests/environment/utils/cache.sh +++ b/scripts/tests/environment/utils/cache.sh @@ -6,7 +6,7 @@ # NOT exercise. # # This file is sourced ON TOP OF common.sh by callers that need cache -# checks (currently only 07_deploy_minimal.sh). +# checks. set -euo pipefail # Map runtime image to the Nexus proxy repo that proxies its system @@ -96,10 +96,6 @@ assert_caches_used() { local -a failures=() - # Package-cache assertion: cumulative proxy traffic must exist for - # the runtime's expected system-package proxy. Cumulative (not - # delta) because most apt/yum traffic happens during 01_install, - # well before this assertion fires. if [[ "${nexus_total_after}" -le 0 ]]; then failures+=("package-cache: no /repository// traffic ever observed (Nexus seems unused)") fi @@ -107,9 +103,6 @@ assert_caches_used() { failures+=("package-cache: expected proxy '${expected_proxy}' for ${DEV_RUNTIME_IMAGE} has no cached requests") fi - # Registry-cache assertion: the deploy itself must produce flow - # entries (HIT or MISS), since image pulls are part of the - # deploy. if [[ "${delta_registry}" -le 0 ]]; then failures+=("registry-cache: no HIT/MISS recorded during this deploy") fi @@ -131,10 +124,6 @@ assert_caches_used() { _resolve_fedora_release() { local image="${DEV_RUNTIME_IMAGE:-}" [[ -z "${image}" ]] && return 0 - # Override entrypoint to /bin/cat: Fedora's official container image - # defaults to bash, but pinning the entrypoint makes the call resilient - # against derivatives that ship a non-shell entrypoint. /etc/os-release - # is plain `KEY=VALUE`, awk lifts VERSION_ID with quotes stripped. docker run --rm --entrypoint /bin/cat "${image}" /etc/os-release 2>/dev/null | awk -F= '/^VERSION_ID=/ { gsub(/"/, "", $2); print $2; exit }' } @@ -186,12 +175,6 @@ probe_caches() { echo "[OK] package-cache: '${proxy_repo}' served '${upstream_path}'" fi - # Registry-cache (rpardini/docker-registry-proxy) is a transparent - # CONNECT proxy used by dockerd. It does not expose /v2/ directly; - # its only public HTTP endpoint is /ca.crt. A 200 there proves the - # cache container is alive and reachable via the proxy port. The - # AND-assertion against ``delta_registry > 0`` then confirms the - # deploy actually flowed through it. echo "[probe] registry-cache: GET /ca.crt" if ! docker exec infinito-registry-cache wget \ --quiet --tries=1 --timeout=10 \ @@ -219,12 +202,6 @@ probe_did_inner_build() { return 0 fi - # Compose derives the network name from the project name, which - # defaults to the host CWD basename: `infinito-nexus` locally, - # `infinito-nexus-core` in the CI fork, something else again in - # Act-runner workspaces or worktrees. Discover the network the - # frontend container is actually on instead of hardcoding it, so - # the probe stays correct regardless of how the repo is named. local network="${COMPOSE_NETWORK:-}" if [[ -z "${network}" ]]; then network="$(docker inspect -f \ @@ -249,10 +226,6 @@ probe_did_inner_build() { echo "[probe-did] docker build --add-host deb.debian.org:${frontend_ip}" \ "--network ${network} (apt-get update via frontend)" - # Force the classic builder: BuildKit rejects user-defined compose - # networks ("not supported by buildkit"). The classic builder - # accepts arbitrary `--network ` so we can put the build on - # the same network as the frontend container. if ! DOCKER_BUILDKIT=0 docker build --no-cache \ --network "${network}" \ --add-host "deb.debian.org:${frontend_ip}" \ diff --git a/scripts/tests/environment/utils/common.sh b/scripts/tests/environment/utils/common.sh index 76760122cb..0d462e5a09 100755 --- a/scripts/tests/environment/utils/common.sh +++ b/scripts/tests/environment/utils/common.sh @@ -7,11 +7,12 @@ set -euo pipefail DASHBOARD_APP="web-app-dashboard" MATOMO_APP="web-app-matomo" +MARIADB_APP="svc-db-mariadb" +POSTGRES_APP="svc-db-postgres" DASHBOARD_URL="https://dashboard.infinito.example" MATOMO_URL="https://matomo.infinito.example" -# These constants are part of the sourced interface consumed by sibling scripts. -: "${DASHBOARD_APP}" "${MATOMO_APP}" "${DASHBOARD_URL}" "${MATOMO_URL}" +: "${DASHBOARD_APP}" "${MATOMO_APP}" "${MARIADB_APP}" "${POSTGRES_APP}" "${DASHBOARD_URL}" "${MATOMO_URL}" UTILS_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" REPO_ROOT="$(cd "${UTILS_DIR}/../../../.." && pwd)"