@mark1russell7/harness 0.16.8 → 0.16.10
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 +4 -0
- package/build/index.d.ts +13 -9
- package/build/index.js +42 -19
- package/build/index.js.map +1 -1
- package/build/layers.d.ts +54 -0
- package/build/layers.js +159 -0
- package/build/layers.js.map +1 -0
- package/image/native/src/bin/ports.rs +33 -1
- package/image/native/src/lib.rs +111 -2
- package/package.json +5 -1
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Ut as Topology } from "./cell-CYOKWfwg.js";
|
|
2
|
+
/**
|
|
3
|
+
* A layer is a rung of the laboratory (`docs/S7.md`). E1 is containers on one kernel, and E2 is a
|
|
4
|
+
* cluster of containers on one kernel. A lab with `Topology.fabric` writes E3: routers in containers.
|
|
5
|
+
* A lab in a guest of QEMU writes E4 (`substrateHere`). The other layers do not have a runner at this
|
|
6
|
+
* time.
|
|
7
|
+
*/
|
|
8
|
+
export declare const LAYERS: readonly ["E0", "E1", "E2", "E3", "E4", "E5", "E6"];
|
|
9
|
+
export type Layer = (typeof LAYERS)[number];
|
|
10
|
+
/** A layer state is the column "State" of the table of the layers in `docs/S7.md`, by its first word. */
|
|
11
|
+
export type LayerState = "today" | "new" | "later" | "waiting";
|
|
12
|
+
/**
|
|
13
|
+
* A limit is a resource that the load of a cell fills, with no fault. The five limits are the accept
|
|
14
|
+
* queue, the port range, the conntrack table, the memory of a cgroup and the egress queue of an
|
|
15
|
+
* interface. The name of a limit is the key of its law in `Prediction`.
|
|
16
|
+
*/
|
|
17
|
+
export declare const LIMITS: readonly ["queue", "ports", "conntrack", "memory", "egress"];
|
|
18
|
+
export type Limit = (typeof LIMITS)[number];
|
|
19
|
+
/**
|
|
20
|
+
* The layer facts are one row of the table of the layers in `docs/S7.md`, and what the cells of the
|
|
21
|
+
* harness apply on the layer. A test holds each text equal to the table. A test of the cells holds
|
|
22
|
+
* `faults` and `limits` equal to the cells of each layer.
|
|
23
|
+
*/
|
|
24
|
+
export interface LayerFacts {
|
|
25
|
+
/** This text is the column "What it is". */
|
|
26
|
+
readonly name: string;
|
|
27
|
+
/** This text is the column "What it proves". */
|
|
28
|
+
readonly proves: string;
|
|
29
|
+
/** These texts are the column "What it cannot prove", one for each thing. The list is empty for "Nothing that this plan covers". */
|
|
30
|
+
readonly cannot: readonly string[];
|
|
31
|
+
/** These names are the column "Tools". */
|
|
32
|
+
readonly tools: readonly string[];
|
|
33
|
+
readonly state: LayerState;
|
|
34
|
+
/**
|
|
35
|
+
* These names are the faults that the cells of the layer inject, each one time. A name is in the
|
|
36
|
+
* vocabulary of the lab of the layer. The cells of E1 and E3 name a `Fault` of the harness. The cells of
|
|
37
|
+
* E2 are in `@mark1russell7/kind`, and they name the kind of their trigger (`TriggerKind`). The two
|
|
38
|
+
* vocabularies share the names of the faults that they share, for example `blackhole` and `rst`.
|
|
39
|
+
*/
|
|
40
|
+
readonly faults: readonly string[];
|
|
41
|
+
/** These limits are the resources that the load of the cells of the layer fills, in the order of `LIMITS`. */
|
|
42
|
+
readonly limits: readonly Limit[];
|
|
43
|
+
}
|
|
44
|
+
/** These are the facts of each layer. The texts come from the table of the layers in `docs/S7.md`. */
|
|
45
|
+
export declare const LAYER_FACTS: Readonly<Record<Layer, LayerFacts>>;
|
|
46
|
+
/** This function gives the layer of a lab of the harness from its topology: E3 with a fabric, E1 without one. */
|
|
47
|
+
export declare const layerOf: (topology: Topology | undefined) => Layer;
|
|
48
|
+
/**
|
|
49
|
+
* This function gives the limits that the prediction of a cell names, in the order of `LIMITS`. It reads
|
|
50
|
+
* a cell of the harness or of `@mark1russell7/kind`.
|
|
51
|
+
*/
|
|
52
|
+
export declare const limitsOf: (cell: {
|
|
53
|
+
readonly prediction: object;
|
|
54
|
+
}) => readonly Limit[];
|
package/build/layers.js
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
// src/layers.ts
|
|
2
|
+
/**
|
|
3
|
+
* A layer is a rung of the laboratory (`docs/S7.md`). E1 is containers on one kernel, and E2 is a
|
|
4
|
+
* cluster of containers on one kernel. A lab with `Topology.fabric` writes E3: routers in containers.
|
|
5
|
+
* A lab in a guest of QEMU writes E4 (`substrateHere`). The other layers do not have a runner at this
|
|
6
|
+
* time.
|
|
7
|
+
*/
|
|
8
|
+
const LAYERS = [
|
|
9
|
+
"E0",
|
|
10
|
+
"E1",
|
|
11
|
+
"E2",
|
|
12
|
+
"E3",
|
|
13
|
+
"E4",
|
|
14
|
+
"E5",
|
|
15
|
+
"E6"
|
|
16
|
+
];
|
|
17
|
+
/**
|
|
18
|
+
* A limit is a resource that the load of a cell fills, with no fault. The five limits are the accept
|
|
19
|
+
* queue, the port range, the conntrack table, the memory of a cgroup and the egress queue of an
|
|
20
|
+
* interface. The name of a limit is the key of its law in `Prediction`.
|
|
21
|
+
*/
|
|
22
|
+
const LIMITS = [
|
|
23
|
+
"queue",
|
|
24
|
+
"ports",
|
|
25
|
+
"conntrack",
|
|
26
|
+
"memory",
|
|
27
|
+
"egress"
|
|
28
|
+
];
|
|
29
|
+
/** These are the facts of each layer. The texts come from the table of the layers in `docs/S7.md`. */
|
|
30
|
+
const LAYER_FACTS = {
|
|
31
|
+
E0: {
|
|
32
|
+
name: "Code on a false clock",
|
|
33
|
+
proves: "The logic of a state machine and each order of its events",
|
|
34
|
+
cannot: ["Any real time"],
|
|
35
|
+
tools: ["algebra", "the service conformance kit"],
|
|
36
|
+
state: "today",
|
|
37
|
+
faults: [],
|
|
38
|
+
limits: []
|
|
39
|
+
},
|
|
40
|
+
E1: {
|
|
41
|
+
name: "Processes and containers on one kernel",
|
|
42
|
+
proves: "Linux TCP timers, stock servers and their clients, proxies, conntrack",
|
|
43
|
+
cannot: [
|
|
44
|
+
"A second kernel",
|
|
45
|
+
"A separate clock",
|
|
46
|
+
"A reboot",
|
|
47
|
+
"A loss of power"
|
|
48
|
+
],
|
|
49
|
+
tools: ["The harness"],
|
|
50
|
+
state: "today",
|
|
51
|
+
faults: [
|
|
52
|
+
"blackhole",
|
|
53
|
+
"freeze-process",
|
|
54
|
+
"rst",
|
|
55
|
+
"stall",
|
|
56
|
+
"fin",
|
|
57
|
+
"unreachable",
|
|
58
|
+
"simplex",
|
|
59
|
+
"mtu-blackhole",
|
|
60
|
+
"netem",
|
|
61
|
+
"fin-ack",
|
|
62
|
+
"middlebox-forget",
|
|
63
|
+
"proxy-idle",
|
|
64
|
+
"toxic",
|
|
65
|
+
"server-close",
|
|
66
|
+
"partition",
|
|
67
|
+
"planned-failover",
|
|
68
|
+
"app-stall",
|
|
69
|
+
"step-down",
|
|
70
|
+
"drain",
|
|
71
|
+
"hop-event"
|
|
72
|
+
],
|
|
73
|
+
limits: LIMITS
|
|
74
|
+
},
|
|
75
|
+
E2: {
|
|
76
|
+
name: "A cluster of containers on one kernel",
|
|
77
|
+
proves: "The control plane, Service rules, CNI and the lifecycle of a pod",
|
|
78
|
+
cannot: ["A kernel for each node", "A loss of a node with no signal"],
|
|
79
|
+
tools: ["kind", "k3d"],
|
|
80
|
+
state: "today",
|
|
81
|
+
faults: [
|
|
82
|
+
"pod-deletion",
|
|
83
|
+
"rolling-update",
|
|
84
|
+
"node-drain",
|
|
85
|
+
"scale-in",
|
|
86
|
+
"crash",
|
|
87
|
+
"liveness-restart",
|
|
88
|
+
"freeze-process",
|
|
89
|
+
"rst",
|
|
90
|
+
"blackhole",
|
|
91
|
+
"peer-gone-without-close",
|
|
92
|
+
"app-stall",
|
|
93
|
+
"rollout",
|
|
94
|
+
"cpu-throttle",
|
|
95
|
+
"authorization-policy",
|
|
96
|
+
"idle",
|
|
97
|
+
"ztunnel-restart",
|
|
98
|
+
"certificate-expiry",
|
|
99
|
+
"cannot-serve",
|
|
100
|
+
"zone-loss",
|
|
101
|
+
"latency",
|
|
102
|
+
"dns-blackhole"
|
|
103
|
+
],
|
|
104
|
+
limits: []
|
|
105
|
+
},
|
|
106
|
+
E3: {
|
|
107
|
+
name: "A routed fabric of containers on one kernel",
|
|
108
|
+
proves: "Routing protocol timers, equal-cost paths, a change of route, sites with real delay",
|
|
109
|
+
cannot: ["The kernel or the forwarding hardware of a router"],
|
|
110
|
+
tools: ["containerlab with FRR"],
|
|
111
|
+
state: "new",
|
|
112
|
+
faults: [
|
|
113
|
+
"blackhole",
|
|
114
|
+
"stall",
|
|
115
|
+
"silence"
|
|
116
|
+
],
|
|
117
|
+
limits: []
|
|
118
|
+
},
|
|
119
|
+
E4: {
|
|
120
|
+
name: "Virtual machines, each with its own kernel",
|
|
121
|
+
proves: "A chosen kernel and HZ, a clock for each node, a loss of power, a disk, a reboot",
|
|
122
|
+
cannot: ["A physical NIC", "Real zones"],
|
|
123
|
+
tools: ["QEMU", "k3s in a VM"],
|
|
124
|
+
state: "new",
|
|
125
|
+
faults: [],
|
|
126
|
+
limits: []
|
|
127
|
+
},
|
|
128
|
+
E5: {
|
|
129
|
+
name: "Images of vendor routers in virtual machines",
|
|
130
|
+
proves: "The defaults and the state machines of a vendor's control plane",
|
|
131
|
+
cannot: ["The forwarding chip of the router"],
|
|
132
|
+
tools: ["vrnetlab"],
|
|
133
|
+
state: "later",
|
|
134
|
+
faults: [],
|
|
135
|
+
limits: []
|
|
136
|
+
},
|
|
137
|
+
E6: {
|
|
138
|
+
name: "Real hardware and clouds",
|
|
139
|
+
proves: "A physical NIC, firmware, managed load balancers, real zones",
|
|
140
|
+
cannot: [],
|
|
141
|
+
tools: ["HW-1"],
|
|
142
|
+
state: "waiting",
|
|
143
|
+
faults: [],
|
|
144
|
+
limits: []
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
/** This function gives the layer of a lab of the harness from its topology: E3 with a fabric, E1 without one. */
|
|
148
|
+
const layerOf = (topology) => topology?.fabric === void 0 ? "E1" : "E3";
|
|
149
|
+
/**
|
|
150
|
+
* This function gives the limits that the prediction of a cell names, in the order of `LIMITS`. It reads
|
|
151
|
+
* a cell of the harness or of `@mark1russell7/kind`.
|
|
152
|
+
*/
|
|
153
|
+
const limitsOf = (cell) => {
|
|
154
|
+
const laws = new Map(Object.entries(cell.prediction));
|
|
155
|
+
return LIMITS.filter((limit) => laws.get(limit) !== void 0);
|
|
156
|
+
};
|
|
157
|
+
export { LAYERS, LAYER_FACTS, LIMITS, layerOf, limitsOf };
|
|
158
|
+
|
|
159
|
+
//# sourceMappingURL=layers.js.map
|
|
@@ -0,0 +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"}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
//!
|
|
9
9
|
//! The target listens on PORT and on PORT + 2, the two destinations of a cell. It serves one command
|
|
10
10
|
//! on PORT + 1, its control port: `close COUNT` waits until it holds COUNT connections, and closes them.
|
|
11
|
+
//! `stack` gives the counters of the network stack of the target (`stack_counters`).
|
|
11
12
|
//!
|
|
12
13
|
//! The client does these steps in each round:
|
|
13
14
|
//!
|
|
@@ -22,6 +23,10 @@
|
|
|
22
23
|
//! closes it, and waits `--settle-ms`. With `--reclaim`, the client reads each FIN first. It then
|
|
23
24
|
//! writes `closing` and closes each connection. It connects again as after `--close client`.
|
|
24
25
|
//!
|
|
26
|
+
//! Before its first round and after its last round, the client writes two `stack` lines: the counters
|
|
27
|
+
//! of its own network stack, then those of the target. The change of a counter between the two lines
|
|
28
|
+
//! tells where a segment went, for example a drop at a full backlog or an ACK that the target skipped.
|
|
29
|
+
//!
|
|
25
30
|
//! With `--mode inflight`, the client writes `ready` and waits for the file `/tmp/go` before its first
|
|
26
31
|
//! round. The harness makes this file after it applies the fault, thus the fault acts on each round.
|
|
27
32
|
//!
|
|
@@ -30,7 +35,7 @@
|
|
|
30
35
|
//! reset and holds no port. A FIN at the exit of the client holds that port in TIME_WAIT for 60 s. A
|
|
31
36
|
//! range of 3 has only 2 ports for a search. Thus the third run of an environment had no control port.
|
|
32
37
|
|
|
33
|
-
use harness_native::emit;
|
|
38
|
+
use harness_native::{emit, stack_counters};
|
|
34
39
|
use prober::{errno_name, monotonic_ns};
|
|
35
40
|
use serde_json::{json, Value};
|
|
36
41
|
use std::error::Error;
|
|
@@ -83,6 +88,7 @@ fn serve(stream: TcpStream, held: &Mutex<Vec<TcpStream>>) -> Result<(), Box<dyn
|
|
|
83
88
|
let mut words = line.split_whitespace();
|
|
84
89
|
let reply = match (words.next(), words.next().and_then(|word| word.parse::<usize>().ok())) {
|
|
85
90
|
(Some("close"), Some(count)) => json!({ "closed": close_held(held, count) }),
|
|
91
|
+
(Some("stack"), None) if line.trim() == "stack" => json!({ "stack": stack_counters() }),
|
|
86
92
|
_ => json!({ "refused": line }),
|
|
87
93
|
};
|
|
88
94
|
writeln!(writer, "{reply}")?;
|
|
@@ -195,6 +201,14 @@ impl Control {
|
|
|
195
201
|
}
|
|
196
202
|
}
|
|
197
203
|
|
|
204
|
+
/// Writes the two `stack` lines: the counters of the client, then those of the target, at the point `at`.
|
|
205
|
+
fn stack_lines(at: &str, control: &mut Control) -> Result<(), Box<dyn Error>> {
|
|
206
|
+
emit("stack", json!({ "side": "client", "at": at, "counters": stack_counters() }));
|
|
207
|
+
let reply = control.ask("stack")?;
|
|
208
|
+
emit("stack", json!({ "side": "target", "at": at, "counters": reply["stack"] }));
|
|
209
|
+
Ok(())
|
|
210
|
+
}
|
|
211
|
+
|
|
198
212
|
/// Closes a connection with a reset: SO_LINGER with a time of 0, then close(2).
|
|
199
213
|
fn reset(stream: TcpStream) -> std::io::Result<()> {
|
|
200
214
|
abortive(&stream)
|
|
@@ -340,6 +354,7 @@ fn client(args: &[String]) -> Result<(), Box<dyn Error>> {
|
|
|
340
354
|
std::thread::sleep(Duration::from_millis(1));
|
|
341
355
|
}
|
|
342
356
|
}
|
|
357
|
+
stack_lines("start", &mut control)?;
|
|
343
358
|
for index in 0..plan.rounds {
|
|
344
359
|
let mut held = Vec::new();
|
|
345
360
|
for destination in &destinations {
|
|
@@ -347,6 +362,7 @@ fn client(args: &[String]) -> Result<(), Box<dyn Error>> {
|
|
|
347
362
|
}
|
|
348
363
|
close_round(&plan, destinations[0], &mut control, held)?;
|
|
349
364
|
}
|
|
365
|
+
stack_lines("end", &mut control)?;
|
|
350
366
|
emit("done", json!({}));
|
|
351
367
|
Ok(())
|
|
352
368
|
}
|
|
@@ -389,6 +405,22 @@ mod tests {
|
|
|
389
405
|
assert!(plan_of(&["--close".to_string(), "soon".to_string(), "h".to_string(), "1".to_string()]).is_err());
|
|
390
406
|
}
|
|
391
407
|
|
|
408
|
+
#[test]
|
|
409
|
+
fn the_control_port_gives_the_counters_of_the_stack_and_refuses_another_word() {
|
|
410
|
+
let listener = TcpListener::bind((Ipv4Addr::LOCALHOST, 0)).expect("a listener");
|
|
411
|
+
let address = listener.local_addr().expect("an address");
|
|
412
|
+
let held = Arc::new(Mutex::new(Vec::new()));
|
|
413
|
+
std::thread::spawn(move || {
|
|
414
|
+
let (stream, _) = listener.accept().expect("an accept");
|
|
415
|
+
serve(stream, &held).expect("the control lines");
|
|
416
|
+
});
|
|
417
|
+
let stream = TcpStream::connect(address).expect("a connect");
|
|
418
|
+
let mut control = Control { reader: BufReader::new(stream.try_clone().expect("a clone")), writer: stream };
|
|
419
|
+
let reply = control.ask("stack").expect("a reply");
|
|
420
|
+
assert!(reply["stack"]["Tcp.ActiveOpens"].as_u64().is_some(), "{reply}");
|
|
421
|
+
assert_eq!(control.ask("stack now").expect("a reply")["refused"], "stack now");
|
|
422
|
+
}
|
|
423
|
+
|
|
392
424
|
#[test]
|
|
393
425
|
fn a_range_with_no_free_port_is_refused_with_its_name() {
|
|
394
426
|
assert_eq!(errno_of(&std::io::Error::from_raw_os_error(libc::EADDRNOTAVAIL)), "EADDRNOTAVAIL");
|
package/image/native/src/lib.rs
CHANGED
|
@@ -1,10 +1,84 @@
|
|
|
1
|
-
//! What the programs of the harness's native side share: their event lines
|
|
2
|
-
//! schedule.
|
|
1
|
+
//! What the programs of the harness's native side share: their event lines, the arrivals of a
|
|
2
|
+
//! schedule and the counters of the network stack.
|
|
3
3
|
|
|
4
4
|
use prober::monotonic_ns;
|
|
5
5
|
use serde_json::{json, Value};
|
|
6
|
+
use std::collections::BTreeMap;
|
|
6
7
|
use std::error::Error;
|
|
7
8
|
|
|
9
|
+
/// The counters of the network stack, each by its name, for example `Tcp.RetransSegs`,
|
|
10
|
+
/// `TcpExt.TCPACKSkippedTimeWait`, `Dev.eth0.rx_drop` or `Softnet.dropped`. The files of snmp,
|
|
11
|
+
/// netstat and dev are of the namespace of the caller. The file softnet_stat is of the host.
|
|
12
|
+
pub fn stack_counters() -> BTreeMap<String, u64> {
|
|
13
|
+
let read = |path: &str| std::fs::read_to_string(path).unwrap_or_default();
|
|
14
|
+
let mut counters = pairs_of(&read("/proc/net/snmp"));
|
|
15
|
+
counters.extend(pairs_of(&read("/proc/net/netstat")));
|
|
16
|
+
counters.extend(devices_of(&read("/proc/net/dev")));
|
|
17
|
+
counters.extend(softnet_of(&read("/proc/net/softnet_stat")));
|
|
18
|
+
counters
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/// Reads the format of /proc/net/snmp and /proc/net/netstat: a line of names, then a line of values
|
|
22
|
+
/// with the same prefix. A value that is not a count, as the -1 of `Tcp.MaxConn`, is skipped.
|
|
23
|
+
pub fn pairs_of(text: &str) -> BTreeMap<String, u64> {
|
|
24
|
+
let lines: Vec<&str> = text.lines().collect();
|
|
25
|
+
let mut counters = BTreeMap::new();
|
|
26
|
+
let mut at = 0;
|
|
27
|
+
while at + 1 < lines.len() {
|
|
28
|
+
let (Some((prefix, names)), Some((other, values))) = (lines[at].split_once(':'), lines[at + 1].split_once(':')) else {
|
|
29
|
+
at += 1;
|
|
30
|
+
continue;
|
|
31
|
+
};
|
|
32
|
+
if prefix != other || values.split_whitespace().next().is_some_and(|first| first.parse::<i64>().is_err()) {
|
|
33
|
+
at += 1;
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
for (name, value) in names.split_whitespace().zip(values.split_whitespace()) {
|
|
37
|
+
if let Ok(value) = value.parse::<u64>() {
|
|
38
|
+
counters.insert(format!("{prefix}.{name}"), value);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
at += 2;
|
|
42
|
+
}
|
|
43
|
+
counters
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/// The columns of /proc/net/dev that the counters keep, by their place after the name of the device.
|
|
47
|
+
const DEVICE_COLUMNS: [(usize, &str); 6] =
|
|
48
|
+
[(1, "rx_packets"), (2, "rx_errs"), (3, "rx_drop"), (9, "tx_packets"), (10, "tx_errs"), (11, "tx_drop")];
|
|
49
|
+
|
|
50
|
+
/// Reads /proc/net/dev: one line for each device, after two lines of headings.
|
|
51
|
+
pub fn devices_of(text: &str) -> BTreeMap<String, u64> {
|
|
52
|
+
let mut counters = BTreeMap::new();
|
|
53
|
+
for line in text.lines() {
|
|
54
|
+
let Some((device, values)) = line.split_once(':') else { continue };
|
|
55
|
+
let values: Vec<u64> = values.split_whitespace().filter_map(|value| value.parse().ok()).collect();
|
|
56
|
+
if values.len() < 16 {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
for (column, name) in DEVICE_COLUMNS {
|
|
60
|
+
counters.insert(format!("Dev.{}.{name}", device.trim()), values[column]);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
counters
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/// Reads /proc/net/softnet_stat: one line of hexadecimal columns for each processor. The sums of the
|
|
67
|
+
/// first three columns are the packets processed, the packets dropped at a full backlog, and the
|
|
68
|
+
/// rounds that ended with work left.
|
|
69
|
+
pub fn softnet_of(text: &str) -> BTreeMap<String, u64> {
|
|
70
|
+
let mut sums = [0u64; 3];
|
|
71
|
+
for line in text.lines() {
|
|
72
|
+
for (sum, value) in sums.iter_mut().zip(line.split_whitespace()) {
|
|
73
|
+
*sum += u64::from_str_radix(value, 16).unwrap_or(0);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if text.trim().is_empty() {
|
|
77
|
+
return BTreeMap::new();
|
|
78
|
+
}
|
|
79
|
+
["processed", "dropped", "squeezed"].iter().zip(sums).map(|(name, sum)| (format!("Softnet.{name}"), sum)).collect()
|
|
80
|
+
}
|
|
81
|
+
|
|
8
82
|
/// Prints one event line, with the time of the call on CLOCK_MONOTONIC.
|
|
9
83
|
pub fn emit(event: &str, fields: Value) {
|
|
10
84
|
emit_at(event, monotonic_ns(), fields);
|
|
@@ -48,4 +122,39 @@ mod tests {
|
|
|
48
122
|
assert!(arrivals_of(r#"{"format":"rigor-schedule/1"}"#).is_err());
|
|
49
123
|
assert!(arrivals_of(r#"{"format":"rigor-schedule/1","times":["a"]}"#).is_err());
|
|
50
124
|
}
|
|
125
|
+
|
|
126
|
+
#[test]
|
|
127
|
+
fn the_counters_of_snmp_and_netstat_come_by_prefix_and_name() {
|
|
128
|
+
let snmp = "Ip: Forwarding DefaultTTL InDiscards\nIp: 1 64 3\n\
|
|
129
|
+
IcmpMsg: InType3\nIcmpMsg: 2\n\
|
|
130
|
+
Tcp: RtoAlgorithm MaxConn RetransSegs\nTcp: 1 -1 7\n";
|
|
131
|
+
let counters = pairs_of(snmp);
|
|
132
|
+
assert_eq!(counters["Ip.InDiscards"], 3);
|
|
133
|
+
assert_eq!(counters["IcmpMsg.InType3"], 2);
|
|
134
|
+
assert_eq!(counters["Tcp.RetransSegs"], 7);
|
|
135
|
+
assert!(!counters.contains_key("Tcp.MaxConn"));
|
|
136
|
+
let netstat = "TcpExt: TCPACKSkippedTimeWait TCPChallengeACK\nTcpExt: 4 0\nIpExt: InNoRoutes\nIpExt: 0\n";
|
|
137
|
+
let counters = pairs_of(netstat);
|
|
138
|
+
assert_eq!(counters["TcpExt.TCPACKSkippedTimeWait"], 4);
|
|
139
|
+
assert_eq!(counters["IpExt.InNoRoutes"], 0);
|
|
140
|
+
assert!(pairs_of("Tcp: RetransSegs\nUdp: InDatagrams\nUdp: 5\n").get("Tcp.RetransSegs").is_none());
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
#[test]
|
|
144
|
+
fn the_counters_of_a_device_and_of_the_backlog_come_from_their_columns() {
|
|
145
|
+
let dev = "Inter-| Receive | Transmit\n face |bytes packets errs drop|bytes\n\
|
|
146
|
+
eth0: 1000 10 1 2 0 0 0 0 2000 20 3 4 0 0 0 0\n";
|
|
147
|
+
let counters = devices_of(dev);
|
|
148
|
+
assert_eq!(counters["Dev.eth0.rx_packets"], 10);
|
|
149
|
+
assert_eq!(counters["Dev.eth0.rx_errs"], 1);
|
|
150
|
+
assert_eq!(counters["Dev.eth0.rx_drop"], 2);
|
|
151
|
+
assert_eq!(counters["Dev.eth0.tx_packets"], 20);
|
|
152
|
+
assert_eq!(counters["Dev.eth0.tx_errs"], 3);
|
|
153
|
+
assert_eq!(counters["Dev.eth0.tx_drop"], 4);
|
|
154
|
+
assert_eq!(counters.len(), 6);
|
|
155
|
+
let softnet = "0000000a 00000001 00000002 00000000\n00000010 00000000 00000001 00000000\n";
|
|
156
|
+
let counters = softnet_of(softnet);
|
|
157
|
+
assert_eq!((counters["Softnet.processed"], counters["Softnet.dropped"], counters["Softnet.squeezed"]), (26, 1, 3));
|
|
158
|
+
assert!(softnet_of("").is_empty());
|
|
159
|
+
}
|
|
51
160
|
}
|
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.10",
|
|
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",
|
|
@@ -48,6 +48,10 @@
|
|
|
48
48
|
"types": "./build/schema.d.ts",
|
|
49
49
|
"default": "./build/schema.js"
|
|
50
50
|
},
|
|
51
|
+
"./layers": {
|
|
52
|
+
"types": "./build/layers.d.ts",
|
|
53
|
+
"default": "./build/layers.js"
|
|
54
|
+
},
|
|
51
55
|
"./package.json": "./package.json"
|
|
52
56
|
},
|
|
53
57
|
"files": [
|