@ultimat3/testing 31.47.1 → 31.48.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/README.md +1 -1
- package/package.json +22 -22
- package/src/drill-fleet.ts +2 -0
- package/src/drill-services.ts +27 -1
- package/src/drills.ts +52 -6
- package/src/index.ts +9 -2
package/README.md
CHANGED
|
@@ -60,7 +60,7 @@ unitTest('the clock moves only when the test moves it', ({ clock }) => {
|
|
|
60
60
|
| `fault-proxy.ts` | `faultProxy({ target })` — a Bun TCP proxy whose mode switches mid-run: `pass`, `delay(ms)`, `blackhole` (bytes held, never dropped), `reset`, `refuse` |
|
|
61
61
|
| `drills.ts` · `drill-verdict.ts` | the nine fault drills (`x drill`) and the verdict over evidence alone; a property with no evidence is red, and an answer may reach the load `DRILL_ANSWER_SLACK_MS` (500) past the deadline it was given by |
|
|
62
62
|
| `drill-fleet.ts` · `drill-run.ts` | `startDrillFleet` — `web`, `worker` (and `sync` for `nats-down`) as processes on a scratch database, every service behind a proxy; `runDrill` — baseline, fault, recovery, judged |
|
|
63
|
-
| `drill-rollout.ts` · `drill-rollout-verdict.ts` · `drill-output.ts` | `roll-before-migrate`: `startDrillFleet({ beforeMigrate: { rewind, watch } })` migrates, runs the caller's `rewind`, starts `web`, `worker` and `
|
|
63
|
+
| `drill-rollout.ts` · `drill-rollout-verdict.ts` · `drill-output.ts` | `roll-before-migrate`: `startDrillFleet({ beforeMigrate: { rewind, watch } })` migrates, runs the caller's `rewind`, starts the roles `drillRoles(drill, found)` names (`web`, `worker`, `scheduler`, then `sync` on a bus and `replicator` on a logical server; `drillRolesNotPlayed` states the rest) unready and counts each output line naming `watch`; `runRollout` waits for every role to meet the schema, runs `fleet.rollout.migrate()`, asks each `/readyz` — `roles-wait`, `serves-after-migrate`, `one-wait-line` |
|
|
64
64
|
| `drill-load.ts` · `drill-writes.ts` | the load's lanes; `drillWriteTargets` — every action an anonymous POST reaches, each request a fresh seeded draw with the app's `exercise.ts` override, so a job enqueued over HTTP is on the table for `worker-sigkill`/`worker-sigterm` |
|
|
65
65
|
| `drill-sync.ts` | `startDrillSync` — the sync-client lane: `hello`, resubscribe, redial on a drop, every `replay-gap` counted; `sync-resumes` reads it |
|
|
66
66
|
| `tenant-proof-report.ts` | `tenantProofFindings` — one coded finding per crossing (`X_TENANT_LEAK`, `X_TENANT_WRITE_CROSSED`), `tenantFindingLines` the human lines. Paths, tables and seeded ids, never a bound value |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultimat3/testing",
|
|
3
|
-
"version": "31.
|
|
3
|
+
"version": "31.48.0",
|
|
4
4
|
"description": "Test harness: cloned template DBs per worker, frozen clock, sealed network, 6 test types",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ultimate",
|
|
@@ -47,27 +47,27 @@
|
|
|
47
47
|
"test": "bun test"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@ultimat3/action": "31.
|
|
51
|
-
"@ultimat3/ai": "31.
|
|
52
|
-
"@ultimat3/auth": "31.
|
|
53
|
-
"@ultimat3/cache": "31.
|
|
54
|
-
"@ultimat3/core": "31.
|
|
55
|
-
"@ultimat3/db": "31.
|
|
56
|
-
"@ultimat3/entity": "31.
|
|
57
|
-
"@ultimat3/http": "31.
|
|
58
|
-
"@ultimat3/i18n": "31.
|
|
59
|
-
"@ultimat3/jobs": "31.
|
|
60
|
-
"@ultimat3/mail": "31.
|
|
61
|
-
"@ultimat3/notify": "31.
|
|
62
|
-
"@ultimat3/policy": "31.
|
|
63
|
-
"@ultimat3/pwa": "31.
|
|
64
|
-
"@ultimat3/query": "31.
|
|
65
|
-
"@ultimat3/realtime": "31.
|
|
66
|
-
"@ultimat3/render": "31.
|
|
67
|
-
"@ultimat3/schema": "31.
|
|
68
|
-
"@ultimat3/scraping": "31.
|
|
69
|
-
"@ultimat3/seo": "31.
|
|
70
|
-
"@ultimat3/time": "31.
|
|
50
|
+
"@ultimat3/action": "31.48.0",
|
|
51
|
+
"@ultimat3/ai": "31.48.0",
|
|
52
|
+
"@ultimat3/auth": "31.48.0",
|
|
53
|
+
"@ultimat3/cache": "31.48.0",
|
|
54
|
+
"@ultimat3/core": "31.48.0",
|
|
55
|
+
"@ultimat3/db": "31.48.0",
|
|
56
|
+
"@ultimat3/entity": "31.48.0",
|
|
57
|
+
"@ultimat3/http": "31.48.0",
|
|
58
|
+
"@ultimat3/i18n": "31.48.0",
|
|
59
|
+
"@ultimat3/jobs": "31.48.0",
|
|
60
|
+
"@ultimat3/mail": "31.48.0",
|
|
61
|
+
"@ultimat3/notify": "31.48.0",
|
|
62
|
+
"@ultimat3/policy": "31.48.0",
|
|
63
|
+
"@ultimat3/pwa": "31.48.0",
|
|
64
|
+
"@ultimat3/query": "31.48.0",
|
|
65
|
+
"@ultimat3/realtime": "31.48.0",
|
|
66
|
+
"@ultimat3/render": "31.48.0",
|
|
67
|
+
"@ultimat3/schema": "31.48.0",
|
|
68
|
+
"@ultimat3/scraping": "31.48.0",
|
|
69
|
+
"@ultimat3/seo": "31.48.0",
|
|
70
|
+
"@ultimat3/time": "31.48.0"
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
73
73
|
"solid-js": "^1.9.18"
|
package/src/drill-fleet.ts
CHANGED
|
@@ -22,6 +22,8 @@ import { testSealKeyEnv } from './test-seal-key';
|
|
|
22
22
|
export interface DrillServiceUrls {
|
|
23
23
|
/** A Postgres URL with rights to CREATE DATABASE: the drill's scratch database is made there. */
|
|
24
24
|
readonly postgres: string;
|
|
25
|
+
/** That server runs `wal_level=logical`, so a replicator can stream from the scratch database. */
|
|
26
|
+
readonly logicalPostgres?: boolean | undefined;
|
|
25
27
|
readonly redis?: string | undefined;
|
|
26
28
|
/** NATS, and the variable the app's `realtime.urlEnv` reads it from. */
|
|
27
29
|
readonly nats?: { readonly url: string; readonly env: string } | undefined;
|
package/src/drill-services.ts
CHANGED
|
@@ -22,8 +22,18 @@ export interface DrillDeclarations {
|
|
|
22
22
|
readonly nats: { readonly env: string } | undefined;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
/** The `wal_level=logical` server `docker/test-services.env` publishes: the replicator's. */
|
|
26
|
+
const LOGICAL_POSTGRES_ENV = 'TEST_REPLICATION_URL';
|
|
27
|
+
/** Where the rollout order hands a bus the app itself does not declare. */
|
|
28
|
+
const DEFAULT_BUS_ENV = 'NATS_URL';
|
|
29
|
+
|
|
25
30
|
type Env = Readonly<Record<string, string | undefined>>;
|
|
26
31
|
|
|
32
|
+
const present = (env: Env, name: string): string | undefined => {
|
|
33
|
+
const value = env[name]?.trim();
|
|
34
|
+
return value === undefined || value === '' ? undefined : value;
|
|
35
|
+
};
|
|
36
|
+
|
|
27
37
|
const read = (env: Env, name: string, drill: Drill): string => {
|
|
28
38
|
const value = env[name]?.trim();
|
|
29
39
|
if (value === undefined || value === '') {
|
|
@@ -60,8 +70,24 @@ export function drillServices(
|
|
|
60
70
|
},
|
|
61
71
|
});
|
|
62
72
|
}
|
|
63
|
-
const postgres = read(env, DRILL_SERVICE_ENV.postgres, drill);
|
|
64
73
|
const redis = declared.redis ? read(env, DRILL_SERVICE_ENV.redis, drill) : undefined;
|
|
74
|
+
if (drill.fault.kind === 'order') {
|
|
75
|
+
// Every role that can start is played, so the bus and the logical server are taken when the
|
|
76
|
+
// run has them; without them the drill still plays what Postgres alone serves, and says so.
|
|
77
|
+
const logical = present(env, LOGICAL_POSTGRES_ENV);
|
|
78
|
+
const bus =
|
|
79
|
+
declared.nats === undefined
|
|
80
|
+
? present(env, DRILL_SERVICE_ENV.nats)
|
|
81
|
+
: read(env, DRILL_SERVICE_ENV.nats, drill);
|
|
82
|
+
return {
|
|
83
|
+
postgres: logical ?? read(env, DRILL_SERVICE_ENV.postgres, drill),
|
|
84
|
+
logicalPostgres: logical !== undefined,
|
|
85
|
+
redis,
|
|
86
|
+
nats:
|
|
87
|
+
bus === undefined ? undefined : { url: bus, env: declared.nats?.env ?? DEFAULT_BUS_ENV },
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
const postgres = read(env, DRILL_SERVICE_ENV.postgres, drill);
|
|
65
91
|
const nats =
|
|
66
92
|
declared.nats === undefined
|
|
67
93
|
? undefined
|
package/src/drills.ts
CHANGED
|
@@ -9,10 +9,11 @@ import type { FaultMode } from './fault-proxy';
|
|
|
9
9
|
export type DrillService = 'postgres' | 'redis' | 'nats';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* A role the fleet runs as its own process (`ROLE`, `apps/web/server.ts`); `sync`
|
|
13
|
-
*
|
|
12
|
+
* A role the fleet runs as its own process (`ROLE`, `apps/web/server.ts`); `sync` for a drill whose
|
|
13
|
+
* sync client needs a node to dial and for the rollout order, `scheduler` and `replicator` for the
|
|
14
|
+
* rollout order alone.
|
|
14
15
|
*/
|
|
15
|
-
export type DrillRole = 'web' | 'worker' | 'sync' | 'scheduler';
|
|
16
|
+
export type DrillRole = 'web' | 'worker' | 'sync' | 'scheduler' | 'replicator';
|
|
16
17
|
|
|
17
18
|
export type DrillName =
|
|
18
19
|
| 'pg-blackhole'
|
|
@@ -111,15 +112,60 @@ export const DRILL_NAMES: readonly DrillName[] = DRILLS.map((drill) => drill.nam
|
|
|
111
112
|
export const drillNamed = (name: string): Drill | undefined =>
|
|
112
113
|
DRILLS.find((drill) => drill.name === name);
|
|
113
114
|
|
|
115
|
+
/** What this run can start beyond the roles Postgres alone serves. */
|
|
116
|
+
export interface DrillRoleFacts {
|
|
117
|
+
/** A NATS server: `sync` needs a bus. */
|
|
118
|
+
readonly bus: boolean;
|
|
119
|
+
/** The scratch database sits on a `wal_level=logical` server: the replicator streams from it. */
|
|
120
|
+
readonly logicalPostgres: boolean;
|
|
121
|
+
/** The app declares an entity on a table: with none, the replicator refuses to boot. */
|
|
122
|
+
readonly publishable: boolean;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** A role the rollout order did not start, and what would have let it. */
|
|
126
|
+
export interface DrillRoleNotPlayed {
|
|
127
|
+
readonly role: DrillRole;
|
|
128
|
+
readonly needs: string;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const POSTGRES_ONLY: DrillRoleFacts = { bus: false, logicalPostgres: false, publishable: false };
|
|
132
|
+
|
|
133
|
+
/** The rollout order's roles beyond `web`, `worker` and `scheduler`, each with its gap if any. */
|
|
134
|
+
const rolloutExtras = (
|
|
135
|
+
found: DrillRoleFacts,
|
|
136
|
+
): readonly (DrillRoleNotPlayed & { gap: boolean })[] => [
|
|
137
|
+
{ role: 'sync', needs: 'TEST_NATS_URL', gap: !found.bus },
|
|
138
|
+
found.publishable
|
|
139
|
+
? { role: 'replicator', needs: 'TEST_REPLICATION_URL', gap: !found.logicalPostgres }
|
|
140
|
+
: { role: 'replicator', needs: 'an entity on a table', gap: true },
|
|
141
|
+
];
|
|
142
|
+
|
|
114
143
|
/**
|
|
115
144
|
* The roles a drill's fleet runs: a sync client needs the sync node it dials; the rollout order is
|
|
116
|
-
* played on every role
|
|
145
|
+
* played on every role this run can start, since each one meets the same behind schema.
|
|
117
146
|
*/
|
|
118
|
-
export const drillRoles = (
|
|
119
|
-
|
|
147
|
+
export const drillRoles = (
|
|
148
|
+
drill: Drill,
|
|
149
|
+
found: DrillRoleFacts = POSTGRES_ONLY,
|
|
150
|
+
): readonly DrillRole[] => {
|
|
151
|
+
if (drill.fault.kind === 'order') {
|
|
152
|
+
const extras = rolloutExtras(found).filter((extra) => !extra.gap);
|
|
153
|
+
return ['web', 'worker', 'scheduler', ...extras.map((extra) => extra.role)];
|
|
154
|
+
}
|
|
120
155
|
return drill.holds.includes('sync-resumes') ? ['web', 'worker', 'sync'] : ['web', 'worker'];
|
|
121
156
|
};
|
|
122
157
|
|
|
158
|
+
/** The rollout-order roles this run leaves out: stated in the report, never dropped silently. */
|
|
159
|
+
export const drillRolesNotPlayed = (
|
|
160
|
+
drill: Drill,
|
|
161
|
+
found: DrillRoleFacts,
|
|
162
|
+
): readonly DrillRoleNotPlayed[] =>
|
|
163
|
+
drill.fault.kind === 'order'
|
|
164
|
+
? rolloutExtras(found)
|
|
165
|
+
.filter((extra) => extra.gap)
|
|
166
|
+
.map(({ role, needs }) => ({ role, needs }))
|
|
167
|
+
: [];
|
|
168
|
+
|
|
123
169
|
/** The service a drill needs running, when it needs one beyond Postgres. */
|
|
124
170
|
export const drillService = (drill: Drill): DrillService | undefined =>
|
|
125
171
|
drill.fault.kind === 'service' ? drill.fault.service : undefined;
|
package/src/index.ts
CHANGED
|
@@ -89,8 +89,15 @@ export type { DrillBudgets, DrillEvidence, DrillFailure, DrillProperty } from '.
|
|
|
89
89
|
export { judgeDrill } from './drill-verdict';
|
|
90
90
|
export type { DrillWrites } from './drill-writes';
|
|
91
91
|
export { drillWriteTargets } from './drill-writes';
|
|
92
|
-
export type {
|
|
93
|
-
|
|
92
|
+
export type {
|
|
93
|
+
Drill,
|
|
94
|
+
DrillName,
|
|
95
|
+
DrillRole,
|
|
96
|
+
DrillRoleFacts,
|
|
97
|
+
DrillRoleNotPlayed,
|
|
98
|
+
DrillService,
|
|
99
|
+
} from './drills';
|
|
100
|
+
export { DRILL_NAMES, DRILLS, drillNamed, drillRoles, drillRolesNotPlayed } from './drills';
|
|
94
101
|
export type { A11yFinding, A11yRule } from './e2e-a11y';
|
|
95
102
|
export { auditTree, NAMED_ROLES } from './e2e-a11y';
|
|
96
103
|
export type { A11yAllow, A11yOptions } from './e2e-a11y-run';
|