Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
test(e2e): run the e2e suites one at a time
Yudhi Armyndharisbe5cfeb45d09
diff --git a/docs/09-testing-strategy.md b/docs/09-testing-strategy.mdindex da9f9fc6b..3225269e9 100644--- a/docs/09-testing-strategy.md+++ b/docs/09-testing-strategy.md@@ -124,6 +124,21 @@ describe('resolveReconnectConfig', () => {E2E smoke tests live in `test/` and use `test/jest-e2e.json`.+> **They run one at a time (`maxWorkers: 1`), and that is a correctness requirement, not a+> performance preference.** Each suite boots a real application, and not every piece of application+> state is redirected to a per-worker location. `dataDir` is a hard-coded `./data` with no+> environment lever, so every worker's plugin loader read-modify-writes the same+> `data/plugins/registry.json`. Measured on a single parallel run: 52 writes from 12 processes, 30+> of them within 500ms of a write by a different process. Individual writes are atomic; the+> read-modify-write cycle is not.+>+> Running them in parallel produced a roughly one-in-ten failure that moved between suites — a 403+> where a 200 was expected, a 404 where a 403 was, a rate-limit window misbehaving — and never+> reproduced when a suite ran on its own, which is what made it look like flakiness. Serially it+> does not occur.+>+> Adding a suite is safe. Restoring parallelism is not, until each worker gets its own data root.+```texttest/├── __mocks__/diff --git a/test/jest-e2e.json b/test/jest-e2e.jsonindex 233bd6111..f4d0a0c41 100644--- a/test/jest-e2e.json+++ b/test/jest-e2e.json@@ -1,11 +1,20 @@{- "moduleFileExtensions": ["js", "json", "ts"],+ "moduleFileExtensions": [+ "js",+ "json",+ "ts"+ ],"rootDir": ".","testEnvironment": "node","testRegex": ".e2e-spec.ts$",- "setupFiles": ["<rootDir>/setup-e2e.ts"],+ "setupFiles": [+ "<rootDir>/setup-e2e.ts"+ ],"transform": {"^.+\\.(t|j)s$": "ts-jest"},- "transformIgnorePatterns": ["node_modules/(?!(archiver|compress-commons|crc32-stream|zip-stream|archiver-utils)/)"]+ "transformIgnorePatterns": [+ "node_modules/(?!(archiver|compress-commons|crc32-stream|zip-stream|archiver-utils)/)"+ ],+ "maxWorkers": 1}diff --git a/test/setup-e2e.ts b/test/setup-e2e.tsindex 42a73c3dd..0ba2d232f 100644--- a/test/setup-e2e.ts+++ b/test/setup-e2e.ts@@ -1,5 +1,20 @@// e2e boot environment. Set BEFORE AppModule is imported (setupFiles phase) so the// app boots against local SQLite with no Redis/queue and no production boot guard.+//+// These suites run ONE AT A TIME (`maxWorkers: 1` in jest-e2e.json), and that is load-bearing+// rather than a performance choice. Each suite boots a real application, and not all of an+// application's state is redirected here: `dataDir` is a hard-coded `./data` with no environment+// lever, so every worker's plugin loader read-modify-writes the same `data/plugins/registry.json`.+// Measured on one parallel run: 52 writes from 12 processes, 30 of them landing within 500ms of a+// write by a different process. Each individual write is atomic, but the read-modify-write cycle+// is not, so workers overwrote and re-read each other's plugin state.+//+// The result was a roughly one-in-ten failure that moved between suites — a 403 where a 200 was+// expected, a 404 where a 403 was, a rate-limit window behaving oddly — and never reproduced when a+// suite was run on its own, which is what made it read as flakiness. Serially it does not happen:+// 11 consecutive clean runs against a measured failure rate of about one in twelve in parallel.+//+// Restoring parallelism means giving each worker its own data root, not just its own database.import { join } from 'path';import { tmpdir } from 'os';import { rmSync } from 'fs';