|
1 | | -# Docker setup for cardano-node-tests (Antithesis/Moog) |
| 1 | +# Docker setup for cardano-node-tests (Antithesis) |
2 | 2 |
|
3 | | -This directory contains the driver image and compose file for submitting |
4 | | -`cardano-node-tests` to Antithesis via the Moog platform. |
| 3 | +This directory contains the driver image and compose files for submitting |
| 4 | +`cardano-node-tests` to Antithesis. |
5 | 5 |
|
6 | 6 | ## How it works |
7 | 7 |
|
8 | | -- `Dockerfile` — minimal image: configures Nix and copies the repo into |
9 | | - `/work/`. No binaries are pre-built; `regression.sh` handles all setup at |
10 | | - runtime via its own Nix shebang. Requires `GIT_REVISION` build arg (the |
11 | | - current commit hash) so pytest can identify the revision without a `.git` |
12 | | - directory inside the image. |
13 | | -- `docker-compose.yaml` — single `driver` service for Moog submission. |
| 8 | +Antithesis environments have **no internet access** at runtime, so all |
| 9 | +dependencies are baked into the image at build time: |
| 10 | + |
| 11 | +- `Dockerfile` — builds the driver image. At build time it: |
| 12 | + 1. Pre-builds `cardano-node`, `cardano-submit-api`, `cardano-cli`, and |
| 13 | + `bech32` from `NODE_REV` into `/opt/cardano/` via `nix build`. |
| 14 | + 2. Pre-warms the `testenv` dev shell and creates the Python venv at |
| 15 | + `/opt/tests-venv/` with all project dependencies installed. |
| 16 | + 3. Pre-warms the `base` dev shell so the `regression.sh` shebang resolves |
| 17 | + from the local nix store without network access. |
| 18 | + 4. Installs `antithesis_run.sh` as the Antithesis test driver at |
| 19 | + `/opt/antithesis/test/v1/quickstart/singleton_driver_regression.sh`. |
| 20 | + |
| 21 | +- `antithesis_run.sh` — container entrypoint that: |
| 22 | + 1. Forces nix into offline mode (`offline = true`). |
| 23 | + 2. Exports `CARDANO_PREBUILT_DIR=/opt/cardano` and `_VENV_DIR=/opt/tests-venv` |
| 24 | + so `regression.sh` skips all downloads and uses the pre-built artefacts. |
| 25 | + 3. Emits the Antithesis `setup_complete` lifecycle signal. |
| 26 | + 4. Hands off to `.github/regression.sh`. |
| 27 | + |
| 28 | +- `Dockerfile.config` — builds the Antithesis config image (`FROM scratch`) |
| 29 | + containing only `docker-compose.yaml`. |
| 30 | + |
| 31 | +- `docker-compose.yaml` — single `driver` service. |
14 | 32 |
|
15 | 33 | ## Workflow |
16 | 34 |
|
17 | | -### 1. Build and push the image |
| 35 | +### 1. Build and push the driver image |
18 | 36 |
|
19 | 37 | ```bash |
20 | 38 | docker build -f docker/Dockerfile \ |
21 | 39 | --build-arg GIT_REVISION=$(git rev-parse HEAD) \ |
| 40 | + --build-arg NODE_REV=master \ |
22 | 41 | -t ghcr.io/intersectmbo/cardano-node-tests-antithesis:latest . |
23 | 42 |
|
24 | 43 | docker push ghcr.io/intersectmbo/cardano-node-tests-antithesis:latest |
25 | 44 | ``` |
26 | 45 |
|
27 | | -### 2. Validate the compose locally |
| 46 | +`NODE_REV` is locked at build time — the same binaries are used every run |
| 47 | +regardless of what is on the `master` branch when the container starts. |
| 48 | + |
| 49 | +### 2. Build and push the config image |
| 50 | + |
| 51 | +```bash |
| 52 | +docker build -f docker/Dockerfile.config \ |
| 53 | + -t us-central1-docker.pkg.dev/<tenant>/antithesis/config:latest . |
| 54 | + |
| 55 | +docker push us-central1-docker.pkg.dev/<tenant>/antithesis/config:latest |
| 56 | +``` |
| 57 | + |
| 58 | +### 3. Validate locally (internet-connected build, isolated network at runtime) |
28 | 59 |
|
29 | 60 | ```bash |
30 | 61 | docker compose -f docker/docker-compose.yaml config |
31 | 62 | docker compose -f docker/docker-compose.yaml up --build |
32 | 63 | ``` |
33 | 64 |
|
34 | | -### 3. Submit to Moog |
| 65 | +To fully simulate the Antithesis no-internet constraint, run inside an |
| 66 | +isolated network namespace on Linux: |
35 | 67 |
|
36 | 68 | ```bash |
37 | | -moog requester create-test \ |
38 | | - --platform github \ |
39 | | - --username saratomaz \ |
40 | | - --repository IntersectMBO/cardano-node-tests \ |
41 | | - --directory ./docker \ |
42 | | - --commit $(git rev-parse HEAD) \ |
43 | | - --try 1 \ |
44 | | - --duration 2 |
| 69 | +unshare -n docker compose -f docker/docker-compose.yaml up |
45 | 70 | ``` |
46 | 71 |
|
47 | 72 | ## Environment variables |
48 | 73 |
|
| 74 | +`NODE_REV` is baked into the image at build time and must **not** be set at |
| 75 | +runtime. All other variables are passed through docker-compose as before. |
| 76 | + |
49 | 77 | | Variable | Default | Description | |
50 | 78 | |-------------------|------------|------------------------------------------| |
51 | | -| `NODE_REV` | `master` | cardano-node git revision | |
52 | 79 | | `CARDANO_CLI_REV` | (built-in) | cardano-cli revision, empty = use node's | |
53 | 80 | | `DBSYNC_REV` | (disabled) | db-sync revision, empty = disabled | |
54 | 81 | | `RUN_TARGET` | `tests` | `tests`, `testpr`, or `testnets` | |
|
0 commit comments