@antelopejs/dms 0.24.3 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,32 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.25.0
4
+
5
+ [compare changes](https://github.com/AntelopeJS/dms/compare/v0.24.3...v0.25.0)
6
+
7
+ ### 🔥 Performance
8
+
9
+ - **dms:** Run two e2e workers per shard, each on a run of its own ([#1286](https://github.com/AntelopeJS/dms/pull/1286))
10
+
11
+ ### 🩹 Fixes
12
+
13
+ - **dms:** Keep the e2e kit's mongod off the run's reserved ports ([#1285](https://github.com/AntelopeJS/dms/pull/1285))
14
+ - **ci:** Run every job on Blacksmith, gate the hand-written jobs and sync tooling-configs 0.10.12 ([#1289](https://github.com/AntelopeJS/dms/pull/1289))
15
+
16
+ ### 🏡 Chore
17
+
18
+ - **deps:** Update dependency @types/chai to v5 ([#1294](https://github.com/AntelopeJS/dms/pull/1294))
19
+ - **deps:** Update dependency @types/jsdom to v30 ([#1295](https://github.com/AntelopeJS/dms/pull/1295))
20
+ - **deps:** Update dependency @unhead/vue to v3 ([#1296](https://github.com/AntelopeJS/dms/pull/1296))
21
+
22
+ #### ⚠️ Breaking Changes
23
+
24
+ - **dms:** Run two e2e workers per shard, each on a run of its own ([#1286](https://github.com/AntelopeJS/dms/pull/1286))
25
+
26
+ ### ❤️ Contributors
27
+
28
+ - Antony Rizzitelli
29
+
3
30
  ## v0.24.3
4
31
 
5
32
  [compare changes](https://github.com/AntelopeJS/dms/compare/v0.24.2...v0.24.3)
package/E2E.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # The e2e kit
2
2
 
3
- `@antelopejs/dms/e2e` is a Playwright setup for a DMS repository. The global setup of its config prepares the playground and starts one run for the whole invocation: a copy of the playground on free ports, its own MongoDB, a mail sink and the built dashboard. It stops the run after the last test. A spec is ordinary Playwright: it imports `test` and `expect` from the kit, and its fixtures give it a fresh database, an administrator and the run's dashboard as `baseURL`. `registerJourneys()` turns the journeys of `e2e/journeys/` into tests on the same fixtures.
3
+ `@antelopejs/dms/e2e` is a Playwright setup for a DMS repository. The global setup of its config prepares the playground and starts a run for each worker for the whole invocation: a copy of the playground on free ports, its own MongoDB, a mail sink and the built dashboard. It stops the runs after the last test. A spec is ordinary Playwright: it imports `test` and `expect` from the kit, and its fixtures give it a fresh database, an administrator and the run's dashboard as `baseURL`. `registerJourneys()` turns the journeys of `e2e/journeys/` into tests on the same fixtures.
4
4
 
5
5
  ## Configure a suite
6
6
 
@@ -50,7 +50,7 @@ Each `*.mjs` file of `e2e/journeys/` is a feature, named after the file, and exp
50
50
 
51
51
  `registerJourneys()` reads both from the config that loaded it.
52
52
 
53
- The tests of a suite run one at a time against its run, the files in alphabetical order. `registerJourneys()` registers the journeys of the config's `smoke` feature first, then the other features in alphabetical order, then every journey marked `last`, so `--grep @smoke` runs the `smoke` journey before the other journeys. Name the journeys file so that it sorts after the specs (`zz-journeys.spec.ts`): a journey marked `last` changes the playground for the backends that follow, and a spec that sorts after it cannot start its backend. `--shard=i/N` splits a suite across machines, each with a run of its own.
53
+ A suite runs on two workers. The global setup starts a run for each, with its own playground copy, ports, MongoDB, mail sink, backends and dashboard, and each worker runs its tests one at a time against its own run, taking the next test in order, the files in alphabetical order. `--workers=N` starts N runs. With `DMS_E2E_RUN`, the suite runs on one worker. A config that starts a `webServer`, such as a mock of an outside API, shares it between the workers, so the global setup refuses more than one: set `workers: 1` with `defineConfig(e2eConfig(), { workers: 1, webServer })`. `registerJourneys()` registers the journeys of the config's `smoke` feature first, then the other features in alphabetical order, then every journey marked `last`, so `--grep @smoke` runs the `smoke` journey before the other journeys. Name the journeys file so that it sorts after the specs (`zz-journeys.spec.ts`): a journey marked `last` changes the playground of its worker's run for the backends that follow, and a spec that sorts after it on that worker cannot start its backend. `--shard=i/N` splits a suite across machines, each with a run of its own.
54
54
 
55
55
  ## Write a spec
56
56
 
@@ -67,7 +67,7 @@ test("the administrator opens the members page", async ({ adminPage }) => {
67
67
 
68
68
  The fixtures:
69
69
 
70
- - `run`: the run of the global setup, shared by a worker: its `webUrl`, `apiUrl`, `accounts` and `evidence` folder.
70
+ - `run`: the run the global setup started for the worker, which only its tests drive: its `webUrl`, `apiUrl`, `accounts` and `evidence` folder.
71
71
  - `baseURL`: the run's dashboard, so `page.goto("/settings")` opens it.
72
72
  - `dms`: the test's journey context. Before the test, it prepares the run as a journey's run does: a fresh database with a backend of its own, and an onboarded administrator. The test drives the run through it: `dms.tab(account)`, `dms.api(label, request)`, `dms.mail(accept)`, `dms.email(name)`, `dms.unique(prefix)` and `dms.verify(label, checks)`. After the test, it closes the tabs, judges the `verify` steps, and replays them into the report. A failing step attaches its screenshot and ARIA snapshot, and a failed test attaches the backend's log. The evidence goes to `<run>/evidence/<feature>/<test>/`. A test whose preparation fails does not run.
73
73
  - `adminPage`: a tab of `dms` that the administrator signed in on.
@@ -120,6 +120,7 @@ test("the administrator reads the onboarding state", async () => {
120
120
  - `DMS_E2E_RUN=<run folder>`: the tests drive that run, such as one `startRun` started, and the suite stops nothing. A run whose dashboard is not served the way the suite asks is refused.
121
121
  - `DMS_E2E_RUNS`: the folder the run folders go to.
122
122
  - `DMS_E2E_NO_STANDBY=1`: each fresh database's backend starts when the test needs it, rather than one ahead.
123
+ - `DMS_E2E_SHUFFLE=<seed>`: `registerJourneys()` registers the journeys not marked `last` in an order drawn from the seed, the same for the same seed, and the `last` ones after them. A suite that passes under several seeds holds no journey that depends on another's state.
123
124
 
124
125
  ## Port recipe
125
126
 
package/README.md CHANGED
@@ -87,9 +87,9 @@ export class SalesPage extends PageController("sales", {
87
87
  | `@antelopejs/interface-database` | `>=0.4.3 <0.5.0` | `0.4.3` |
88
88
  | `@antelopejs/interface-database-catalog` | `>=0.1.1 <0.2.0` | `0.1.1` |
89
89
  | `@antelopejs/interface-database-decorators` | `>=0.5.4 <0.6.0` | `0.5.4` |
90
- | `@antelopejs/interface-dms` | `^0.17.2` | `0.17.2` |
90
+ | `@antelopejs/interface-dms` | `^0.17.3` | `0.17.3` |
91
91
  | `@antelopejs/interface-dms-automation` | `>=0.7.0 <0.8.0` | `0.7.2` |
92
- | `@antelopejs/interface-dms-builder` | `^0.6.3` | `0.6.3` |
92
+ | `@antelopejs/interface-dms-builder` | `^0.6.4` | `0.6.4` |
93
93
  | `@antelopejs/interface-email` | `>=0.2.1 <0.3.0` | `0.2.1` |
94
94
  | `@antelopejs/interface-file-storage` | `>=0.1.4 <0.2.0` | `0.1.9` |
95
95
  | `@antelopejs/interface-redis` | `>=0.0.9 <0.1.0` | `0.0.11` |
@@ -19,7 +19,7 @@ export type Suite = import("./suite.mjs").Suite;
19
19
  */
20
20
  export type DmsOptions = import("./test-journey.mjs").DmsOptions;
21
21
  /**
22
- * What a worker shares: the suite its config declared, the run its global setup started, and the journeys config of the suite
22
+ * What a worker shares: the suite its config declared, the run its global setup started for it, and the journeys config of the suite
23
23
  */
24
24
  export type DmsWorkerFixtures = {
25
25
  dmsSuite: Suite;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Refuses a dashboard that did not bind its port: another server answered the
3
+ * readiness probe in its place.
4
+ *
5
+ * @param {{ log: string }} frontend The dashboard's process record
6
+ * @throws When its log says its port is already in use
7
+ */
8
+ export function assertFrontendBound(frontend: {
9
+ log: string;
10
+ }): void;
@@ -1,27 +1,32 @@
1
1
  /**
2
2
  * Playwright's global setup of a journeys suite, once per `playwright test`.
3
3
  * With `DMS_E2E_RUN` set, the tests drive that run and it stops nothing; a
4
- * run whose dashboard is not served the way the suite asks is refused.
5
- * Otherwise it starts a run on the journeys config through `startRun`: its
6
- * prepare commands (none with `DMS_E2E_PREBUILT=1`), then the
7
- * stack, whose dashboard is the development one for a `frontend: "dev"`
8
- * suite. It publishes the run's folder in `DMS_E2E_RUN` for the workers,
9
- * and returns the teardown that stops it.
10
- * The run outlives the worker Playwright replaces after a failed test.
4
+ * run whose dashboard is not served the way the suite asks is refused, and
5
+ * so are several workers, which would share it. Several workers are refused
6
+ * too when the config starts a `webServer`, a server every worker would
7
+ * share, such as a mock of an outside API. Otherwise it starts one run
8
+ * per worker through `startRuns`: the journeys config's prepare commands
9
+ * (none with `DMS_E2E_PREBUILT=1`), then the stacks, whose dashboard is the
10
+ * development one for a `frontend: "dev"` suite. It publishes the runs'
11
+ * folders in `DMS_E2E_LANES` for the workers, and returns the teardown that
12
+ * stops them. A run outlives the worker Playwright replaces after a failed
13
+ * test, and the replacement drives the same run.
11
14
  *
12
- * @returns {Promise<(() => Promise<void>) | undefined>} The teardown of the run it started
13
- * @throws When the adopted run serves its dashboard another way than the suite asks
15
+ * @param {Pick<import("@playwright/test").FullConfig, "workers" | "webServer">} config The resolved config
16
+ * @returns {Promise<(() => Promise<void>) | undefined>} The teardown of the runs it started
17
+ * @throws When the adopted run serves its dashboard another way than the suite asks, or several workers would share it or the config's `webServer`
14
18
  */
15
- export default function globalSetup(): Promise<(() => Promise<void>) | undefined>;
19
+ export default function globalSetup({ workers, webServer }: Pick<import("@playwright/test").FullConfig, "workers" | "webServer">): Promise<(() => Promise<void>) | undefined>;
16
20
  /**
17
- * The run this `playwright test` drives, which its global setup published.
18
- * A worker reads it once: tests run one at a time, each saves the run when
19
- * it ends, and the worker Playwright starts after a failed test reads it
20
- * again.
21
+ * The run the worker of `lane` drives, which the global setup published. A
22
+ * worker reads it once: its tests run one at a time, each saves the run
23
+ * when it ends, and the worker Playwright starts in its place after a
24
+ * failed test reads it again.
21
25
  *
22
26
  * @param {Suite} suite The suite that drives it
27
+ * @param {number} lane The worker's `parallelIndex`
23
28
  * @returns {import("./run-state.mjs").RunState} The run
24
- * @throws When no global setup published a run, an older e2e kit started it, or it serves its dashboard another way than the suite asks
29
+ * @throws When no global setup published a run for the lane, an older e2e kit started it, or it serves its dashboard another way than the suite asks
25
30
  */
26
- export function currentRun(suite: Suite): import("./run-state.mjs").RunState;
31
+ export function currentRun(suite: Suite, lane: number): import("./run-state.mjs").RunState;
27
32
  export type Suite = import("./suite.mjs").Suite;
@@ -1,7 +1,8 @@
1
1
  /**
2
- * The Playwright config of a suite: one worker against the run its global
3
- * setup starts (parallelism comes from `--shard`), no retries, a test
4
- * timeout above the kit's own waits, and the CI reporters. It is plain
2
+ * The Playwright config of a suite: two workers, each against a run of its
3
+ * own that the global setup starts (one worker when `DMS_E2E_RUN` names
4
+ * the run to drive), no retries, a test timeout above the kit's own waits,
5
+ * and the CI reporters. It is plain
5
6
  * Playwright config, so `defineConfig(e2eConfig(), overrides)` adjusts it.
6
7
  * The suite's journeys come from `e2e/journeys.config.ts` and
7
8
  * `e2e/journeys/`, or the journeys config `config` names and the
@@ -19,7 +20,8 @@ export function e2eConfig(options?: SuiteOptions): import("@playwright/test").Pl
19
20
  * Registers the journeys of the suite its config declared: those of the
20
21
  * journeys config that its `frontend` serves, the config's `smoke`
21
22
  * feature first, then the other features in order, and those marked
22
- * `last` after all others. One test per journey, named by its id under its
23
+ * `last` after all others; with `DMS_E2E_SHUFFLE` set, the journeys not
24
+ * marked `last` in the order its seed draws. One test per journey, named by its id under its
23
25
  * feature's name, with the
24
26
  * journey's `tag` and its title and entry point as annotations. Each test
25
27
  * drives its journey through the `dms` fixture, prepared with the
@@ -27,7 +27,7 @@ export function mongodBinary(from: string[]): Promise<string>;
27
27
  * every other process the kit starts does, since Windows runs no script
28
28
  * by its path alone.
29
29
  *
30
- * @param {{ mongo: string, logs: string }} paths The run's folders
30
+ * @param {{ mongo: string, logs: string, apiPort?: number, webPort?: number, smtpPort?: number, processes?: ReadonlyArray<{ port?: number }> }} paths The run's folders, or the run, whose reserved ports the mongod does not take
31
31
  * @param {string[]} from Folders to resolve mongodb-memory-server-core from
32
32
  * @param {import("./processes.mjs").RestartablePort} [port] The port, which a restart keeps so the backend's URL still reaches it, so it must be one {@link restartablePort} gave
33
33
  * @returns {Promise<{ url: string, record: ReturnType<typeof startDetached> & { port: import("./processes.mjs").RestartablePort } }>} Its URL and process record
@@ -35,6 +35,12 @@ export function mongodBinary(from: string[]): Promise<string>;
35
35
  export function startMongod(paths: {
36
36
  mongo: string;
37
37
  logs: string;
38
+ apiPort?: number;
39
+ webPort?: number;
40
+ smtpPort?: number;
41
+ processes?: ReadonlyArray<{
42
+ port?: number;
43
+ }>;
38
44
  }, from: string[], port?: import("./processes.mjs").RestartablePort): Promise<{
39
45
  url: string;
40
46
  record: ReturnType<typeof startDetached> & {
@@ -1,9 +1,10 @@
1
1
  /**
2
- * Asks the kernel for a free TCP port on the loopback interface.
2
+ * Asks the kernel for a free loopback port outside `exclude`.
3
3
  *
4
+ * @param {Iterable<number>} [exclude] Skipped ports
4
5
  * @returns {Promise<number>} The port
5
6
  */
6
- export function freePort(): Promise<number>;
7
+ export function freePort(exclude?: Iterable<number>): Promise<number>;
7
8
  /**
8
9
  * @typedef {number & { readonly restartable: true }} RestartablePort A loopback port outside the kernel's ephemeral range, or any port where /proc does not tell the range. A function that takes one refuses a port from {@link freePort}, which a restart can fail to listen on again.
9
10
  */
@@ -13,16 +14,17 @@ export function freePort(): Promise<number>;
13
14
  */
14
15
  export function isRestartablePort(port: number): port is RestartablePort;
15
16
  /**
16
- * A free loopback port outside the kernel's ephemeral range, for a server
17
+ * A free loopback port outside the ephemeral range and `exclude` for a server
17
18
  * that must listen on the same port again after it restarts. No outgoing
18
19
  * connection takes such a port as its source port, so none can hold it in
19
20
  * TIME_WAIT and make that listen fail with `EADDRINUSE`, as a port from
20
21
  * {@link freePort} can be held.
21
22
  *
23
+ * @param {Iterable<number>} [exclude] Skipped ports
22
24
  * @returns {Promise<RestartablePort>} The port
23
- * @throws When no unprivileged port outside the range is free
25
+ * @throws When none is free
24
26
  */
25
- export function restartablePort(): Promise<RestartablePort>;
27
+ export function restartablePort(exclude?: Iterable<number>): Promise<RestartablePort>;
26
28
  /**
27
29
  * Starts a long-running program in its own process group, its output going
28
30
  * straight to `<logs>/<name>.log` so it survives the caller. The record
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The ports a run holds or has reserved: its API, dashboard and mail ports
3
+ * and the port of every process it recorded.
4
+ *
5
+ * @param {{ apiPort?: number, webPort?: number, smtpPort?: number, processes?: ReadonlyArray<{ port?: number }> }} run The run, or the folders of one
6
+ * @returns {number[]} The ports a new server must not take
7
+ */
8
+ export function reservedPorts(run: {
9
+ apiPort?: number;
10
+ webPort?: number;
11
+ smtpPort?: number;
12
+ processes?: ReadonlyArray<{
13
+ port?: number;
14
+ }>;
15
+ }): number[];
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * A `node_modules` that is `modules` with `@antelopejs/dms-frontend` replaced
3
- * by the renderer checkout, every other entry linked to the original.
3
+ * by the renderer checkout and no `.cache`, every other entry linked to the
4
+ * original.
4
5
  *
5
6
  * @param {string} modules The playground's installed modules
6
7
  * @param {string} shadow The run's `node_modules`
@@ -12,9 +13,10 @@ export function linkRenderer(modules: string, shadow: string, renderer: string):
12
13
  * the playground, every sibling is linked, so relative paths such as a
13
14
  * tsconfig `extends` resolve as in the checkout. The playground itself is
14
15
  * copied without its installed modules and build, so `.antelope/` and the
15
- * frontend build belong to the run. Its `node_modules` is the playground's,
16
- * except that `@antelopejs/dms-frontend` is the `renderer` checkout when
17
- * there is one.
16
+ * frontend build belong to the run. Its `node_modules` links every entry of
17
+ * the playground's but `.cache`, where a backend writes its MCP credential
18
+ * and its packed modules, so that folder belongs to the run too; and
19
+ * `@antelopejs/dms-frontend` is the `renderer` checkout when there is one.
18
20
  *
19
21
  * @param {string} playground The playground folder
20
22
  * @param {string} checkout The checkout root, or the module folder outside one
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @typedef {import("./run-state.mjs").RunState} RunState A running DMS: its `apiUrl`, `webUrl`, `accounts`, `secrets` and `evidence` folder
3
+ * @typedef {import("./start.mjs").RunOptions} RunOptions How a test starts a run
4
+ * @typedef {{ run: RunState, stop: () => Promise<void> }} StartedRun A ready run, and what stops it
5
+ */
1
6
  /**
2
7
  * Starts a run of the checkout's playground, as the global setup of a
3
8
  * Playwright suite does, for any test runner: a copy of the playground on
@@ -32,6 +32,25 @@ export function targetOf(options: Pick<StartOptions, "playground" | "renderer" |
32
32
  * @returns {Promise<import("./run-state.mjs").RunState>} The ready run
33
33
  */
34
34
  export function startStack(options: StartOptions, cwd: string): Promise<import("./run-state.mjs").RunState>;
35
+ /**
36
+ * Starts `count` runs of the checkout's playground, each with its own
37
+ * playground copy, ports, MongoDB, mail sink, backends and dashboard, for
38
+ * the workers of one suite to drive one each. The first runs the journeys
39
+ * config's prepare commands as `options` asks; the others start once it is
40
+ * ready, together, without them, so their dashboards come from the build
41
+ * cache the first one filled. `stop` stops them all, and from the moment
42
+ * the first is ready a SIGINT or SIGTERM to this process stops every run
43
+ * started so far, then ends the process by that signal.
44
+ *
45
+ * @param {RunOptions} options How to start them
46
+ * @param {number} count How many, at least 1
47
+ * @returns {Promise<{ runs: import("./run-state.mjs").RunState[], stop: () => Promise<void> }>} The ready runs, and what stops them
48
+ * @throws When a run fails to start; every run it started is stopped first
49
+ */
50
+ export function startRuns(options: RunOptions, count: number): Promise<{
51
+ runs: import("./run-state.mjs").RunState[];
52
+ stop: () => Promise<void>;
53
+ }>;
35
54
  /**
36
55
  * How to start a run: `config` is the absolute path of a journeys config file, `prepare` first runs the journeys config's install and build commands, `playground` and `renderer` win over the journeys config, and `noStandby` is also on with `DMS_E2E_NO_STANDBY=1`
37
56
  */
@@ -17,18 +17,21 @@ export function declaredSuite(): Suite;
17
17
  * The journeys a suite runs: those of the `smoke` feature first, then the
18
18
  * others in the order of their features, and those marked `last` after all
19
19
  * others. A `frontend: "dev"` suite runs the journeys that ask for the
20
- * development dashboard, any other the rest.
20
+ * development dashboard, any other the rest. With `seed`, the journeys not
21
+ * marked `last` run in an order drawn from it instead, the same for the
22
+ * same seed, and the `last` ones still after them in their own order.
21
23
  *
22
24
  * @param {{ name: string, journeys: Journey[] }[]} features The features and their journeys
23
25
  * @param {Suite["frontend"]} frontend How the suite's run serves its dashboard
24
26
  * @param {string} smoke The feature whose journeys run first, the journeys config's `smoke`
27
+ * @param {string} [seed] What draws the order, `DMS_E2E_SHUFFLE`
25
28
  * @returns {{ feature: string, journey: Journey }[]} The journeys, each with its feature
26
29
  * @throws When two journeys share an id
27
30
  */
28
31
  export function suiteJourneys(features: {
29
32
  name: string;
30
33
  journeys: Journey[];
31
- }[], frontend: Suite["frontend"], smoke: string): {
34
+ }[], frontend: Suite["frontend"], smoke: string, seed?: string): {
32
35
  feature: string;
33
36
  journey: Journey;
34
37
  }[];
package/e2e/fixtures.mjs CHANGED
@@ -10,7 +10,7 @@ import { loadSuiteConfig } from "./journeys-config.mjs";
10
10
  /**
11
11
  * @typedef {import("./suite.mjs").Suite} Suite
12
12
  * @typedef {import("./test-journey.mjs").DmsOptions} DmsOptions How the `dms` fixture prepares a test
13
- * @typedef {{ dmsSuite: Suite, run: import("./run-state.mjs").RunState, journeysConfig: import("./journeys-config.mjs").SuiteConfig }} DmsWorkerFixtures What a worker shares: the suite its config declared, the run its global setup started, and the journeys config of the suite
13
+ * @typedef {{ dmsSuite: Suite, run: import("./run-state.mjs").RunState, journeysConfig: import("./journeys-config.mjs").SuiteConfig }} DmsWorkerFixtures What a worker shares: the suite its config declared, the run its global setup started for it, and the journeys config of the suite
14
14
  * @typedef {{ dmsOptions: DmsOptions, dms: import("./journey.mjs").JourneyContext, adminPage: import("@playwright/test").Page }} DmsTestFixtures What one test gets: its options, the journey context it drives the run through, and a page the administrator signed in on
15
15
  * @typedef {import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions} PlaywrightTestFixtures The fixtures Playwright gives a test
16
16
  * @typedef {import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions} PlaywrightWorkerFixtures The fixtures Playwright gives a worker
@@ -93,8 +93,8 @@ async function report(result, state, testInfo) {
93
93
  const FIXTURES = {
94
94
  dmsSuite: [UNDECLARED_SUITE, { option: true, scope: "worker" }],
95
95
  run: [
96
- async ({ dmsSuite }, use) => {
97
- await use(currentRun(dmsSuite));
96
+ async ({ dmsSuite }, use, workerInfo) => {
97
+ await use(currentRun(dmsSuite, workerInfo.parallelIndex));
98
98
  },
99
99
  { scope: "worker" },
100
100
  ],
@@ -0,0 +1,16 @@
1
+ import { existsSync, readFileSync } from "node:fs";
2
+
3
+ /**
4
+ * Refuses a dashboard that did not bind its port: another server answered the
5
+ * readiness probe in its place.
6
+ *
7
+ * @param {{ log: string }} frontend The dashboard's process record
8
+ * @throws When its log says its port is already in use
9
+ */
10
+ export function assertFrontendBound(frontend) {
11
+ const log = existsSync(frontend.log)
12
+ ? readFileSync(frontend.log, "utf8")
13
+ : "";
14
+ const refusal = /Port \d+ is already in use/.exec(log);
15
+ if (refusal) throw new Error(`${refusal[0]}; see ${frontend.log}`);
16
+ }
@@ -1,38 +1,56 @@
1
1
  import { assertForwardedRun } from "./backend.mjs";
2
2
  import { declaredSuite } from "./suite.mjs";
3
+ import { arrayOf, decode, isString } from "./json.mjs";
3
4
  import { loadRun } from "./run-state.mjs";
4
- import { startRun } from "./run.mjs";
5
+ import { startRuns } from "./start.mjs";
5
6
 
6
7
  /** @typedef {import("./suite.mjs").Suite} Suite */
7
8
 
8
9
  const RUN = "DMS_E2E_RUN";
10
+ const LANES = "DMS_E2E_LANES";
11
+ const isLanes = arrayOf(isString);
9
12
 
10
13
  /**
11
14
  * Playwright's global setup of a journeys suite, once per `playwright test`.
12
15
  * With `DMS_E2E_RUN` set, the tests drive that run and it stops nothing; a
13
- * run whose dashboard is not served the way the suite asks is refused.
14
- * Otherwise it starts a run on the journeys config through `startRun`: its
15
- * prepare commands (none with `DMS_E2E_PREBUILT=1`), then the
16
- * stack, whose dashboard is the development one for a `frontend: "dev"`
17
- * suite. It publishes the run's folder in `DMS_E2E_RUN` for the workers,
18
- * and returns the teardown that stops it.
19
- * The run outlives the worker Playwright replaces after a failed test.
16
+ * run whose dashboard is not served the way the suite asks is refused, and
17
+ * so are several workers, which would share it. Several workers are refused
18
+ * too when the config starts a `webServer`, a server every worker would
19
+ * share, such as a mock of an outside API. Otherwise it starts one run
20
+ * per worker through `startRuns`: the journeys config's prepare commands
21
+ * (none with `DMS_E2E_PREBUILT=1`), then the stacks, whose dashboard is the
22
+ * development one for a `frontend: "dev"` suite. It publishes the runs'
23
+ * folders in `DMS_E2E_LANES` for the workers, and returns the teardown that
24
+ * stops them. A run outlives the worker Playwright replaces after a failed
25
+ * test, and the replacement drives the same run.
20
26
  *
21
- * @returns {Promise<(() => Promise<void>) | undefined>} The teardown of the run it started
22
- * @throws When the adopted run serves its dashboard another way than the suite asks
27
+ * @param {Pick<import("@playwright/test").FullConfig, "workers" | "webServer">} config The resolved config
28
+ * @returns {Promise<(() => Promise<void>) | undefined>} The teardown of the runs it started
29
+ * @throws When the adopted run serves its dashboard another way than the suite asks, or several workers would share it or the config's `webServer`
23
30
  */
24
- export default async function globalSetup() {
31
+ export default async function globalSetup({ workers, webServer }) {
25
32
  const suite = declaredSuite();
33
+ if (workers > 1 && webServer) {
34
+ throw new Error(
35
+ `the config's webServer is one server that ${workers} workers would share: set workers: 1 in the suite's config`,
36
+ );
37
+ }
26
38
  const adopted = process.env[RUN];
27
39
  if (adopted) {
40
+ if (workers > 1) {
41
+ throw new Error(
42
+ `${RUN} names one run, which ${workers} workers would share: run the suite with --workers=1`,
43
+ );
44
+ }
28
45
  assertServes(loadRun(adopted), suite);
46
+ process.env[LANES] = JSON.stringify([adopted]);
29
47
  return undefined;
30
48
  }
31
- const { run, stop } = await startRun({
32
- config: suite.config,
33
- frontend: suite.frontend,
34
- });
35
- process.env[RUN] = run.dir;
49
+ const { runs, stop } = await startRuns(
50
+ { config: suite.config, frontend: suite.frontend },
51
+ workers,
52
+ );
53
+ process.env[LANES] = JSON.stringify(runs.map((run) => run.dir));
36
54
  return stop;
37
55
  }
38
56
 
@@ -51,20 +69,28 @@ function assertServes(state, suite) {
51
69
  }
52
70
 
53
71
  /**
54
- * The run this `playwright test` drives, which its global setup published.
55
- * A worker reads it once: tests run one at a time, each saves the run when
56
- * it ends, and the worker Playwright starts after a failed test reads it
57
- * again.
72
+ * The run the worker of `lane` drives, which the global setup published. A
73
+ * worker reads it once: its tests run one at a time, each saves the run
74
+ * when it ends, and the worker Playwright starts in its place after a
75
+ * failed test reads it again.
58
76
  *
59
77
  * @param {Suite} suite The suite that drives it
78
+ * @param {number} lane The worker's `parallelIndex`
60
79
  * @returns {import("./run-state.mjs").RunState} The run
61
- * @throws When no global setup published a run, an older e2e kit started it, or it serves its dashboard another way than the suite asks
80
+ * @throws When no global setup published a run for the lane, an older e2e kit started it, or it serves its dashboard another way than the suite asks
62
81
  */
63
- export function currentRun(suite) {
64
- const dir = process.env[RUN];
65
- if (!dir) {
82
+ export function currentRun(suite, lane) {
83
+ const recorded = process.env[LANES];
84
+ if (!recorded) {
85
+ throw new Error(
86
+ `${LANES} is not set: run the suite through its config, whose global setup starts its runs`,
87
+ );
88
+ }
89
+ const lanes = decode(isLanes, JSON.parse(recorded), LANES, "run folders");
90
+ const dir = lanes[lane];
91
+ if (dir === undefined) {
66
92
  throw new Error(
67
- `${RUN} is not set: run the suite through its config, whose global setup starts a run, or set it to a run startRun started`,
93
+ `worker ${lane} has no run: the global setup started ${lanes.length}`,
68
94
  );
69
95
  }
70
96
  const state = loadRun(dir);
package/e2e/index.mjs CHANGED
@@ -17,11 +17,13 @@ export * from "./fixtures.mjs";
17
17
 
18
18
  const MINUTE = 60_000;
19
19
  const CI = Boolean(process.env.CI);
20
+ const WORKERS = 2;
20
21
 
21
22
  /**
22
- * The Playwright config of a suite: one worker against the run its global
23
- * setup starts (parallelism comes from `--shard`), no retries, a test
24
- * timeout above the kit's own waits, and the CI reporters. It is plain
23
+ * The Playwright config of a suite: two workers, each against a run of its
24
+ * own that the global setup starts (one worker when `DMS_E2E_RUN` names
25
+ * the run to drive), no retries, a test timeout above the kit's own waits,
26
+ * and the CI reporters. It is plain
25
27
  * Playwright config, so `defineConfig(e2eConfig(), overrides)` adjusts it.
26
28
  * The suite's journeys come from `e2e/journeys.config.ts` and
27
29
  * `e2e/journeys/`, or the journeys config `config` names and the
@@ -42,7 +44,7 @@ export function e2eConfig(options = {}) {
42
44
  testMatch: /\.spec\.ts$/,
43
45
  outputDir: `test-results${suffix}`,
44
46
  fullyParallel: true,
45
- workers: 1,
47
+ workers: process.env.DMS_E2E_RUN ? 1 : WORKERS,
46
48
  retries: 0,
47
49
  forbidOnly: CI,
48
50
  timeout: 15 * MINUTE,
@@ -67,7 +69,8 @@ export function e2eConfig(options = {}) {
67
69
  * Registers the journeys of the suite its config declared: those of the
68
70
  * journeys config that its `frontend` serves, the config's `smoke`
69
71
  * feature first, then the other features in order, and those marked
70
- * `last` after all others. One test per journey, named by its id under its
72
+ * `last` after all others; with `DMS_E2E_SHUFFLE` set, the journeys not
73
+ * marked `last` in the order its seed draws. One test per journey, named by its id under its
71
74
  * feature's name, with the
72
75
  * journey's `tag` and its title and entry point as annotations. Each test
73
76
  * drives its journey through the `dms` fixture, prepared with the
@@ -86,7 +89,12 @@ export async function registerJourneys() {
86
89
  journeys: await loadJourneys(journeysFile(config, name)),
87
90
  })),
88
91
  );
89
- const journeys = suiteJourneys(features, suite.frontend, config.smoke);
92
+ const journeys = suiteJourneys(
93
+ features,
94
+ suite.frontend,
95
+ config.smoke,
96
+ process.env.DMS_E2E_SHUFFLE || undefined,
97
+ );
90
98
  for (const { feature, journey } of journeys) {
91
99
  const annotation = [
92
100
  { type: "title", description: journey.title },
package/e2e/mongo.mjs CHANGED
@@ -4,6 +4,7 @@ import { createRequire } from "node:module";
4
4
  import { join } from "node:path";
5
5
  import { setTimeout as sleep } from "node:timers/promises";
6
6
  import { pathToFileURL } from "node:url";
7
+ import { reservedPorts } from "./reserved-ports.mjs";
7
8
  import {
8
9
  arrayOf,
9
10
  decode,
@@ -261,14 +262,14 @@ export async function mongodBinary(from) {
261
262
  * every other process the kit starts does, since Windows runs no script
262
263
  * by its path alone.
263
264
  *
264
- * @param {{ mongo: string, logs: string }} paths The run's folders
265
+ * @param {{ mongo: string, logs: string, apiPort?: number, webPort?: number, smtpPort?: number, processes?: ReadonlyArray<{ port?: number }> }} paths The run's folders, or the run, whose reserved ports the mongod does not take
265
266
  * @param {string[]} from Folders to resolve mongodb-memory-server-core from
266
267
  * @param {import("./processes.mjs").RestartablePort} [port] The port, which a restart keeps so the backend's URL still reaches it, so it must be one {@link restartablePort} gave
267
268
  * @returns {Promise<{ url: string, record: ReturnType<typeof startDetached> & { port: import("./processes.mjs").RestartablePort } }>} Its URL and process record
268
269
  */
269
270
  export async function startMongod(paths, from, port) {
270
271
  const binary = await mongodBinary(from);
271
- port ??= await restartablePort();
272
+ port ??= await restartablePort(reservedPorts(paths));
272
273
  mkdirSync(paths.mongo, { recursive: true });
273
274
  const script = JAVASCRIPT_FILE.test(binary);
274
275
  const record = startDetached({
package/e2e/processes.mjs CHANGED
@@ -45,11 +45,22 @@ function isTcpAddress(address) {
45
45
  }
46
46
 
47
47
  /**
48
- * Asks the kernel for a free TCP port on the loopback interface.
48
+ * Asks the kernel for a free loopback port outside `exclude`.
49
49
  *
50
+ * @param {Iterable<number>} [exclude] Skipped ports
50
51
  * @returns {Promise<number>} The port
51
52
  */
52
- export function freePort() {
53
+ export async function freePort(exclude = []) {
54
+ const skip = new Set(exclude);
55
+ for (let n = 0; n < RESTARTABLE_PORT_ATTEMPTS; n += 1) {
56
+ const port = await kernelPort();
57
+ if (!skip.has(port)) return port;
58
+ }
59
+ throw new Error("no free port");
60
+ }
61
+
62
+ /** @returns {Promise<number>} */
63
+ function kernelPort() {
53
64
  return new Promise((resolve, reject) => {
54
65
  const server = createServer();
55
66
  server.once("error", reject);
@@ -107,38 +118,46 @@ export function isRestartablePort(port) {
107
118
  }
108
119
 
109
120
  /**
110
- * A free loopback port outside the kernel's ephemeral range, for a server
121
+ * A free loopback port outside the ephemeral range and `exclude` for a server
111
122
  * that must listen on the same port again after it restarts. No outgoing
112
123
  * connection takes such a port as its source port, so none can hold it in
113
124
  * TIME_WAIT and make that listen fail with `EADDRINUSE`, as a port from
114
125
  * {@link freePort} can be held.
115
126
  *
127
+ * @param {Iterable<number>} [exclude] Skipped ports
116
128
  * @returns {Promise<RestartablePort>} The port
117
- * @throws When no unprivileged port outside the range is free
129
+ * @throws When none is free
118
130
  */
119
- export async function restartablePort() {
131
+ export async function restartablePort(exclude = []) {
132
+ const excluded = new Set(exclude);
120
133
  const range = ephemeralRange();
121
134
  const below =
122
135
  range === null ? 0 : Math.max(range.low - FIRST_UNPRIVILEGED_PORT, 0);
123
136
  const above = range === null ? 0 : Math.max(LAST_PORT - range.high, 0);
124
- if (range === null || below + above === 0) return restartableFree();
137
+ if (range === null || below + above === 0) return restartableFree(excluded);
125
138
  for (let attempt = 0; attempt < RESTARTABLE_PORT_ATTEMPTS; attempt += 1) {
126
139
  const index = randomInt(below + above);
127
140
  const port =
128
141
  index < below
129
142
  ? FIRST_UNPRIVILEGED_PORT + index
130
143
  : range.high + 1 + index - below;
131
- if (isRestartablePort(port) && (await canListen(port))) return port;
144
+ if (
145
+ isRestartablePort(port) &&
146
+ !excluded.has(port) &&
147
+ (await canListen(port))
148
+ )
149
+ return port;
132
150
  }
133
151
  throw new Error("no loopback port outside the ephemeral range is free");
134
152
  }
135
153
 
136
154
  /**
137
- * @returns {Promise<RestartablePort>} A port from {@link freePort}, where /proc does not tell the range
138
- * @throws When the range is known and the port lies in it
155
+ * @param {Set<number>} excluded Ports to skip
156
+ * @returns {Promise<RestartablePort>} A port from {@link freePort}, where /proc tells no range
157
+ * @throws When the port lies in the range
139
158
  */
140
- async function restartableFree() {
141
- const port = await freePort();
159
+ async function restartableFree(excluded) {
160
+ const port = await freePort(excluded);
142
161
  if (isRestartablePort(port)) return port;
143
162
  throw new Error("no loopback port outside the ephemeral range is free");
144
163
  }
@@ -254,10 +273,10 @@ export async function probe(url) {
254
273
  export async function waitForOk(url, record, timeoutMs) {
255
274
  const deadline = Date.now() + timeoutMs;
256
275
  while (Date.now() < deadline) {
257
- if ((await probe(url)) === 200) return;
258
276
  if (!isAlive(record.pid)) {
259
277
  throw new Error(`${url}: the process exited first; see ${record.log}`);
260
278
  }
279
+ if ((await probe(url)) === 200) return;
261
280
  await sleep(READY_POLL_MS);
262
281
  }
263
282
  throw new Error(
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The ports a run holds or has reserved: its API, dashboard and mail ports
3
+ * and the port of every process it recorded.
4
+ *
5
+ * @param {{ apiPort?: number, webPort?: number, smtpPort?: number, processes?: ReadonlyArray<{ port?: number }> }} run The run, or the folders of one
6
+ * @returns {number[]} The ports a new server must not take
7
+ */
8
+ export function reservedPorts(run) {
9
+ return [
10
+ run.apiPort,
11
+ run.webPort,
12
+ run.smtpPort,
13
+ ...(run.processes ?? []).map((entry) => entry.port),
14
+ ].filter((port) => port !== undefined);
15
+ }
package/e2e/run-copy.mjs CHANGED
@@ -15,23 +15,26 @@ export const COPY_SKIPPED = new Set([
15
15
  WORKSPACE_FOLDER,
16
16
  ]);
17
17
  const SHADOW_SKIPPED = new Set([".antelope", WORKSPACE_FOLDER, ".git"]);
18
+ /** The folder of `node_modules` that a run's processes write to, which each run keeps its own. */
19
+ const MODULES_CACHE = ".cache";
18
20
 
19
21
  /**
20
22
  * @param {string} real
21
23
  * @param {string} shadow
22
- * @param {string} keep
24
+ * @param {string[]} keep
23
25
  */
24
- function shadowLevel(real, shadow, keep) {
26
+ function shadowLevel(real, shadow, ...keep) {
25
27
  mkdirSync(shadow, { recursive: true });
26
28
  for (const entry of readdirSync(real)) {
27
- if (entry === keep || SHADOW_SKIPPED.has(entry)) continue;
29
+ if (keep.includes(entry) || SHADOW_SKIPPED.has(entry)) continue;
28
30
  symlinkSync(join(real, entry), join(shadow, entry));
29
31
  }
30
32
  }
31
33
 
32
34
  /**
33
35
  * A `node_modules` that is `modules` with `@antelopejs/dms-frontend` replaced
34
- * by the renderer checkout, every other entry linked to the original.
36
+ * by the renderer checkout and no `.cache`, every other entry linked to the
37
+ * original.
35
38
  *
36
39
  * @param {string} modules The playground's installed modules
37
40
  * @param {string} shadow The run's `node_modules`
@@ -39,7 +42,7 @@ function shadowLevel(real, shadow, keep) {
39
42
  */
40
43
  export function linkRenderer(modules, shadow, renderer) {
41
44
  const scope = "@antelopejs";
42
- shadowLevel(modules, shadow, scope);
45
+ shadowLevel(modules, shadow, scope, MODULES_CACHE);
43
46
  const scoped = join(modules, scope);
44
47
  const shadowScope = join(shadow, scope);
45
48
  if (existsSync(scoped)) shadowLevel(scoped, shadowScope, "dms-frontend");
@@ -52,9 +55,10 @@ export function linkRenderer(modules, shadow, renderer) {
52
55
  * the playground, every sibling is linked, so relative paths such as a
53
56
  * tsconfig `extends` resolve as in the checkout. The playground itself is
54
57
  * copied without its installed modules and build, so `.antelope/` and the
55
- * frontend build belong to the run. Its `node_modules` is the playground's,
56
- * except that `@antelopejs/dms-frontend` is the `renderer` checkout when
57
- * there is one.
58
+ * frontend build belong to the run. Its `node_modules` links every entry of
59
+ * the playground's but `.cache`, where a backend writes its MCP credential
60
+ * and its packed modules, so that folder belongs to the run too; and
61
+ * `@antelopejs/dms-frontend` is the `renderer` checkout when there is one.
58
62
  *
59
63
  * @param {string} playground The playground folder
60
64
  * @param {string} checkout The checkout root, or the module folder outside one
@@ -77,6 +81,6 @@ export function layOutCopy(playground, checkout, root, renderer) {
77
81
  });
78
82
  const modules = join(playground, "node_modules");
79
83
  if (renderer) linkRenderer(modules, join(shadow, "node_modules"), renderer);
80
- else symlinkSync(modules, join(shadow, "node_modules"));
84
+ else shadowLevel(modules, join(shadow, "node_modules"), MODULES_CACHE);
81
85
  return shadow;
82
86
  }
package/e2e/run.mjs CHANGED
@@ -1,7 +1,5 @@
1
1
  import { runJourney as driveJourney } from "./journey-run.mjs";
2
- import { loadRun } from "./run-state.mjs";
3
- import { down } from "./stack.mjs";
4
- import { startOptions, startStack } from "./start.mjs";
2
+ import { startRuns } from "./start.mjs";
5
3
 
6
4
  export { apiRequest, onboard } from "./session.mjs";
7
5
  export { freshDatabase, restartBackend } from "./backend.mjs";
@@ -14,9 +12,6 @@ export { loadRun, saveRun } from "./run-state.mjs";
14
12
  * @typedef {{ run: RunState, stop: () => Promise<void> }} StartedRun A ready run, and what stops it
15
13
  */
16
14
 
17
- /** @type {NodeJS.Signals[]} */
18
- const STOP_SIGNALS = ["SIGINT", "SIGTERM"];
19
-
20
15
  /**
21
16
  * Starts a run of the checkout's playground, as the global setup of a
22
17
  * Playwright suite does, for any test runner: a copy of the playground on
@@ -31,36 +26,11 @@ const STOP_SIGNALS = ["SIGINT", "SIGTERM"];
31
26
  * @throws When the skill, its prepare commands or the stack fail; nothing it started is left running
32
27
  */
33
28
  export async function startRun(options = {}) {
34
- const cwd = process.cwd();
35
- const run = await startStack(startOptions(options, cwd), cwd);
36
- const onSignal = (/** @type {NodeJS.Signals} */ signal) => {
37
- release();
38
- const reraise = () => process.kill(process.pid, signal);
39
- stopRun(run.dir).then(reraise, reraise);
40
- };
41
- const release = () => {
42
- for (const signal of STOP_SIGNALS) process.off(signal, onSignal);
43
- };
44
- for (const signal of STOP_SIGNALS) process.on(signal, onSignal);
45
- return {
46
- run,
47
- stop: () => {
48
- release();
49
- return stopRun(run.dir);
50
- },
51
- };
52
- }
53
-
54
- /**
55
- * Stops a run from what its `run.json` recorded last, which the journeys of
56
- * other processes update, and reports what it could not do on stderr.
57
- *
58
- * @param {string} dir The run folder
59
- */
60
- async function stopRun(dir) {
61
- const lines = await down(loadRun(dir));
62
- for (const line of lines.filter((entry) => entry.startsWith("could not")))
63
- process.stderr.write(`dms-e2e: ${line}\n`);
29
+ const {
30
+ runs: [run],
31
+ stop,
32
+ } = await startRuns(options, 1);
33
+ return { run, stop };
64
34
  }
65
35
 
66
36
  /**
package/e2e/stack.mjs CHANGED
@@ -9,9 +9,11 @@ import {
9
9
  } from "./dashboard.mjs";
10
10
  import { existingBuildRoots } from "./build-inputs.mjs";
11
11
  import { describeFailure } from "./failure.mjs";
12
+ import { assertFrontendBound } from "./frontend-bound.mjs";
12
13
  import { checkoutOf } from "./git.mjs";
13
14
  import { apiTargetFile, writeTarget } from "./forwarder.mjs";
14
15
  import { currentNamespaces, isSameProcess } from "./identity.mjs";
16
+ import { reservedPorts } from "./reserved-ports.mjs";
15
17
  import { dropRunDatabases, startMongod } from "./mongo.mjs";
16
18
  import {
17
19
  freePort,
@@ -231,7 +233,7 @@ async function startFirstMail(state) {
231
233
  return;
232
234
  } catch (error) {
233
235
  if (attempt === MAIL_PORT_ATTEMPTS) throw error;
234
- state.smtpPort = await restartablePort();
236
+ state.smtpPort = await restartablePort(reservedPorts(state));
235
237
  }
236
238
  }
237
239
  }
@@ -288,7 +290,7 @@ export async function launchBackend(
288
290
  mode = runBackendMode(state),
289
291
  ) {
290
292
  const { ajs } = cliPaths(build?.playground ?? state.playground);
291
- const port = await freePort();
293
+ const port = await freePort(reservedPorts(state));
292
294
  const launch = spec(
293
295
  state,
294
296
  `backend${database.slice(state.databasePrefix.length)}`,
@@ -495,6 +497,7 @@ async function buildAndStart(state, useCache) {
495
497
  const frontend = startDetached(frontendSpec(state));
496
498
  record(state, { ...frontend, port: state.webPort });
497
499
  await waitForOk(`${state.webUrl}/dms-preview`, frontend, READY_TIMEOUT_MS);
500
+ assertFrontendBound(frontend);
498
501
  });
499
502
  await recordDashboardModules(state);
500
503
  }
package/e2e/start.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  import { resolve } from "node:path";
2
2
  import { checkoutOf } from "./git.mjs";
3
- import { up } from "./stack.mjs";
3
+ import { loadRun } from "./run-state.mjs";
4
+ import { down, up } from "./stack.mjs";
4
5
  import { loadSuiteConfig, runPrepare } from "./journeys-config.mjs";
5
6
 
6
7
  /**
@@ -77,3 +78,89 @@ export async function startStack(options, cwd) {
77
78
  }
78
79
  return state;
79
80
  }
81
+
82
+ /** @type {NodeJS.Signals[]} */
83
+ const STOP_SIGNALS = ["SIGINT", "SIGTERM"];
84
+
85
+ /**
86
+ * Stops a run from what its `run.json` recorded last, which the journeys of
87
+ * other processes update, and reports what it could not do on stderr.
88
+ *
89
+ * @param {string} dir The run folder
90
+ */
91
+ async function stopRun(dir) {
92
+ const lines = await down(loadRun(dir));
93
+ for (const line of lines.filter((entry) => entry.startsWith("could not")))
94
+ process.stderr.write(`dms-e2e: ${line}\n`);
95
+ }
96
+
97
+ /**
98
+ * Stops the runs in `dirs` together, each to its end whatever the others do.
99
+ *
100
+ * @param {string[]} dirs The run folders
101
+ * @returns {Promise<void>}
102
+ * @throws The first failure, once every run stopped
103
+ */
104
+ async function stopRuns(dirs) {
105
+ const stopped = await Promise.allSettled(dirs.map(stopRun));
106
+ const failed = stopped.find((result) => result.status === "rejected");
107
+ if (failed) throw failed.reason;
108
+ }
109
+
110
+ /**
111
+ * Starts `count` runs of the checkout's playground, each with its own
112
+ * playground copy, ports, MongoDB, mail sink, backends and dashboard, for
113
+ * the workers of one suite to drive one each. The first runs the journeys
114
+ * config's prepare commands as `options` asks; the others start once it is
115
+ * ready, together, without them, so their dashboards come from the build
116
+ * cache the first one filled. `stop` stops them all, and from the moment
117
+ * the first is ready a SIGINT or SIGTERM to this process stops every run
118
+ * started so far, then ends the process by that signal.
119
+ *
120
+ * @param {RunOptions} options How to start them
121
+ * @param {number} count How many, at least 1
122
+ * @returns {Promise<{ runs: import("./run-state.mjs").RunState[], stop: () => Promise<void> }>} The ready runs, and what stops them
123
+ * @throws When a run fails to start; every run it started is stopped first
124
+ */
125
+ export async function startRuns(options, count) {
126
+ const cwd = process.cwd();
127
+ const first = await startStack(startOptions(options, cwd), cwd);
128
+ const dirs = [first.dir];
129
+ const onSignal = (/** @type {NodeJS.Signals} */ signal) => {
130
+ release();
131
+ const reraise = () => process.kill(process.pid, signal);
132
+ stopRuns(dirs).then(reraise, reraise);
133
+ };
134
+ const release = () => {
135
+ for (const signal of STOP_SIGNALS) process.off(signal, onSignal);
136
+ };
137
+ for (const signal of STOP_SIGNALS) process.on(signal, onSignal);
138
+ const others = await Promise.allSettled(
139
+ Array.from({ length: count - 1 }, async () => {
140
+ const run = await startStack(
141
+ startOptions({ ...options, prepare: false }, cwd),
142
+ cwd,
143
+ );
144
+ dirs.push(run.dir);
145
+ return run;
146
+ }),
147
+ );
148
+ const failed = others.find((other) => other.status === "rejected");
149
+ if (failed) {
150
+ release();
151
+ await stopRuns(dirs);
152
+ throw failed.reason;
153
+ }
154
+ return {
155
+ runs: [
156
+ first,
157
+ ...others.flatMap((other) =>
158
+ other.status === "fulfilled" ? [other.value] : [],
159
+ ),
160
+ ],
161
+ stop: () => {
162
+ release();
163
+ return stopRuns(dirs);
164
+ },
165
+ };
166
+ }
package/e2e/suite.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import { createHash } from "node:crypto";
1
2
  import { existsSync } from "node:fs";
2
3
  import { resolve } from "node:path";
3
4
  import { checkoutOf } from "./git.mjs";
@@ -87,15 +88,18 @@ function isSuite(value) {
87
88
  * The journeys a suite runs: those of the `smoke` feature first, then the
88
89
  * others in the order of their features, and those marked `last` after all
89
90
  * others. A `frontend: "dev"` suite runs the journeys that ask for the
90
- * development dashboard, any other the rest.
91
+ * development dashboard, any other the rest. With `seed`, the journeys not
92
+ * marked `last` run in an order drawn from it instead, the same for the
93
+ * same seed, and the `last` ones still after them in their own order.
91
94
  *
92
95
  * @param {{ name: string, journeys: Journey[] }[]} features The features and their journeys
93
96
  * @param {Suite["frontend"]} frontend How the suite's run serves its dashboard
94
97
  * @param {string} smoke The feature whose journeys run first, the journeys config's `smoke`
98
+ * @param {string} [seed] What draws the order, `DMS_E2E_SHUFFLE`
95
99
  * @returns {{ feature: string, journey: Journey }[]} The journeys, each with its feature
96
100
  * @throws When two journeys share an id
97
101
  */
98
- export function suiteJourneys(features, frontend, smoke) {
102
+ export function suiteJourneys(features, frontend, smoke, seed) {
99
103
  const ids = features.flatMap((feature) =>
100
104
  feature.journeys.map((journey) => journey.id),
101
105
  );
@@ -113,8 +117,27 @@ export function suiteJourneys(features, frontend, smoke) {
113
117
  .filter(
114
118
  (entry) => (entry.journey.frontend === "dev") === (frontend === "dev"),
115
119
  );
120
+ const first = entries.filter((entry) => !entry.journey.last);
116
121
  return [
117
- ...entries.filter((entry) => !entry.journey.last),
122
+ ...(seed === undefined ? first : shuffled(first, seed)),
118
123
  ...entries.filter((entry) => entry.journey.last),
119
124
  ];
120
125
  }
126
+
127
+ /**
128
+ * `entries` sorted on a hash of `seed` and each feature and journey id.
129
+ *
130
+ * @param {{ feature: string, journey: Journey }[]} entries The journeys
131
+ * @param {string} seed What draws the order
132
+ * @returns {{ feature: string, journey: Journey }[]} The same journeys in the drawn order
133
+ */
134
+ function shuffled(entries, seed) {
135
+ const rank = (/** @type {{ feature: string, journey: Journey }} */ entry) =>
136
+ createHash("sha256")
137
+ .update(`${seed}\0${entry.feature}/${entry.journey.id}`)
138
+ .digest("hex");
139
+ return entries
140
+ .map((entry) => ({ entry, rank: rank(entry) }))
141
+ .toSorted((left, right) => (left.rank < right.rank ? -1 : 1))
142
+ .map(({ entry }) => entry);
143
+ }
@@ -80,12 +80,12 @@
80
80
  "devDependencies": {
81
81
  "@antelopejs/core": "~1.24.5",
82
82
  "@antelopejs/dms-frontend": ">=0.11.11 <0.12.0",
83
- "@antelopejs/tooling-configs": ">=0.10.4 <0.11.0",
83
+ "@antelopejs/tooling-configs": ">=0.10.12 <0.11.0",
84
84
  "@inertiajs/vue3": "^3.7.0",
85
85
  "@nuxt/eslint-config": "^1.17.0",
86
86
  "@nuxt/ui": "4.10.0",
87
87
  "@types/jsonwebtoken": "^9.0.10",
88
- "@unhead/vue": "^2.0.19",
88
+ "@unhead/vue": "^3.0.0",
89
89
  "@vitejs/plugin-vue": "^6",
90
90
  "eslint": "^10.9.1",
91
91
  "globals": "^15.0.0",
@@ -102,7 +102,7 @@
102
102
  },
103
103
  "peerDependencies": {
104
104
  "@nuxt/ui": "4.10.0",
105
- "@unhead/vue": "^2.0.0",
105
+ "@unhead/vue": "^2.0.0 || ^3.0.0",
106
106
  "tailwindcss": "^4.0.0",
107
107
  "typescript": "^5.8.0",
108
108
  "vite": "^7.0.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antelopejs/dms",
3
- "version": "0.24.3",
3
+ "version": "0.25.0",
4
4
  "description": "AntelopeJS DMS. Plug in your PostgreSQL, MySQL, MariaDB, MongoDB or RethinkDB database and your coding agent builds a back office and analytics dashboard as typed TypeScript. Real-time updates on the data the DMS manages.",
5
5
  "keywords": [
6
6
  "antelopejs",
@@ -110,8 +110,8 @@
110
110
  "ts-morph": "^28.0.0",
111
111
  "ua-parser-js": "^2.0.9",
112
112
  "zod": "^4.5.0",
113
- "@antelopejs/interface-dms": "^0.17.2",
114
- "@antelopejs/interface-dms-builder": "^0.6.3"
113
+ "@antelopejs/interface-dms": "^0.17.3",
114
+ "@antelopejs/interface-dms-builder": "^0.6.4"
115
115
  },
116
116
  "devDependencies": {
117
117
  "@antelopejs/api": "~1.7.9",
@@ -120,11 +120,11 @@
120
120
  "@antelopejs/mysql": ">=0.2.7 <0.3.0",
121
121
  "@antelopejs/postgres": ">=0.4.3 <0.5.0",
122
122
  "@antelopejs/rethinkdb": "~1.10.6",
123
- "@antelopejs/tooling-configs": ">=0.10.4 <0.11.0",
123
+ "@antelopejs/tooling-configs": ">=0.10.12 <0.11.0",
124
124
  "@playwright/test": "~1.65.0",
125
125
  "@types/archiver": "^6.0.4",
126
- "@types/chai": "^4.3.20",
127
- "@types/jsdom": "^28.0.3",
126
+ "@types/chai": "^5.0.0",
127
+ "@types/jsdom": "^30.0.0",
128
128
  "@types/mocha": "^10",
129
129
  "@types/node": "^26.6.5",
130
130
  "@types/node-cron": "^3.0.11",
@@ -211,7 +211,7 @@
211
211
  "optional": true
212
212
  }
213
213
  },
214
- "gitHead": "85ab0c1159cdb0fab9aef45e7a7be0b1dfec02a2",
214
+ "gitHead": "f3f8282f5834ebe408f0ce6f950a3f1b53f227ef",
215
215
  "scripts": {
216
216
  "build": "pnpm --filter @antelopejs/interface-dms --filter @antelopejs/interface-dms-builder build && rimraf dist && antelopejs-tsc && tsc-alias && tsc -p e2e/tsconfig.types.json",
217
217
  "dev": "ajs project run --inspect -w -p playground",
@@ -219,13 +219,13 @@
219
219
  "frontend:build": "pnpm --dir playground frontend:build",
220
220
  "frontend:start": "pnpm --dir playground frontend:start",
221
221
  "typecheck": "node scripts/unless-prebuilt.mjs pnpm --filter @antelopejs/interface-dms --filter @antelopejs/interface-dms-builder exec antelopejs-tsc && antelopejs-tsc --noEmit",
222
- "test": "node scripts/unless-prebuilt.mjs pnpm run build && ajs module test .",
222
+ "test": "node scripts/unless-prebuilt.mjs pnpm run build && ajs module test . --timeout 30000",
223
223
  "check:backend": "node scripts/unless-prebuilt.mjs pnpm run build && node scripts/backend-checks.cjs",
224
- "test:unit": "pnpm run check:backend && node scripts/backend-checks.test.mjs && node scripts/docs-scripts.test.mjs && node scripts/csstools-peers.test.mjs && node scripts/json-record.test.mjs && node scripts/test-files.test.mjs && node scripts/refresh-test-weights.test.mjs && DMS_TEST_DIR=dist/test/unit ajs module test . $(node scripts/test-files.mjs dist/test/unit dist/test/unit/builder)",
225
- "test:integration": "node scripts/unless-prebuilt.mjs pnpm run build && DMS_TEST_DIR=dist/test/integration ajs module test .",
224
+ "test:unit": "pnpm run check:backend && node scripts/backend-checks.test.mjs && node scripts/docs-scripts.test.mjs && node scripts/csstools-peers.test.mjs && node scripts/json-record.test.mjs && node scripts/test-files.test.mjs && node scripts/refresh-test-weights.test.mjs && DMS_TEST_DIR=dist/test/unit ajs module test --timeout 30000 . $(node scripts/test-files.mjs dist/test/unit dist/test/unit/builder)",
225
+ "test:integration": "node scripts/unless-prebuilt.mjs pnpm run build && DMS_TEST_DIR=dist/test/integration ajs module test . --timeout 30000",
226
226
  "test:published-dms": "node scripts/published-dms.mjs",
227
- "test:builder": "node scripts/unless-prebuilt.mjs pnpm run build && DMS_TEST_DIR=dist/test/unit/builder ajs module test .",
228
- "test:builder:shard": "node scripts/unless-prebuilt.mjs pnpm run build && files=$(node scripts/test-files.mjs dist/test/unit/builder --shard=$DMS_TEST_SHARD --weights=scripts/test-weights.json) && DMS_TEST_DIR=dist/test/unit/builder ajs module test . -f dist/test/helpers/file-durations.js $files",
227
+ "test:builder": "node scripts/unless-prebuilt.mjs pnpm run build && DMS_TEST_DIR=dist/test/unit/builder ajs module test . --timeout 30000",
228
+ "test:builder:shard": "node scripts/unless-prebuilt.mjs pnpm run build && files=$(node scripts/test-files.mjs dist/test/unit/builder --shard=$DMS_TEST_SHARD --weights=scripts/test-weights.json) && DMS_TEST_DIR=dist/test/unit/builder ajs module test . -f dist/test/helpers/file-durations.js $files --timeout 30000",
229
229
  "test:watch": "tsc -w & tsc-alias -w",
230
230
  "release": "pnpm --filter @antelopejs/interface-dms build && pnpm --dir frontend-vue install --frozen-lockfile && release-it",
231
231
  "knip": "knip --dependencies",