Skip to content

Commit f1df1f5

Browse files
fix(tests): make the container lane work from the Makefile's cwd
Both bugs were invisible until CI ran the lane through its real entry point. The spike invoked hack/e2e-container-up.sh by hand from the repo root, and every path it needed happened to resolve from there. COMPOSE_FILE defaulted to a cwd-relative hack/e2e-compose.yaml, but the Makefile target runs from packages/core/testing, where no hack/ exists: open .../packages/core/testing/hack/e2e-compose.yaml: no such file Resolve it from the script's own location instead, so the Makefile path and a contributor running the script directly both work. The retry path then exposed the second one. compose interpolates the whole file before deciding what the subcommand needs, so the `${USERDATA:?}` guard that makes a missing machine config fail loudly on `up` also failed `down`, where no machine config is required: error while interpolating x-node.environment.USERDATA: required variable USERDATA is missing a value `|| true` swallowed that, so delete-cluster-container never removed anything and the nodes and their /var volumes would have survived into the next run -- the half-dead cluster the target exists to prevent. Pass a placeholder, which `down` never reads because it matches containers by project and service name, and keep the guard armed for `up`. Assisted-By: Claude <[email protected]> Signed-off-by: Myasnikov Daniil <[email protected]>
1 parent 0772de9 commit f1df1f5

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

‎hack/e2e-container-up.sh‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@
1717
set -eu
1818

1919
SANDBOX_NAME="${SANDBOX_NAME:?SANDBOX_NAME must be set (packages/core/testing/Makefile sets it)}"
20-
COMPOSE_FILE="${COMPOSE_FILE:-hack/e2e-compose.yaml}"
20+
# Resolved from this script's own location, not the caller's cwd: the Makefile
21+
# target runs it from packages/core/testing, where a relative hack/ does not
22+
# exist, while a contributor runs it from the repo root, where it does. Deriving
23+
# the root here makes both work and keeps the compose project name, the file and
24+
# the teardown in packages/core/testing/Makefile referring to the same thing.
25+
SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
26+
REPO_ROOT=$(CDPATH= cd -- "${SCRIPT_DIR}/.." && pwd)
27+
COMPOSE_FILE="${COMPOSE_FILE:-${REPO_ROOT}/hack/e2e-compose.yaml}"
2128
COMPOSE_PROJECT="${COMPOSE_PROJECT:-cozy-e2e}"
2229
# 60 GB is NOT enough: LINSTOR can place both tenant workers on one node, and
2330
# 2x20 GiB worker disks + 2x~21 GiB CDI import scratch + etcd is ~86 GiB. The

‎packages/core/testing/Makefile‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,15 @@ prepare-cluster-container:
5858
# Tear the container lane down. Volumes included: the node /var volumes hold
5959
# etcd and the kubelet state, so leaving them behind makes the next run adopt a
6060
# half-dead cluster instead of building a new one.
61+
# USERDATA is set to a placeholder because compose interpolates the whole file
62+
# before it decides what the subcommand needs, so the `${USERDATA:?}` guard that
63+
# makes a missing machine config fail loudly on `up` also fails `down`, where no
64+
# machine config is required. The value is never read: `down` matches containers
65+
# by project and service name. Without it teardown always errored, `|| true`
66+
# swallowed it, and the nodes and their /var volumes survived into the next run
67+
# -- the exact half-dead cluster this target exists to prevent.
6168
delete-cluster-container:
62-
docker compose -p cozy-e2e -f $(ROOT_DIR)hack/e2e-compose.yaml down -v || true
69+
USERDATA=teardown docker compose -p cozy-e2e -f $(ROOT_DIR)hack/e2e-compose.yaml down -v || true
6370

6471
# COZY_APISERVER_ENDPOINT crosses into the sandbox explicitly: docker exec
6572
# starts a fresh environment, so a value exported by the caller does not reach

0 commit comments

Comments
 (0)