Skip to content

Commit 638d5ba

Browse files
Merge pull request #4911 from guardian/jsh/add-dev-commands
Add a dev command to boot the e2e stack without running tests
2 parents e16529b + db2c871 commit 638d5ba

21 files changed

Lines changed: 1688 additions & 642 deletions

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,3 @@ image-embedder-lambda/__tests__/embedder/test-data
4242
/e2e-tests/blob-report/
4343
/e2e-tests/playwright/.cache/
4444
/e2e-tests/playwright/.auth/
45-
46-
# Testcontainers global-setup artifacts
47-
/e2e-tests/.grid-urls.json

e2e-tests/README.md

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,37 @@ npm run test:ui # open browser and test suite, run tests at your leisure
4545
Traces are captured `on-first-retry` (see [`playwright.config.ts`](playwright.config.ts)),
4646
so a failed test on CI leaves a trace you can open with `npx playwright show-trace`.
4747

48-
## How they work
48+
## Running the stack without the tests
4949

50-
Playwright's `globalSetup` ([`global-setup.ts`](global-setup.ts)) uses
51-
[Testcontainers](https://testcontainers.com/) to stand up everything the tests need:
50+
`npm run dev:e2e` boots exactly the same stack the tests use, prints the service URLs and
51+
holds it open until you press Ctrl-C, which tears it all down.
5252

53-
1. a shared Docker network;
54-
2. **Elasticsearch** and **LocalStack** (the backing infrastructure);
55-
3. the **CloudFormation core stack** (`dev/cloudformation/grid-dev-core.yml`) and seeded
56-
buckets, provisioned into LocalStack;
57-
4. per-service config, generated by `dev/script/generate-config/service-config.js`;
58-
5. the Grid Docker image (either `grid-e2e-ci` or `grid-e2e-dev`) — a single container running Grid's Play services.
53+
```bash
54+
npm run dev:e2e # uses your local dev-nginx for the https://*.media.<domain> domains
55+
GRID_PROXY=true npm run dev:e2e # no dev-nginx? start the bundled Caddy proxy on :443 instead
56+
```
57+
58+
The stack binds fixed host ports, so two stacks cannot run
59+
at once. Starting a second one fails immediately rather than timing out.
60+
61+
### Running the tests against a stack you already started
62+
63+
The test commands reuse a running stack instead of booting their own, which turns a
64+
multi-minute boot into a couple of seconds. Leave `npm run dev:e2e` running in one
65+
terminal, then use `npm test`, `npm run test:ui` or any of the others as normal — they
66+
attach automatically and leave the stack running when they finish.
67+
68+
If only some services are up (usually because the stack is still booting), the run stops
69+
straight away and names the ports it is waiting on.
70+
71+
| Variable | Effect |
72+
| --- | --- |
73+
| `GRID_RESEED=true` | Reload the Elasticsearch fixtures into the reused stack. |
74+
75+
**Watch out for stale provisioning.** A reused stack picks up Scala changes (the repo is
76+
bind-mounted and services run under `sbt run`), but *not* changes to anything applied at
77+
boot: generated service config, the CloudFormation template, bucket contents, permissions
78+
or the Elasticsearch fixtures. After changing any of those, restart `dev:e2e`.
5979

60-
Elasticsearch is then seeded with image fixtures, and the resolved Kahuna base URL is
61-
exposed to the tests. `globalTeardown` stops everything and cleans up.
80+
Reuse also means state carries over between runs. The current suite is read-only, so this
81+
is harmless today, but a test that uploads or edits an image will want a fresh stack.

e2e-tests/global-setup.ts

Lines changed: 0 additions & 287 deletions
This file was deleted.

e2e-tests/global-teardown.ts

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)