@mark1russell7/harness 0.16.28 → 0.16.30
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 +9 -1
- package/build/index.d.ts +40 -3
- package/build/index.js +137 -18
- package/build/index.js.map +1 -1
- package/build/layers.d.ts +34 -1
- package/build/layers.js +100 -1
- package/build/layers.js.map +1 -1
- package/image/lazyfs/start.mts +42 -3
- package/package.json +4 -3
package/build/layers.d.ts
CHANGED
|
@@ -51,4 +51,37 @@ export declare const layerOf: (topology: Topology | undefined) => Layer;
|
|
|
51
51
|
*/
|
|
52
52
|
export declare const limitsOf: (cell: {
|
|
53
53
|
readonly prediction: object;
|
|
54
|
-
}) => readonly Limit[];
|
|
54
|
+
}) => readonly Limit[];
|
|
55
|
+
/**
|
|
56
|
+
* A rig term is one pair of the space of the rig map of rigor: a fault and the layer that the fault acts on. It uses
|
|
57
|
+
* the words of that map. The rig records of this repository (`docs/rigs.json`) name these pairs.
|
|
58
|
+
*/
|
|
59
|
+
export interface RigTerm {
|
|
60
|
+
readonly fault: string;
|
|
61
|
+
readonly layer: string;
|
|
62
|
+
}
|
|
63
|
+
/** These are the environments of the rig map for the layers. E0 has no environment: it runs no lab. */
|
|
64
|
+
export declare const LAYER_RIG_ENV: Readonly<Record<Layer, string | undefined>>;
|
|
65
|
+
/**
|
|
66
|
+
* These are the rig terms of each fault name of the labs: the faults of the harness and the kinds of the triggers of
|
|
67
|
+
* `@mark1russell7/kind`. The two vocabularies share the names that they share. An empty list is a fault that the rig
|
|
68
|
+
* map has no word for at this time. Examples are a stop with its grace, a planned failover, a drain and an ICMP
|
|
69
|
+
* unreachable. The terms of `netem` and `toxic` come from the settings of the cell (`rigTermsOf`).
|
|
70
|
+
*/
|
|
71
|
+
export declare const RIG_TERMS: Readonly<Record<string, readonly RigTerm[]>>;
|
|
72
|
+
/** These are the rig terms of each type of a toxic of Toxiproxy. A slow close and a limit of bandwidth have no word in the rig map. */
|
|
73
|
+
export declare const TOXIC_RIG_TERMS: Readonly<Record<string, readonly RigTerm[]>>;
|
|
74
|
+
/** These parts of a cell tell its rig terms. A cell of kind gives the kind of its trigger as `fault`. */
|
|
75
|
+
export interface RigTermCell {
|
|
76
|
+
readonly fault: string;
|
|
77
|
+
readonly toxic?: {
|
|
78
|
+
readonly type: string;
|
|
79
|
+
} | undefined;
|
|
80
|
+
readonly netem?: string | undefined;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* This function gives the rig terms of a cell. The terms of `netem` come from the words of its setting, and the terms
|
|
84
|
+
* of `toxic` from the type of its toxic. This function throws a `RangeError` for a fault name that `RIG_TERMS` does
|
|
85
|
+
* not have, thus a new fault gets its terms in the same change.
|
|
86
|
+
*/
|
|
87
|
+
export declare function rigTermsOf(cell: RigTermCell): readonly RigTerm[];
|
package/build/layers.js
CHANGED
|
@@ -154,6 +154,105 @@ const limitsOf = (cell) => {
|
|
|
154
154
|
const laws = new Map(Object.entries(cell.prediction));
|
|
155
155
|
return LIMITS.filter((limit) => laws.get(limit) !== void 0);
|
|
156
156
|
};
|
|
157
|
-
|
|
157
|
+
/** These are the environments of the rig map for the layers. E0 has no environment: it runs no lab. */
|
|
158
|
+
const LAYER_RIG_ENV = {
|
|
159
|
+
E0: void 0,
|
|
160
|
+
E1: "container",
|
|
161
|
+
E2: "kind",
|
|
162
|
+
E3: "fabric",
|
|
163
|
+
E4: "vm",
|
|
164
|
+
E5: "vendor",
|
|
165
|
+
E6: "hardware"
|
|
166
|
+
};
|
|
167
|
+
const term = (fault, layer) => ({
|
|
168
|
+
fault,
|
|
169
|
+
layer
|
|
170
|
+
});
|
|
171
|
+
/**
|
|
172
|
+
* These are the rig terms of each fault name of the labs: the faults of the harness and the kinds of the triggers of
|
|
173
|
+
* `@mark1russell7/kind`. The two vocabularies share the names that they share. An empty list is a fault that the rig
|
|
174
|
+
* map has no word for at this time. Examples are a stop with its grace, a planned failover, a drain and an ICMP
|
|
175
|
+
* unreachable. The terms of `netem` and `toxic` come from the settings of the cell (`rigTermsOf`).
|
|
176
|
+
*/
|
|
177
|
+
const RIG_TERMS = {
|
|
178
|
+
blackhole: [term("blackhole", "L3")],
|
|
179
|
+
"freeze-process": [term("freeze", "process")],
|
|
180
|
+
rst: [term("reset", "L4")],
|
|
181
|
+
stall: [term("stall", "L3")],
|
|
182
|
+
fin: [term("kill", "process")],
|
|
183
|
+
unreachable: [],
|
|
184
|
+
simplex: [term("blackhole", "L3")],
|
|
185
|
+
"mtu-blackhole": [term("mtu", "L3")],
|
|
186
|
+
netem: [],
|
|
187
|
+
"fin-ack": [term("loss", "L4")],
|
|
188
|
+
"middlebox-forget": [term("cut", "L4")],
|
|
189
|
+
"proxy-idle": [term("cut", "L7")],
|
|
190
|
+
toxic: [],
|
|
191
|
+
"server-close": [term("cut", "L7")],
|
|
192
|
+
partition: [term("partition", "L3")],
|
|
193
|
+
"planned-failover": [],
|
|
194
|
+
"app-stall": [term("stall", "L7")],
|
|
195
|
+
"step-down": [],
|
|
196
|
+
drain: [],
|
|
197
|
+
"hop-event": [],
|
|
198
|
+
silence: [term("blackhole", "L3")],
|
|
199
|
+
none: [],
|
|
200
|
+
"pod-deletion": [],
|
|
201
|
+
"rolling-update": [],
|
|
202
|
+
"node-drain": [],
|
|
203
|
+
"scale-in": [],
|
|
204
|
+
crash: [term("kill", "process")],
|
|
205
|
+
"liveness-restart": [term("kill", "process")],
|
|
206
|
+
"peer-gone-without-close": [term("blackhole", "L3")],
|
|
207
|
+
rollout: [],
|
|
208
|
+
"cpu-throttle": [term("cpu", "process")],
|
|
209
|
+
"authorization-policy": [],
|
|
210
|
+
idle: [],
|
|
211
|
+
"ztunnel-restart": [],
|
|
212
|
+
"certificate-expiry": [term("cert-bad", "TLS")],
|
|
213
|
+
"cannot-serve": [],
|
|
214
|
+
"zone-loss": [term("node-loss", "process")],
|
|
215
|
+
latency: [term("delay", "L3")],
|
|
216
|
+
"dns-blackhole": [term("dns", "L7")]
|
|
217
|
+
};
|
|
218
|
+
/** These are the rig terms of each type of a toxic of Toxiproxy. A slow close and a limit of bandwidth have no word in the rig map. */
|
|
219
|
+
const TOXIC_RIG_TERMS = {
|
|
220
|
+
latency: [term("delay", "L4")],
|
|
221
|
+
timeout: [term("stall", "L4")],
|
|
222
|
+
reset_peer: [term("reset", "L4")],
|
|
223
|
+
slow_close: [],
|
|
224
|
+
bandwidth: [],
|
|
225
|
+
limit_data: [term("cut", "L4")],
|
|
226
|
+
slicer: [term("split-frame", "L7")]
|
|
227
|
+
};
|
|
228
|
+
/** These are the words of tc netem that the rig map names, each with its fault of the map. */
|
|
229
|
+
const NETEM_TERMS = [
|
|
230
|
+
["delay", "delay"],
|
|
231
|
+
["loss", "loss"],
|
|
232
|
+
["duplicate", "duplicate"],
|
|
233
|
+
["reorder", "reorder"],
|
|
234
|
+
["corrupt", "corrupt"]
|
|
235
|
+
];
|
|
236
|
+
/**
|
|
237
|
+
* This function gives the rig terms of a cell. The terms of `netem` come from the words of its setting, and the terms
|
|
238
|
+
* of `toxic` from the type of its toxic. This function throws a `RangeError` for a fault name that `RIG_TERMS` does
|
|
239
|
+
* not have, thus a new fault gets its terms in the same change.
|
|
240
|
+
*/
|
|
241
|
+
function rigTermsOf(cell) {
|
|
242
|
+
const own = RIG_TERMS[cell.fault];
|
|
243
|
+
if (own === void 0) throw new RangeError(`rigTermsOf: the fault ${cell.fault} has no entry in RIG_TERMS.`);
|
|
244
|
+
if (cell.fault === "netem") {
|
|
245
|
+
const words = (cell.netem ?? "").split(/\s+/);
|
|
246
|
+
return NETEM_TERMS.filter(([word]) => words.includes(word)).map(([, fault]) => term(fault, "L3"));
|
|
247
|
+
}
|
|
248
|
+
if (cell.fault === "toxic") {
|
|
249
|
+
if (cell.toxic === void 0) return [];
|
|
250
|
+
const terms = TOXIC_RIG_TERMS[cell.toxic.type];
|
|
251
|
+
if (terms === void 0) throw new RangeError(`rigTermsOf: the toxic ${cell.toxic.type} has no entry in TOXIC_RIG_TERMS.`);
|
|
252
|
+
return terms;
|
|
253
|
+
}
|
|
254
|
+
return own;
|
|
255
|
+
}
|
|
256
|
+
export { LAYERS, LAYER_FACTS, LAYER_RIG_ENV, LIMITS, RIG_TERMS, TOXIC_RIG_TERMS, layerOf, limitsOf, rigTermsOf };
|
|
158
257
|
|
|
159
258
|
//# sourceMappingURL=layers.js.map
|
package/build/layers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layers.js","names":[],"sources":["../src/layers.ts"],"sourcesContent":["import type { Fault, Topology } from \"./cell.ts\";\n\n// This module imports no `node:` module, thus a page in a browser can read the layers (`@mark1russell7/harness/layers`).\n\n/**\n * A layer is a rung of the laboratory (`docs/S7.md`). E1 is containers on one kernel, and E2 is a\n * cluster of containers on one kernel. A lab with `Topology.fabric` writes E3: routers in containers.\n * A lab in a guest of QEMU writes E4 (`substrateHere`). The other layers do not have a runner at this\n * time.\n */\nexport const LAYERS = [\"E0\", \"E1\", \"E2\", \"E3\", \"E4\", \"E5\", \"E6\"] as const;\nexport type Layer = (typeof LAYERS)[number];\n\n/** A layer state is the column \"State\" of the table of the layers in `docs/S7.md`, by its first word. */\nexport type LayerState = \"today\" | \"new\" | \"later\" | \"waiting\";\n\n/**\n * A limit is a resource that the load of a cell fills, with no fault. The five limits are the accept\n * queue, the port range, the conntrack table, the memory of a cgroup and the egress queue of an\n * interface. The name of a limit is the key of its law in `Prediction`.\n */\nexport const LIMITS = [\"queue\", \"ports\", \"conntrack\", \"memory\", \"egress\"] as const;\nexport type Limit = (typeof LIMITS)[number];\n\n/**\n * The layer facts are one row of the table of the layers in `docs/S7.md`, and what the cells of the\n * harness apply on the layer. A test holds each text equal to the table. A test of the cells holds\n * `faults` and `limits` equal to the cells of each layer.\n */\nexport interface LayerFacts {\n /** This text is the column \"What it is\". */\n readonly name: string;\n /** This text is the column \"What it proves\". */\n readonly proves: string;\n /** These texts are the column \"What it cannot prove\", one for each thing. The list is empty for \"Nothing that this plan covers\". */\n readonly cannot: readonly string[];\n /** These names are the column \"Tools\". */\n readonly tools: readonly string[];\n readonly state: LayerState;\n /**\n * These names are the faults that the cells of the layer inject, each one time. A name is in the\n * vocabulary of the lab of the layer. The cells of E1 and E3 name a `Fault` of the harness. The cells of\n * E2 are in `@mark1russell7/kind`, and they name the kind of their trigger (`TriggerKind`). The two\n * vocabularies share the names of the faults that they share, for example `blackhole` and `rst`.\n */\n readonly faults: readonly string[];\n /** These limits are the resources that the load of the cells of the layer fills, in the order of `LIMITS`. */\n readonly limits: readonly Limit[];\n}\n\n/** These are the faults of a cell of one kernel: each fault of the harness except the silence of a fabric. */\nconst ONE_KERNEL: readonly Fault[] = [\n \"blackhole\",\n \"freeze-process\",\n \"rst\",\n \"stall\",\n \"fin\",\n \"unreachable\",\n \"simplex\",\n \"mtu-blackhole\",\n \"netem\",\n \"fin-ack\",\n \"middlebox-forget\",\n \"proxy-idle\",\n \"toxic\",\n \"server-close\",\n \"partition\",\n \"planned-failover\",\n \"app-stall\",\n \"step-down\",\n \"drain\",\n \"hop-event\",\n];\n\n/** These are the faults of a cell of kind: each kind of a trigger of `@mark1russell7/kind`, in the order of `TriggerKind`. */\nconst ON_KIND: readonly string[] = [\n \"pod-deletion\",\n \"rolling-update\",\n \"node-drain\",\n \"scale-in\",\n \"crash\",\n \"liveness-restart\",\n \"freeze-process\",\n \"rst\",\n \"blackhole\",\n \"peer-gone-without-close\",\n \"app-stall\",\n \"rollout\",\n \"cpu-throttle\",\n \"authorization-policy\",\n \"idle\",\n \"ztunnel-restart\",\n \"certificate-expiry\",\n \"cannot-serve\",\n \"zone-loss\",\n \"latency\",\n \"dns-blackhole\",\n];\n\n/** These are the facts of each layer. The texts come from the table of the layers in `docs/S7.md`. */\nexport const LAYER_FACTS: Readonly<Record<Layer, LayerFacts>> = {\n E0: {\n name: \"Code on a false clock\",\n proves: \"The logic of a state machine and each order of its events\",\n cannot: [\"Any real time\"],\n tools: [\"algebra\", \"the service conformance kit\"],\n state: \"today\",\n faults: [],\n limits: [],\n },\n E1: {\n name: \"Processes and containers on one kernel\",\n proves: \"Linux TCP timers, stock servers and their clients, proxies, conntrack\",\n cannot: [\"A second kernel\", \"A separate clock\", \"A reboot\", \"A loss of power\"],\n tools: [\"The harness\"],\n state: \"today\",\n faults: ONE_KERNEL,\n limits: LIMITS,\n },\n E2: {\n name: \"A cluster of containers on one kernel\",\n proves: \"The control plane, Service rules, CNI and the lifecycle of a pod\",\n cannot: [\"A kernel for each node\", \"A loss of a node with no signal\"],\n tools: [\"kind\", \"k3d\"],\n state: \"today\",\n faults: ON_KIND,\n limits: [],\n },\n E3: {\n name: \"A routed fabric of containers on one kernel\",\n proves: \"Routing protocol timers, equal-cost paths, a change of route, sites with real delay\",\n cannot: [\"The kernel or the forwarding hardware of a router\"],\n tools: [\"containerlab with FRR\"],\n state: \"new\",\n faults: [\"blackhole\", \"stall\", \"silence\"] satisfies readonly Fault[],\n limits: [],\n },\n E4: {\n name: \"Virtual machines, each with its own kernel\",\n proves: \"A chosen kernel and HZ, a clock for each node, a loss of power, a disk, a reboot\",\n cannot: [\"A physical NIC\", \"Real zones\"],\n tools: [\"QEMU\", \"k3s in a VM\"],\n state: \"new\",\n faults: [],\n limits: [],\n },\n E5: {\n name: \"Images of vendor routers in virtual machines\",\n proves: \"The defaults and the state machines of a vendor's control plane\",\n cannot: [\"The forwarding chip of the router\"],\n tools: [\"vrnetlab\"],\n state: \"later\",\n faults: [],\n limits: [],\n },\n E6: {\n name: \"Real hardware and clouds\",\n proves: \"A physical NIC, firmware, managed load balancers, real zones\",\n cannot: [],\n tools: [\"HW-1\"],\n state: \"waiting\",\n faults: [],\n limits: [],\n },\n};\n\n/** This function gives the layer of a lab of the harness from its topology: E3 with a fabric, E1 without one. */\nexport const layerOf = (topology: Topology | undefined): Layer => (topology?.fabric === undefined ? \"E1\" : \"E3\");\n\n/**\n * This function gives the limits that the prediction of a cell names, in the order of `LIMITS`. It reads\n * a cell of the harness or of `@mark1russell7/kind`.\n */\nexport const limitsOf = (cell: { readonly prediction: object }): readonly Limit[] => {\n const laws = new Map(Object.entries(cell.prediction));\n return LIMITS.filter((limit) => laws.get(limit) !== undefined);\n};\n"],"mappings":";;;;;;;AAUA,MAAa,SAAS;CAAC;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;AAAI;;;;;;AAW/D,MAAa,SAAS;CAAC;CAAS;CAAS;CAAa;CAAU;AAAQ;;AA+ExE,MAAa,cAAmD;CAC9D,IAAI;EACF,MAAM;EACN,QAAQ;EACR,QAAQ,CAAC,eAAe;EACxB,OAAO,CAAC,WAAW,6BAA6B;EAChD,OAAO;EACP,QAAQ,CAAC;EACT,QAAQ,CAAC;CACX;CACA,IAAI;EACF,MAAM;EACN,QAAQ;EACR,QAAQ;GAAC;GAAmB;GAAoB;GAAY;EAAiB;EAC7E,OAAO,CAAC,aAAa;EACrB,OAAO;EACP,QAAQ;GAhEV;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EA6CU;EACR,QAAQ;CACV;CACA,IAAI;EACF,MAAM;EACN,QAAQ;EACR,QAAQ,CAAC,0BAA0B,iCAAiC;EACpE,OAAO,CAAC,QAAQ,KAAK;EACrB,OAAO;EACP,QAAQ;GAjDV;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EA6BU;EACR,QAAQ,CAAC;CACX;CACA,IAAI;EACF,MAAM;EACN,QAAQ;EACR,QAAQ,CAAC,mDAAmD;EAC5D,OAAO,CAAC,uBAAuB;EAC/B,OAAO;EACP,QAAQ;GAAC;GAAa;GAAS;EAAS;EACxC,QAAQ,CAAC;CACX;CACA,IAAI;EACF,MAAM;EACN,QAAQ;EACR,QAAQ,CAAC,kBAAkB,YAAY;EACvC,OAAO,CAAC,QAAQ,aAAa;EAC7B,OAAO;EACP,QAAQ,CAAC;EACT,QAAQ,CAAC;CACX;CACA,IAAI;EACF,MAAM;EACN,QAAQ;EACR,QAAQ,CAAC,mCAAmC;EAC5C,OAAO,CAAC,UAAU;EAClB,OAAO;EACP,QAAQ,CAAC;EACT,QAAQ,CAAC;CACX;CACA,IAAI;EACF,MAAM;EACN,QAAQ;EACR,QAAQ,CAAC;EACT,OAAO,CAAC,MAAM;EACd,OAAO;EACP,QAAQ,CAAC;EACT,QAAQ,CAAC;CACX;AACF;;AAGA,MAAa,WAAW,aAA2C,UAAU,WAAW,KAAA,IAAY,OAAO;;;;;AAM3G,MAAa,YAAY,SAA4D;CACnF,MAAM,OAAO,IAAI,IAAI,OAAO,QAAQ,KAAK,UAAU,CAAC;CACpD,OAAO,OAAO,QAAQ,UAAU,KAAK,IAAI,KAAK,MAAM,KAAA,CAAS;AAC/D"}
|
|
1
|
+
{"version":3,"file":"layers.js","names":[],"sources":["../src/layers.ts"],"sourcesContent":["import type { Fault, Topology } from \"./cell.ts\";\n\n// This module imports no `node:` module, thus a page in a browser can read the layers (`@mark1russell7/harness/layers`).\n\n/**\n * A layer is a rung of the laboratory (`docs/S7.md`). E1 is containers on one kernel, and E2 is a\n * cluster of containers on one kernel. A lab with `Topology.fabric` writes E3: routers in containers.\n * A lab in a guest of QEMU writes E4 (`substrateHere`). The other layers do not have a runner at this\n * time.\n */\nexport const LAYERS = [\"E0\", \"E1\", \"E2\", \"E3\", \"E4\", \"E5\", \"E6\"] as const;\nexport type Layer = (typeof LAYERS)[number];\n\n/** A layer state is the column \"State\" of the table of the layers in `docs/S7.md`, by its first word. */\nexport type LayerState = \"today\" | \"new\" | \"later\" | \"waiting\";\n\n/**\n * A limit is a resource that the load of a cell fills, with no fault. The five limits are the accept\n * queue, the port range, the conntrack table, the memory of a cgroup and the egress queue of an\n * interface. The name of a limit is the key of its law in `Prediction`.\n */\nexport const LIMITS = [\"queue\", \"ports\", \"conntrack\", \"memory\", \"egress\"] as const;\nexport type Limit = (typeof LIMITS)[number];\n\n/**\n * The layer facts are one row of the table of the layers in `docs/S7.md`, and what the cells of the\n * harness apply on the layer. A test holds each text equal to the table. A test of the cells holds\n * `faults` and `limits` equal to the cells of each layer.\n */\nexport interface LayerFacts {\n /** This text is the column \"What it is\". */\n readonly name: string;\n /** This text is the column \"What it proves\". */\n readonly proves: string;\n /** These texts are the column \"What it cannot prove\", one for each thing. The list is empty for \"Nothing that this plan covers\". */\n readonly cannot: readonly string[];\n /** These names are the column \"Tools\". */\n readonly tools: readonly string[];\n readonly state: LayerState;\n /**\n * These names are the faults that the cells of the layer inject, each one time. A name is in the\n * vocabulary of the lab of the layer. The cells of E1 and E3 name a `Fault` of the harness. The cells of\n * E2 are in `@mark1russell7/kind`, and they name the kind of their trigger (`TriggerKind`). The two\n * vocabularies share the names of the faults that they share, for example `blackhole` and `rst`.\n */\n readonly faults: readonly string[];\n /** These limits are the resources that the load of the cells of the layer fills, in the order of `LIMITS`. */\n readonly limits: readonly Limit[];\n}\n\n/** These are the faults of a cell of one kernel: each fault of the harness except the silence of a fabric. */\nconst ONE_KERNEL: readonly Fault[] = [\n \"blackhole\",\n \"freeze-process\",\n \"rst\",\n \"stall\",\n \"fin\",\n \"unreachable\",\n \"simplex\",\n \"mtu-blackhole\",\n \"netem\",\n \"fin-ack\",\n \"middlebox-forget\",\n \"proxy-idle\",\n \"toxic\",\n \"server-close\",\n \"partition\",\n \"planned-failover\",\n \"app-stall\",\n \"step-down\",\n \"drain\",\n \"hop-event\",\n];\n\n/** These are the faults of a cell of kind: each kind of a trigger of `@mark1russell7/kind`, in the order of `TriggerKind`. */\nconst ON_KIND: readonly string[] = [\n \"pod-deletion\",\n \"rolling-update\",\n \"node-drain\",\n \"scale-in\",\n \"crash\",\n \"liveness-restart\",\n \"freeze-process\",\n \"rst\",\n \"blackhole\",\n \"peer-gone-without-close\",\n \"app-stall\",\n \"rollout\",\n \"cpu-throttle\",\n \"authorization-policy\",\n \"idle\",\n \"ztunnel-restart\",\n \"certificate-expiry\",\n \"cannot-serve\",\n \"zone-loss\",\n \"latency\",\n \"dns-blackhole\",\n];\n\n/** These are the facts of each layer. The texts come from the table of the layers in `docs/S7.md`. */\nexport const LAYER_FACTS: Readonly<Record<Layer, LayerFacts>> = {\n E0: {\n name: \"Code on a false clock\",\n proves: \"The logic of a state machine and each order of its events\",\n cannot: [\"Any real time\"],\n tools: [\"algebra\", \"the service conformance kit\"],\n state: \"today\",\n faults: [],\n limits: [],\n },\n E1: {\n name: \"Processes and containers on one kernel\",\n proves: \"Linux TCP timers, stock servers and their clients, proxies, conntrack\",\n cannot: [\"A second kernel\", \"A separate clock\", \"A reboot\", \"A loss of power\"],\n tools: [\"The harness\"],\n state: \"today\",\n faults: ONE_KERNEL,\n limits: LIMITS,\n },\n E2: {\n name: \"A cluster of containers on one kernel\",\n proves: \"The control plane, Service rules, CNI and the lifecycle of a pod\",\n cannot: [\"A kernel for each node\", \"A loss of a node with no signal\"],\n tools: [\"kind\", \"k3d\"],\n state: \"today\",\n faults: ON_KIND,\n limits: [],\n },\n E3: {\n name: \"A routed fabric of containers on one kernel\",\n proves: \"Routing protocol timers, equal-cost paths, a change of route, sites with real delay\",\n cannot: [\"The kernel or the forwarding hardware of a router\"],\n tools: [\"containerlab with FRR\"],\n state: \"new\",\n faults: [\"blackhole\", \"stall\", \"silence\"] satisfies readonly Fault[],\n limits: [],\n },\n E4: {\n name: \"Virtual machines, each with its own kernel\",\n proves: \"A chosen kernel and HZ, a clock for each node, a loss of power, a disk, a reboot\",\n cannot: [\"A physical NIC\", \"Real zones\"],\n tools: [\"QEMU\", \"k3s in a VM\"],\n state: \"new\",\n faults: [],\n limits: [],\n },\n E5: {\n name: \"Images of vendor routers in virtual machines\",\n proves: \"The defaults and the state machines of a vendor's control plane\",\n cannot: [\"The forwarding chip of the router\"],\n tools: [\"vrnetlab\"],\n state: \"later\",\n faults: [],\n limits: [],\n },\n E6: {\n name: \"Real hardware and clouds\",\n proves: \"A physical NIC, firmware, managed load balancers, real zones\",\n cannot: [],\n tools: [\"HW-1\"],\n state: \"waiting\",\n faults: [],\n limits: [],\n },\n};\n\n/** This function gives the layer of a lab of the harness from its topology: E3 with a fabric, E1 without one. */\nexport const layerOf = (topology: Topology | undefined): Layer => (topology?.fabric === undefined ? \"E1\" : \"E3\");\n\n/**\n * This function gives the limits that the prediction of a cell names, in the order of `LIMITS`. It reads\n * a cell of the harness or of `@mark1russell7/kind`.\n */\nexport const limitsOf = (cell: { readonly prediction: object }): readonly Limit[] => {\n const laws = new Map(Object.entries(cell.prediction));\n return LIMITS.filter((limit) => laws.get(limit) !== undefined);\n};\n\n/**\n * A rig term is one pair of the space of the rig map of rigor: a fault and the layer that the fault acts on. It uses\n * the words of that map. The rig records of this repository (`docs/rigs.json`) name these pairs.\n */\nexport interface RigTerm {\n readonly fault: string;\n readonly layer: string;\n}\n\n/** These are the environments of the rig map for the layers. E0 has no environment: it runs no lab. */\nexport const LAYER_RIG_ENV: Readonly<Record<Layer, string | undefined>> = {\n E0: undefined,\n E1: \"container\",\n E2: \"kind\",\n E3: \"fabric\",\n E4: \"vm\",\n E5: \"vendor\",\n E6: \"hardware\",\n};\n\nconst term = (fault: string, layer: string): RigTerm => ({ fault, layer });\n\n/**\n * These are the rig terms of each fault name of the labs: the faults of the harness and the kinds of the triggers of\n * `@mark1russell7/kind`. The two vocabularies share the names that they share. An empty list is a fault that the rig\n * map has no word for at this time. Examples are a stop with its grace, a planned failover, a drain and an ICMP\n * unreachable. The terms of `netem` and `toxic` come from the settings of the cell (`rigTermsOf`).\n */\nexport const RIG_TERMS: Readonly<Record<string, readonly RigTerm[]>> = {\n // The faults of the harness.\n blackhole: [term(\"blackhole\", \"L3\")],\n \"freeze-process\": [term(\"freeze\", \"process\")],\n rst: [term(\"reset\", \"L4\")],\n stall: [term(\"stall\", \"L3\")],\n fin: [term(\"kill\", \"process\")],\n unreachable: [],\n simplex: [term(\"blackhole\", \"L3\")],\n \"mtu-blackhole\": [term(\"mtu\", \"L3\")],\n netem: [],\n \"fin-ack\": [term(\"loss\", \"L4\")],\n \"middlebox-forget\": [term(\"cut\", \"L4\")],\n \"proxy-idle\": [term(\"cut\", \"L7\")],\n toxic: [],\n \"server-close\": [term(\"cut\", \"L7\")],\n partition: [term(\"partition\", \"L3\")],\n \"planned-failover\": [],\n \"app-stall\": [term(\"stall\", \"L7\")],\n \"step-down\": [],\n drain: [],\n \"hop-event\": [],\n silence: [term(\"blackhole\", \"L3\")],\n // A calibration cell injects nothing.\n none: [],\n // The kinds of the triggers of kind that the harness does not name.\n \"pod-deletion\": [],\n \"rolling-update\": [],\n \"node-drain\": [],\n \"scale-in\": [],\n crash: [term(\"kill\", \"process\")],\n \"liveness-restart\": [term(\"kill\", \"process\")],\n \"peer-gone-without-close\": [term(\"blackhole\", \"L3\")],\n rollout: [],\n \"cpu-throttle\": [term(\"cpu\", \"process\")],\n \"authorization-policy\": [],\n idle: [],\n \"ztunnel-restart\": [],\n \"certificate-expiry\": [term(\"cert-bad\", \"TLS\")],\n \"cannot-serve\": [],\n \"zone-loss\": [term(\"node-loss\", \"process\")],\n latency: [term(\"delay\", \"L3\")],\n \"dns-blackhole\": [term(\"dns\", \"L7\")],\n};\n\n/** These are the rig terms of each type of a toxic of Toxiproxy. A slow close and a limit of bandwidth have no word in the rig map. */\nexport const TOXIC_RIG_TERMS: Readonly<Record<string, readonly RigTerm[]>> = {\n latency: [term(\"delay\", \"L4\")],\n timeout: [term(\"stall\", \"L4\")],\n reset_peer: [term(\"reset\", \"L4\")],\n slow_close: [],\n bandwidth: [],\n limit_data: [term(\"cut\", \"L4\")],\n slicer: [term(\"split-frame\", \"L7\")],\n};\n\n/** These are the words of tc netem that the rig map names, each with its fault of the map. */\nconst NETEM_TERMS: readonly (readonly [string, string])[] = [\n [\"delay\", \"delay\"],\n [\"loss\", \"loss\"],\n [\"duplicate\", \"duplicate\"],\n [\"reorder\", \"reorder\"],\n [\"corrupt\", \"corrupt\"],\n];\n\n/** These parts of a cell tell its rig terms. A cell of kind gives the kind of its trigger as `fault`. */\nexport interface RigTermCell {\n readonly fault: string;\n readonly toxic?: { readonly type: string } | undefined;\n readonly netem?: string | undefined;\n}\n\n/**\n * This function gives the rig terms of a cell. The terms of `netem` come from the words of its setting, and the terms\n * of `toxic` from the type of its toxic. This function throws a `RangeError` for a fault name that `RIG_TERMS` does\n * not have, thus a new fault gets its terms in the same change.\n */\nexport function rigTermsOf(cell: RigTermCell): readonly RigTerm[] {\n const own = RIG_TERMS[cell.fault];\n if (own === undefined) throw new RangeError(`rigTermsOf: the fault ${cell.fault} has no entry in RIG_TERMS.`);\n if (cell.fault === \"netem\") {\n const words = (cell.netem ?? \"\").split(/\\s+/);\n return NETEM_TERMS.filter(([word]) => words.includes(word)).map(([, fault]) => term(fault, \"L3\"));\n }\n if (cell.fault === \"toxic\") {\n if (cell.toxic === undefined) return [];\n const terms = TOXIC_RIG_TERMS[cell.toxic.type];\n if (terms === undefined) throw new RangeError(`rigTermsOf: the toxic ${cell.toxic.type} has no entry in TOXIC_RIG_TERMS.`);\n return terms;\n }\n return own;\n}\n"],"mappings":";;;;;;;AAUA,MAAa,SAAS;CAAC;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;AAAI;;;;;;AAW/D,MAAa,SAAS;CAAC;CAAS;CAAS;CAAa;CAAU;AAAQ;;AA+ExE,MAAa,cAAmD;CAC9D,IAAI;EACF,MAAM;EACN,QAAQ;EACR,QAAQ,CAAC,eAAe;EACxB,OAAO,CAAC,WAAW,6BAA6B;EAChD,OAAO;EACP,QAAQ,CAAC;EACT,QAAQ,CAAC;CACX;CACA,IAAI;EACF,MAAM;EACN,QAAQ;EACR,QAAQ;GAAC;GAAmB;GAAoB;GAAY;EAAiB;EAC7E,OAAO,CAAC,aAAa;EACrB,OAAO;EACP,QAAQ;GAhEV;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EA6CU;EACR,QAAQ;CACV;CACA,IAAI;EACF,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,CAAC;CAC7B,iBAAiB,CAAC,KAAK,OAAO,IAAI,CAAC;AACrC;;AAGA,MAAa,kBAAgE;CAC3E,SAAS,CAAC,KAAK,SAAS,IAAI,CAAC;CAC7B,SAAS,CAAC,KAAK,SAAS,IAAI,CAAC;CAC7B,YAAY,CAAC,KAAK,SAAS,IAAI,CAAC;CAChC,YAAY,CAAC;CACb,WAAW,CAAC;CACZ,YAAY,CAAC,KAAK,OAAO,IAAI,CAAC;CAC9B,QAAQ,CAAC,KAAK,eAAe,IAAI,CAAC;AACpC;;AAGA,MAAM,cAAsD;CAC1D,CAAC,SAAS,OAAO;CACjB,CAAC,QAAQ,MAAM;CACf,CAAC,aAAa,WAAW;CACzB,CAAC,WAAW,SAAS;CACrB,CAAC,WAAW,SAAS;AACvB;;;;;;AAcA,SAAgB,WAAW,MAAuC;CAChE,MAAM,MAAM,UAAU,KAAK;CAC3B,IAAI,QAAQ,KAAA,GAAW,MAAM,IAAI,WAAW,yBAAyB,KAAK,MAAM,4BAA4B;CAC5G,IAAI,KAAK,UAAU,SAAS;EAC1B,MAAM,SAAS,KAAK,SAAS,GAAA,CAAI,MAAM,KAAK;EAC5C,OAAO,YAAY,QAAQ,CAAC,UAAU,MAAM,SAAS,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,WAAW,KAAK,OAAO,IAAI,CAAC;CAClG;CACA,IAAI,KAAK,UAAU,SAAS;EAC1B,IAAI,KAAK,UAAU,KAAA,GAAW,OAAO,CAAC;EACtC,MAAM,QAAQ,gBAAgB,KAAK,MAAM;EACzC,IAAI,UAAU,KAAA,GAAW,MAAM,IAAI,WAAW,yBAAyB,KAAK,MAAM,KAAK,kCAAkC;EACzH,OAAO;CACT;CACA,OAAO;AACT"}
|
package/image/lazyfs/start.mts
CHANGED
|
@@ -6,14 +6,23 @@
|
|
|
6
6
|
* descriptor 3, and this process keeps the reader open. Thus LazyFS starts at once, and a write after a reader went away
|
|
7
7
|
* does not stop it.
|
|
8
8
|
*
|
|
9
|
+
* LazyFS answers only `lazyfs::clear-cache` on `done.fifo`. Thus this process reads the log of LazyFS, and writes one line
|
|
10
|
+
* to `acks` for each answer to a fault command: `ok` when LazyFS took the fault, `error` when it refused the fault.
|
|
11
|
+
*
|
|
9
12
|
* This process is PID 1 of the container. It gives `SIGTERM` and `SIGINT` to LazyFS, and it ends with the exit of LazyFS.
|
|
13
|
+
* When the file `armed` exists, the end of LazyFS is a fault: this process writes the exit of LazyFS to `exit`, and keeps
|
|
14
|
+
* the container for the check until a signal.
|
|
10
15
|
*/
|
|
11
16
|
import { execFileSync, spawn } from "node:child_process";
|
|
12
|
-
import { constants, openSync } from "node:fs";
|
|
17
|
+
import { appendFileSync, constants, existsSync, openSync, writeFileSync } from "node:fs";
|
|
13
18
|
import { constants as os } from "node:os";
|
|
19
|
+
import type { Readable } from "node:stream";
|
|
14
20
|
|
|
15
21
|
const FAULTS = "/run/lazyfs/faults.fifo";
|
|
16
22
|
const DONE = "/run/lazyfs/done.fifo";
|
|
23
|
+
const ARMED = "/run/lazyfs/armed";
|
|
24
|
+
const EXIT = "/run/lazyfs/exit";
|
|
25
|
+
const ACKS = "/run/lazyfs/acks";
|
|
17
26
|
|
|
18
27
|
execFileSync("mkfifo", [FAULTS, DONE], { stdio: "inherit" });
|
|
19
28
|
// On Linux, an open of a FIFO to read and write does not wait for the other end, the same as `exec 3<>` of a shell
|
|
@@ -21,13 +30,43 @@ const reader = openSync(DONE, constants.O_RDWR);
|
|
|
21
30
|
const lazyfs = spawn(
|
|
22
31
|
"/usr/local/bin/lazyfs",
|
|
23
32
|
["/mnt/disk", "--config-path", "/etc/lazyfs/config.toml", "-o", "allow_other", "-o", "modules=subdir", "-o", "subdir=/var/disk", "-f"],
|
|
24
|
-
{ stdio: ["inherit", "
|
|
33
|
+
{ stdio: ["inherit", "pipe", "pipe", reader] },
|
|
25
34
|
);
|
|
26
|
-
|
|
35
|
+
|
|
36
|
+
/** This function copies a stream of the log of LazyFS to the log of the container, and writes each answer to `acks`. */
|
|
37
|
+
const watch = (from: Readable, to: NodeJS.WriteStream): void => {
|
|
38
|
+
let rest = "";
|
|
39
|
+
from.on("data", (chunk: Buffer) => {
|
|
40
|
+
to.write(chunk);
|
|
41
|
+
const lines = (rest + chunk.toString("utf8")).split("\n");
|
|
42
|
+
rest = lines.pop() ?? "";
|
|
43
|
+
for (const line of lines) {
|
|
44
|
+
if (line.includes("configured successfully") || line.includes("received: VALID crash fault")) appendFileSync(ACKS, `ok ${line}\n`);
|
|
45
|
+
else if (line.includes("received: INVALID")) appendFileSync(ACKS, `error ${line}\n`);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
if (lazyfs.stdout !== null) watch(lazyfs.stdout, process.stdout);
|
|
50
|
+
if (lazyfs.stderr !== null) watch(lazyfs.stderr, process.stderr);
|
|
51
|
+
|
|
52
|
+
let ended = false;
|
|
53
|
+
for (const signal of ["SIGTERM", "SIGINT"] as const) {
|
|
54
|
+
process.on(signal, () => {
|
|
55
|
+
if (ended) process.exit(0);
|
|
56
|
+
lazyfs.kill(signal);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
27
59
|
lazyfs.on("error", (error) => {
|
|
28
60
|
console.error(`LazyFS did not start: ${error.message}`);
|
|
29
61
|
process.exit(1);
|
|
30
62
|
});
|
|
31
63
|
lazyfs.on("exit", (code, signal) => {
|
|
64
|
+
ended = true;
|
|
65
|
+
if (existsSync(ARMED)) {
|
|
66
|
+
writeFileSync(EXIT, signal === null ? `code=${String(code)}\n` : `signal=${signal}\n`);
|
|
67
|
+
// The timer keeps this process, and with it the container, until a signal
|
|
68
|
+
setInterval(() => undefined, 1 << 30);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
32
71
|
process.exit(code ?? (signal === null ? 1 : 128 + os.signals[signal]));
|
|
33
72
|
});
|
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.16.
|
|
4
|
+
"version": "0.16.30",
|
|
5
5
|
"description": "Network labs in Docker, declared as data. A cell builds a topology of networks, routers and proxies around a stock target. It injects a fault at layer 3 or 4 from a NET_ADMIN sidecar, measures the records of the kernel and judges a prediction. The faults are black holes, resets, ICMP unreachable, one-way and MTU drops, tc netem, the toxics of Toxiproxy and frozen processes. Its disk tier cuts the power of a program on LazyFS: the disk loses each write after the last fsync. Its memory tier sets the limits of the cgroup of a client, and judges its throttle above memory.high and the choice of the OOM killer. Its egress tier puts a netem or tbf qdisc on the interface of a client, and judges the departure of each datagram from the stamps of the kernel. Its replicated groups are Redis with Sentinels, MongoDB replica sets, PostgreSQL standbys, Kafka, RabbitMQ and BGP fabrics with BFD. A lab can also operate in a QEMU guest. Its first use is connection timers: keep-alive, TCP retransmission, heartbeats and reconnects.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"fault-injection",
|
|
@@ -124,11 +124,12 @@
|
|
|
124
124
|
},
|
|
125
125
|
"dependencies": {
|
|
126
126
|
"@mark1russell7/prober": "^0.3.7",
|
|
127
|
-
"@mark1russell7/quantity": "^0.5.
|
|
127
|
+
"@mark1russell7/quantity": "^0.5.3",
|
|
128
128
|
"@mark1russell7/rigor-bench": "^0.2.10",
|
|
129
|
-
"@mark1russell7/rigor-chaos": "^0.
|
|
129
|
+
"@mark1russell7/rigor-chaos": "^0.5.0",
|
|
130
130
|
"@mark1russell7/rigor-statistics": "^0.2.1",
|
|
131
131
|
"@mark1russell7/rigor-testkit": "^0.1.14",
|
|
132
|
+
"@mark1russell7/text": "^0.0.28",
|
|
132
133
|
"semver": "^7.8.5",
|
|
133
134
|
"testcontainers": "12.2.1"
|
|
134
135
|
},
|