@mark1russell7/harness 0.11.2 → 0.11.3

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.
@@ -0,0 +1,19 @@
1
+ import { J as Subject, _ as ImageSource, i as ClientImage, r as Client } from "./cell-BmSnJJtn.js";
2
+ import { z } from "zod";
3
+ //#region src/schema.d.ts
4
+ /**
5
+ * This schema accepts the source of an image (`ImageSource`). It is a pinned image with its digest,
6
+ * a build context whose paths stay in it, or an image that the harness ships.
7
+ */
8
+ export declare const imageSourceSchema: z.ZodType<ImageSource>;
9
+ /** This schema accepts a client image (`ClientImage`): a stock image by its name or the source of an image, and its command. */
10
+ export declare const clientImageSchema: z.ZodType<ClientImage>;
11
+ /** This schema accepts the client of a cell (`Cell.client`): a client that the harness ships by its name, or a client image. */
12
+ export declare const clientSchema: z.ZodType<Client | ClientImage>;
13
+ /**
14
+ * This schema accepts a subject (`Subject`): its name, the source of its image and its stock base.
15
+ * It also accepts the command of each of its programs.
16
+ */
17
+ export declare const subjectSchema: z.ZodType<Subject>;
18
+ //#endregion
19
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1,56 @@
1
+ import { a as SHIPPED_NAMES, t as CLIENT_NAMES, u as imageProblems, x as subjectProblems } from "./image-Q_fs3rCC.js";
2
+ import { z } from "zod";
3
+ //#region src/schema.ts
4
+ /** This function adds each problem that a check finds as an issue of a schema. */
5
+ const issues = (check) => (value, ctx) => {
6
+ for (const message of check(value)) ctx.addIssue({
7
+ code: "custom",
8
+ message
9
+ });
10
+ };
11
+ /** This schema accepts a command: argv of one text or more. */
12
+ const command = z.array(z.string().min(1)).min(1);
13
+ /** This schema accepts the shape of each kind of image source. The checks of its values come after it. */
14
+ const sourceShape = z.discriminatedUnion("kind", [
15
+ z.strictObject({
16
+ kind: z.literal("pinned"),
17
+ image: z.string()
18
+ }),
19
+ z.strictObject({
20
+ kind: z.literal("build"),
21
+ name: z.string(),
22
+ context: z.string(),
23
+ dockerfile: z.string().optional(),
24
+ files: z.array(z.string()).optional()
25
+ }),
26
+ z.strictObject({
27
+ kind: z.literal("shipped"),
28
+ name: z.enum(SHIPPED_NAMES)
29
+ })
30
+ ]);
31
+ /**
32
+ * This schema accepts the source of an image (`ImageSource`). It is a pinned image with its digest,
33
+ * a build context whose paths stay in it, or an image that the harness ships.
34
+ */
35
+ const imageSourceSchema = sourceShape.superRefine(issues(imageProblems));
36
+ /** This schema accepts a client image (`ClientImage`): a stock image by its name or the source of an image, and its command. */
37
+ const clientImageSchema = z.strictObject({
38
+ image: z.union([z.string().min(1), imageSourceSchema]),
39
+ command
40
+ });
41
+ /** This schema accepts the client of a cell (`Cell.client`): a client that the harness ships by its name, or a client image. */
42
+ const clientSchema = z.union([z.enum(CLIENT_NAMES), clientImageSchema]);
43
+ /**
44
+ * This schema accepts a subject (`Subject`): its name, the source of its image and its stock base.
45
+ * It also accepts the command of each of its programs.
46
+ */
47
+ const subjectSchema = z.strictObject({
48
+ name: z.string().min(1),
49
+ image: sourceShape,
50
+ base: z.string(),
51
+ programs: z.record(z.string(), command)
52
+ }).superRefine(issues(subjectProblems));
53
+ //#endregion
54
+ export { clientImageSchema, clientSchema, imageSourceSchema, subjectSchema };
55
+
56
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","names":[],"sources":["../src/schema.ts"],"sourcesContent":["// The entry \"@mark1russell7/harness/schema\": the zod schemas of the data that a caller gives the\n// harness as JSON. These are the source of an image, a client and a subject. The root entry of\n// the package does not import zod.\nimport { z } from \"zod\";\nimport type { Client, ClientImage, ImageSource, Subject } from \"./cell.ts\";\nimport { CLIENT_NAMES, SHIPPED_NAMES, imageProblems, subjectProblems } from \"./image.ts\";\n\n/** This function adds each problem that a check finds as an issue of a schema. */\nconst issues =\n <T>(check: (value: T) => string[]) =>\n (value: T, ctx: z.RefinementCtx): void => {\n for (const message of check(value)) ctx.addIssue({ code: \"custom\", message });\n };\n\n/** This schema accepts a command: argv of one text or more. */\nconst command = z.array(z.string().min(1)).min(1);\n\n/** This schema accepts the shape of each kind of image source. The checks of its values come after it. */\nconst sourceShape = z.discriminatedUnion(\"kind\", [\n z.strictObject({ kind: z.literal(\"pinned\"), image: z.string() }),\n z.strictObject({\n kind: z.literal(\"build\"),\n name: z.string(),\n context: z.string(),\n dockerfile: z.string().optional(),\n files: z.array(z.string()).optional(),\n }),\n z.strictObject({ kind: z.literal(\"shipped\"), name: z.enum(SHIPPED_NAMES) }),\n]);\n\n/**\n * This schema accepts the source of an image (`ImageSource`). It is a pinned image with its digest,\n * a build context whose paths stay in it, or an image that the harness ships.\n */\nexport const imageSourceSchema: z.ZodType<ImageSource> = sourceShape.superRefine(issues(imageProblems));\n\n/** This schema accepts a client image (`ClientImage`): a stock image by its name or the source of an image, and its command. */\nexport const clientImageSchema: z.ZodType<ClientImage> = z.strictObject({\n image: z.union([z.string().min(1), imageSourceSchema]),\n command,\n});\n\n/** This schema accepts the client of a cell (`Cell.client`): a client that the harness ships by its name, or a client image. */\nexport const clientSchema: z.ZodType<Client | ClientImage> = z.union([z.enum(CLIENT_NAMES), clientImageSchema]);\n\n/**\n * This schema accepts a subject (`Subject`): its name, the source of its image and its stock base.\n * It also accepts the command of each of its programs.\n */\nexport const subjectSchema: z.ZodType<Subject> = z\n .strictObject({\n name: z.string().min(1),\n image: sourceShape,\n base: z.string(),\n programs: z.record(z.string(), command),\n })\n .superRefine(issues(subjectProblems));\n"],"mappings":";;;;AAQA,MAAM,UACA,WACH,OAAU,QAA+B;CACxC,KAAK,MAAM,WAAW,MAAM,KAAK,GAAG,IAAI,SAAS;EAAE,MAAM;EAAU;CAAQ,CAAC;AAC9E;;AAGF,MAAM,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;;AAGhD,MAAM,cAAc,EAAE,mBAAmB,QAAQ;CAC/C,EAAE,aAAa;EAAE,MAAM,EAAE,QAAQ,QAAQ;EAAG,OAAO,EAAE,OAAO;CAAE,CAAC;CAC/D,EAAE,aAAa;EACb,MAAM,EAAE,QAAQ,OAAO;EACvB,MAAM,EAAE,OAAO;EACf,SAAS,EAAE,OAAO;EAClB,YAAY,EAAE,OAAO,CAAC,CAAC,SAAS;EAChC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS;CACtC,CAAC;CACD,EAAE,aAAa;EAAE,MAAM,EAAE,QAAQ,SAAS;EAAG,MAAM,EAAE,KAAK,aAAa;CAAE,CAAC;AAC5E,CAAC;;;;;AAMD,MAAa,oBAA4C,YAAY,YAAY,OAAO,aAAa,CAAC;;AAGtG,MAAa,oBAA4C,EAAE,aAAa;CACtE,OAAO,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,iBAAiB,CAAC;CACrD;AACF,CAAC;;AAGD,MAAa,eAAgD,EAAE,MAAM,CAAC,EAAE,KAAK,YAAY,GAAG,iBAAiB,CAAC;;;;;AAM9G,MAAa,gBAAoC,EAC9C,aAAa;CACZ,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CACtB,OAAO;CACP,MAAM,EAAE,OAAO;CACf,UAAU,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO;AACxC,CAAC,CAAC,CACD,YAAY,OAAO,eAAe,CAAC"}
@@ -8,6 +8,8 @@
8
8
  //
9
9
  // The lines:
10
10
  // - start: the versions of pg, pg-pool and Node, the mode and the options of the pool.
11
+ // - connecting: the first query, which makes the first connection of the pool. Its stamp is the
12
+ // stamp of the first sent line. The pool arms its connect timer in that call.
11
13
  // - socket, socket-end, socket-error: each socket of the pool, with its local address.
12
14
  // - connected: the first socket. The TCP client of the harness names its own socket so.
13
15
  // - pool: each event of the pool: connect, acquire, release, remove, and error with its errno.
@@ -118,6 +120,8 @@ setTimeout(() => {
118
120
  const operate = async (n) => {
119
121
  const at = now();
120
122
  const reply = pool.query(query);
123
+ // a band of a cell that starts into a fault counts from the start of the first connect
124
+ if (n === 1) emit("connecting", { at: `${host}:${port}` }, at);
121
125
  emit("sent", { n }, at);
122
126
  try {
123
127
  const result = await reply;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@mark1russell7/harness",
4
- "version": "0.11.2",
4
+ "version": "0.11.3",
5
5
  "description": "A fault-injection harness for connection timers: a cell runs a client against a stock target in Docker, through a topology of routers and proxies, a replicated group under Sentinels or a replica set, injects a fault, measures the kernel's own records and judges a prediction. HTTP clients of Go, Node and undici race the keep-alive of a Node server, and the MongoDB driver meets the faults of a replica set. The WebSocket client of @procedures/client drops a silent connection on its own heartbeat, and the harness times that detection and the reconnect from the program's lines and the kernel's stamps.",
6
6
  "keywords": [
7
7
  "fault-injection",
@@ -33,6 +33,10 @@
33
33
  "types": "./build/index.d.ts",
34
34
  "default": "./build/index.js"
35
35
  },
36
+ "./schema": {
37
+ "types": "./build/schema.d.ts",
38
+ "default": "./build/schema.js"
39
+ },
36
40
  "./package.json": "./package.json"
37
41
  },
38
42
  "files": [