@decaf-ts/utils 0.9.6 → 0.10.1
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/lib/esm/index.d.ts +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/esm/tests/Consumer.d.ts +42 -0
- package/lib/esm/tests/Consumer.js +316 -0
- package/lib/esm/tests/Consumer.js.map +1 -0
- package/lib/esm/tests/ProducerChildProcess.d.ts +18 -0
- package/lib/esm/tests/ProducerChildProcess.js +66 -0
- package/lib/esm/tests/ProducerChildProcess.js.map +1 -0
- package/lib/esm/tests/TestReporter.d.ts +193 -0
- package/lib/esm/tests/TestReporter.js +260 -0
- package/lib/esm/tests/TestReporter.js.map +1 -0
- package/lib/esm/tests/index.d.ts +2 -0
- package/lib/esm/tests/index.js +3 -0
- package/lib/esm/tests/index.js.map +1 -0
- package/lib/esm/utils/tests.d.ts +1 -193
- package/lib/esm/utils/tests.js +1 -259
- package/lib/esm/utils/tests.js.map +1 -1
- package/lib/index.cjs +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/tests/Consumer.cjs +322 -0
- package/lib/tests/Consumer.d.ts +42 -0
- package/lib/tests/Consumer.js.map +1 -0
- package/lib/tests/ProducerChildProcess.cjs +66 -0
- package/lib/tests/ProducerChildProcess.d.ts +18 -0
- package/lib/tests/ProducerChildProcess.js.map +1 -0
- package/lib/tests/TestReporter.cjs +300 -0
- package/lib/tests/TestReporter.d.ts +193 -0
- package/lib/tests/TestReporter.js.map +1 -0
- package/lib/tests/index.cjs +19 -0
- package/lib/tests/index.d.ts +2 -0
- package/lib/tests/index.js.map +1 -0
- package/lib/utils/tests.cjs +3 -285
- package/lib/utils/tests.d.ts +1 -193
- package/lib/utils/tests.js.map +1 -1
- package/package.json +11 -3
package/lib/esm/index.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export * from "./writers";
|
|
|
26
26
|
* @const VERSION
|
|
27
27
|
* @memberOf module:utils
|
|
28
28
|
*/
|
|
29
|
-
export declare const VERSION = "0.
|
|
29
|
+
export declare const VERSION = "0.10.0";
|
|
30
30
|
/**
|
|
31
31
|
* @description Represents the current version of the module.
|
|
32
32
|
* @summary Stores the version for the @decaf-ts/utils package. The build replaces
|
package/lib/esm/index.js
CHANGED
|
@@ -26,7 +26,7 @@ export * from "./writers/index.js";
|
|
|
26
26
|
* @const VERSION
|
|
27
27
|
* @memberOf module:utils
|
|
28
28
|
*/
|
|
29
|
-
export const VERSION = "0.
|
|
29
|
+
export const VERSION = "0.10.0";
|
|
30
30
|
/**
|
|
31
31
|
* @description Represents the current version of the module.
|
|
32
32
|
* @summary Stores the version for the @decaf-ts/utils package. The build replaces
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { LoggedClass } from "@decaf-ts/logging";
|
|
2
|
+
import { TestReporter } from "./TestReporter";
|
|
3
|
+
type LogStore = Record<number, string[]>;
|
|
4
|
+
export interface ParsedLog {
|
|
5
|
+
timestamp: number;
|
|
6
|
+
child: string;
|
|
7
|
+
action: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ComparerResult {
|
|
10
|
+
consumer: ParsedLog[];
|
|
11
|
+
producer: ParsedLog[];
|
|
12
|
+
}
|
|
13
|
+
type Comparer = (consumerData: LogStore, producerData: LogStore) => Promise<ComparerResult>;
|
|
14
|
+
type ConsumerHandler = (identifier: number, ...args: unknown[]) => unknown | Promise<unknown>;
|
|
15
|
+
export declare const defaultComparer: Comparer;
|
|
16
|
+
export interface ReportingComparerOptions {
|
|
17
|
+
reporter?: TestReporter;
|
|
18
|
+
testCase?: string;
|
|
19
|
+
referencePrefix?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare const reportingComparer: (consumerData: LogStore, producerData: LogStore, options?: ReportingComparerOptions) => Promise<ComparerResult>;
|
|
22
|
+
export declare class ConsumerRunner extends LoggedClass {
|
|
23
|
+
private readonly action;
|
|
24
|
+
private readonly handler;
|
|
25
|
+
private readonly comparerHandle;
|
|
26
|
+
private forkedCache;
|
|
27
|
+
private consumerResults;
|
|
28
|
+
private producerResults;
|
|
29
|
+
private childExitPromises;
|
|
30
|
+
private completionTriggered;
|
|
31
|
+
private activeHandlers;
|
|
32
|
+
constructor(action: string, consumerHandler: ConsumerHandler, compareHandler?: Comparer);
|
|
33
|
+
private reset;
|
|
34
|
+
private waitForChildExit;
|
|
35
|
+
private store;
|
|
36
|
+
private recordConsumer;
|
|
37
|
+
private isProducerComplete;
|
|
38
|
+
private isConsumerComplete;
|
|
39
|
+
private terminateChildren;
|
|
40
|
+
run(count: number, timeout: number | undefined, times: number, random: boolean | undefined): Promise<ComparerResult>;
|
|
41
|
+
}
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import { fork } from "node:child_process";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { LoggedClass } from "@decaf-ts/logging";
|
|
4
|
+
import { TestReporter } from "./TestReporter.js";
|
|
5
|
+
const parseData = (data) => {
|
|
6
|
+
const [timestamp, , child, action] = data.split(" - ");
|
|
7
|
+
return {
|
|
8
|
+
timestamp: parseInt(timestamp, 10),
|
|
9
|
+
child,
|
|
10
|
+
action,
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export const defaultComparer = async (consumerData, producerData) => {
|
|
14
|
+
const sortedConsumerData = Object.keys(consumerData)
|
|
15
|
+
.reduce((accum, key) => {
|
|
16
|
+
const identifier = Number(key);
|
|
17
|
+
const entries = consumerData[identifier] ?? [];
|
|
18
|
+
accum.push(...entries.map((entry) => parseData(entry)));
|
|
19
|
+
return accum;
|
|
20
|
+
}, [])
|
|
21
|
+
.sort((a, b) => a.timestamp - b.timestamp);
|
|
22
|
+
const sortedProducerData = Object.keys(producerData)
|
|
23
|
+
.reduce((accum, key) => {
|
|
24
|
+
const identifier = Number(key);
|
|
25
|
+
const entries = producerData[identifier] ?? [];
|
|
26
|
+
accum.push(...entries.map((entry) => parseData(entry)));
|
|
27
|
+
return accum;
|
|
28
|
+
}, [])
|
|
29
|
+
.sort((a, b) => a.timestamp - b.timestamp);
|
|
30
|
+
if (sortedProducerData.length !== sortedConsumerData.length) {
|
|
31
|
+
throw new Error("Producer data and consumer data does not match in length");
|
|
32
|
+
}
|
|
33
|
+
let counter = -1;
|
|
34
|
+
const isMatching = sortedProducerData.every((producer, index) => {
|
|
35
|
+
counter = index;
|
|
36
|
+
const consumer = sortedConsumerData[index];
|
|
37
|
+
return (producer.child === consumer.child && producer.action === consumer.action);
|
|
38
|
+
});
|
|
39
|
+
if (!isMatching) {
|
|
40
|
+
const errorLines = [
|
|
41
|
+
`Producer data and consumer data do not sort the same way as of record ${counter}:`,
|
|
42
|
+
" | CONSUMER | PRODUCER |",
|
|
43
|
+
" | id | action | timestamp | id | action | timestamp |",
|
|
44
|
+
];
|
|
45
|
+
sortedProducerData.forEach((producer, index) => {
|
|
46
|
+
if (index < counter || index > counter + 15) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const consumer = sortedConsumerData[index];
|
|
50
|
+
errorLines.push(` ${index < 10 ? `0${index}` : index}| ${consumer.child} | ${consumer.action} | ${consumer.timestamp} | ${producer.child} | ${producer.action} | ${producer.timestamp} |`);
|
|
51
|
+
});
|
|
52
|
+
throw new Error(errorLines.join("\n"));
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
consumer: sortedConsumerData,
|
|
56
|
+
producer: sortedProducerData,
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
const formatTimestamp = (value) => new Date(value).toISOString();
|
|
60
|
+
export const reportingComparer = async (consumerData, producerData, options) => {
|
|
61
|
+
const reporter = options?.reporter ??
|
|
62
|
+
new TestReporter(options?.testCase ?? "consumer-producer");
|
|
63
|
+
const referencePrefix = options?.referencePrefix ?? "consumer-producer";
|
|
64
|
+
try {
|
|
65
|
+
const comparison = await defaultComparer(consumerData, producerData);
|
|
66
|
+
const rows = comparison.consumer.map((consumerEntry, index) => {
|
|
67
|
+
const producerEntry = comparison.producer[index];
|
|
68
|
+
return {
|
|
69
|
+
Index: `${index}`,
|
|
70
|
+
"Consumer Child": consumerEntry.child,
|
|
71
|
+
"Consumer Action": consumerEntry.action,
|
|
72
|
+
"Consumer Timestamp": formatTimestamp(consumerEntry.timestamp),
|
|
73
|
+
"Producer Child": producerEntry?.child ?? "N/A",
|
|
74
|
+
"Producer Action": producerEntry?.action ?? "N/A",
|
|
75
|
+
"Producer Timestamp": producerEntry
|
|
76
|
+
? formatTimestamp(producerEntry.timestamp)
|
|
77
|
+
: "N/A",
|
|
78
|
+
};
|
|
79
|
+
});
|
|
80
|
+
await Promise.allSettled([
|
|
81
|
+
reporter.reportMessage(`${referencePrefix}-comparison`, `Consumer and producer logs matched (${comparison.consumer.length} entries).`),
|
|
82
|
+
reporter.reportTable(`${referencePrefix}-logs`, {
|
|
83
|
+
headers: [
|
|
84
|
+
"Index",
|
|
85
|
+
"Consumer Child",
|
|
86
|
+
"Consumer Action",
|
|
87
|
+
"Consumer Timestamp",
|
|
88
|
+
"Producer Child",
|
|
89
|
+
"Producer Action",
|
|
90
|
+
"Producer Timestamp",
|
|
91
|
+
],
|
|
92
|
+
rows,
|
|
93
|
+
}),
|
|
94
|
+
]);
|
|
95
|
+
return comparison;
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
const message = error instanceof Error ? error.message : String(error ?? "Unknown error");
|
|
99
|
+
await Promise.allSettled([
|
|
100
|
+
reporter.reportMessage(`${referencePrefix}-mismatch`, message),
|
|
101
|
+
reporter.reportObject(`${referencePrefix}-consumer`, consumerData),
|
|
102
|
+
reporter.reportObject(`${referencePrefix}-producer`, producerData),
|
|
103
|
+
]);
|
|
104
|
+
throw error;
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
export class ConsumerRunner extends LoggedClass {
|
|
108
|
+
constructor(action, consumerHandler, compareHandler) {
|
|
109
|
+
super();
|
|
110
|
+
this.forkedCache = [];
|
|
111
|
+
this.consumerResults = {};
|
|
112
|
+
this.producerResults = {};
|
|
113
|
+
this.childExitPromises = [];
|
|
114
|
+
this.completionTriggered = false;
|
|
115
|
+
this.activeHandlers = 0;
|
|
116
|
+
this.action = action;
|
|
117
|
+
this.handler = consumerHandler;
|
|
118
|
+
this.comparerHandle = compareHandler ?? defaultComparer;
|
|
119
|
+
this.reset();
|
|
120
|
+
}
|
|
121
|
+
reset() {
|
|
122
|
+
this.forkedCache = [];
|
|
123
|
+
this.consumerResults = {};
|
|
124
|
+
this.producerResults = {};
|
|
125
|
+
this.completionTriggered = false;
|
|
126
|
+
this.childExitPromises = [];
|
|
127
|
+
this.activeHandlers = 0;
|
|
128
|
+
}
|
|
129
|
+
waitForChildExit() {
|
|
130
|
+
if (!this.childExitPromises?.length) {
|
|
131
|
+
return Promise.resolve();
|
|
132
|
+
}
|
|
133
|
+
const exits = [...this.childExitPromises];
|
|
134
|
+
this.childExitPromises = [];
|
|
135
|
+
return Promise.allSettled(exits).then(() => void 0);
|
|
136
|
+
}
|
|
137
|
+
store(identifier, action, timeout, times, count, random) {
|
|
138
|
+
const logParts = [
|
|
139
|
+
Date.now(),
|
|
140
|
+
"PRODUCER",
|
|
141
|
+
identifier,
|
|
142
|
+
action,
|
|
143
|
+
];
|
|
144
|
+
if (timeout) {
|
|
145
|
+
logParts.push(timeout);
|
|
146
|
+
}
|
|
147
|
+
if (times && count) {
|
|
148
|
+
logParts.push(`${count}/${times}`, random ?? false);
|
|
149
|
+
}
|
|
150
|
+
const log = logParts.join(" - ");
|
|
151
|
+
if (!this.producerResults[identifier]) {
|
|
152
|
+
this.producerResults[identifier] = [];
|
|
153
|
+
}
|
|
154
|
+
this.producerResults[identifier].push(log);
|
|
155
|
+
}
|
|
156
|
+
recordConsumer(identifier) {
|
|
157
|
+
const logParts = [
|
|
158
|
+
Date.now(),
|
|
159
|
+
"CONSUMER",
|
|
160
|
+
identifier,
|
|
161
|
+
this.action,
|
|
162
|
+
];
|
|
163
|
+
const log = logParts.join(" - ");
|
|
164
|
+
if (!this.consumerResults[identifier]) {
|
|
165
|
+
this.consumerResults[identifier] = [];
|
|
166
|
+
}
|
|
167
|
+
this.consumerResults[identifier].push(log);
|
|
168
|
+
}
|
|
169
|
+
isProducerComplete(count, times) {
|
|
170
|
+
const producerKeys = Object.keys(this.producerResults);
|
|
171
|
+
if (producerKeys.length !== count) {
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
174
|
+
return producerKeys.every((key) => this.producerResults[Number(key)]?.length === times);
|
|
175
|
+
}
|
|
176
|
+
isConsumerComplete(count, times) {
|
|
177
|
+
const consumerKeys = Object.keys(this.consumerResults);
|
|
178
|
+
if (consumerKeys.length !== count) {
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
return consumerKeys.every((key) => this.consumerResults[Number(key)]?.length === times);
|
|
182
|
+
}
|
|
183
|
+
terminateChildren(forceKill = false) {
|
|
184
|
+
if (!this.forkedCache) {
|
|
185
|
+
return this.waitForChildExit();
|
|
186
|
+
}
|
|
187
|
+
const cached = this.forkedCache;
|
|
188
|
+
this.forkedCache = undefined;
|
|
189
|
+
cached.forEach((forked, index) => {
|
|
190
|
+
if (!forked.connected && !forceKill) {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
try {
|
|
194
|
+
forked.send({
|
|
195
|
+
identifier: index,
|
|
196
|
+
terminate: true,
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
catch {
|
|
200
|
+
// IPC channel already closed; nothing else to do.
|
|
201
|
+
}
|
|
202
|
+
if (forceKill && !forked.killed) {
|
|
203
|
+
forked.kill();
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
return this.waitForChildExit();
|
|
207
|
+
}
|
|
208
|
+
async run(count, timeout, times, random) {
|
|
209
|
+
this.reset();
|
|
210
|
+
const childPath = join(__dirname, "ProducerChildProcess.cjs");
|
|
211
|
+
return new Promise((resolve, reject) => {
|
|
212
|
+
const snapshotState = () => {
|
|
213
|
+
const summarize = (records) => Object.keys(records).reduce((acc, key) => {
|
|
214
|
+
acc[key] = records[Number(key)]?.length ?? 0;
|
|
215
|
+
return acc;
|
|
216
|
+
}, {});
|
|
217
|
+
return {
|
|
218
|
+
producers: summarize(this.producerResults),
|
|
219
|
+
consumers: summarize(this.consumerResults),
|
|
220
|
+
activeHandlers: this.activeHandlers,
|
|
221
|
+
};
|
|
222
|
+
};
|
|
223
|
+
const handleError = (error) => {
|
|
224
|
+
if (this.completionTriggered) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
this.completionTriggered = true;
|
|
228
|
+
Promise.resolve(this.terminateChildren(true)).finally(() => reject(error));
|
|
229
|
+
};
|
|
230
|
+
const finalizeIfComplete = () => {
|
|
231
|
+
if (this.completionTriggered) {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
if (!this.isProducerComplete(count, times) ||
|
|
235
|
+
!this.isConsumerComplete(count, times) ||
|
|
236
|
+
this.activeHandlers > 0) {
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
this.completionTriggered = true;
|
|
240
|
+
if (process.env.DEBUG_CONSUMER_RUNNER === "1") {
|
|
241
|
+
console.debug("ConsumerRunner finalize state", snapshotState());
|
|
242
|
+
}
|
|
243
|
+
try {
|
|
244
|
+
const comparisonPromise = Promise.resolve(this.comparerHandle(this.consumerResults, this.producerResults));
|
|
245
|
+
Promise.all([comparisonPromise, this.waitForChildExit()])
|
|
246
|
+
.then(async ([comparison]) => {
|
|
247
|
+
await new Promise((resolveDelay) => setImmediate(resolveDelay));
|
|
248
|
+
resolve(comparison);
|
|
249
|
+
})
|
|
250
|
+
.catch(reject);
|
|
251
|
+
}
|
|
252
|
+
catch (error) {
|
|
253
|
+
reject(error);
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
for (let identifier = 1; identifier < count + 1; identifier += 1) {
|
|
257
|
+
const forked = fork(childPath);
|
|
258
|
+
this.forkedCache?.push(forked);
|
|
259
|
+
this.childExitPromises?.push(new Promise((resolveChild) => {
|
|
260
|
+
forked.once("exit", () => resolveChild());
|
|
261
|
+
}));
|
|
262
|
+
forked.on("error", handleError);
|
|
263
|
+
forked.on("message", async (message) => {
|
|
264
|
+
if (this.completionTriggered) {
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
const { identifier: childId, args, action, timeout: childTimeout, times: childTimes, random: childRandom, } = message;
|
|
268
|
+
this.activeHandlers += 1;
|
|
269
|
+
let handlerFailed = false;
|
|
270
|
+
if (process.env.DEBUG_CONSUMER_RUNNER === "1") {
|
|
271
|
+
console.debug("ConsumerRunner message:start", {
|
|
272
|
+
childId,
|
|
273
|
+
producerCount: this.producerResults[childId]?.length ?? 0,
|
|
274
|
+
consumerCount: this.consumerResults[childId]?.length ?? 0,
|
|
275
|
+
activeHandlers: this.activeHandlers,
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
try {
|
|
279
|
+
this.store(childId, action, childTimeout, childTimes, count, childRandom);
|
|
280
|
+
const handlerArgs = Array.isArray(args) ? args : [];
|
|
281
|
+
await Promise.resolve(this.handler(childId, ...handlerArgs));
|
|
282
|
+
this.recordConsumer(childId);
|
|
283
|
+
if (process.env.DEBUG_CONSUMER_RUNNER === "1") {
|
|
284
|
+
console.debug("ConsumerRunner message:complete", {
|
|
285
|
+
childId,
|
|
286
|
+
producerCount: this.producerResults[childId]?.length ?? 0,
|
|
287
|
+
consumerCount: this.consumerResults[childId]?.length ?? 0,
|
|
288
|
+
activeHandlers: this.activeHandlers,
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
catch (error) {
|
|
293
|
+
handlerFailed = true;
|
|
294
|
+
handleError(error);
|
|
295
|
+
}
|
|
296
|
+
finally {
|
|
297
|
+
this.activeHandlers = Math.max(0, this.activeHandlers - 1);
|
|
298
|
+
if (!handlerFailed) {
|
|
299
|
+
finalizeIfComplete();
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
this.forkedCache?.forEach((forked, index) => {
|
|
305
|
+
forked.send({
|
|
306
|
+
identifier: index,
|
|
307
|
+
action: this.action,
|
|
308
|
+
timeout,
|
|
309
|
+
times,
|
|
310
|
+
random,
|
|
311
|
+
});
|
|
312
|
+
});
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
//# sourceMappingURL=Consumer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Consumer.js","sourceRoot":"","sources":["../../../src/tests/Consumer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,IAAI,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,0BAAuB;AAmC9C,MAAM,SAAS,GAAG,CAAC,IAAY,EAAa,EAAE;IAC5C,MAAM,CAAC,SAAS,EAAE,AAAD,EAAG,KAAK,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACvD,OAAO;QACL,SAAS,EAAE,QAAQ,CAAC,SAAS,EAAE,EAAE,CAAC;QAClC,KAAK;QACL,MAAM;KACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAa,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,EAAE;IAC5E,MAAM,kBAAkB,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC;SACjD,MAAM,CAAc,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QAClC,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAC/B,MAAM,OAAO,GAAG,YAAY,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;QAC/C,KAAK,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,KAA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;wBAC3D,IAAI,CAAC,aAAa,EAAE,CAAC;4BACnB,kBAAkB,EAAE,CAAC;wBACvB,CAAC;oBACH,CAAC;gBACH,CAAC,CAAC,CAAC;YACL,CAAC;YAED,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;gBAC1C,MAAM,CAAC,IAAI,CAAC;oBACV,UAAU,EAAE,KAAK;oBACjB,MAAM,EAAE,IAAI,CAAC,MAAM;oBACnB,OAAO;oBACP,KAAK;oBACL,MAAM;iBACP,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
type ParentMessage = {
|
|
2
|
+
identifier: number;
|
|
3
|
+
action: string;
|
|
4
|
+
timeout?: number;
|
|
5
|
+
times: number;
|
|
6
|
+
random?: boolean;
|
|
7
|
+
terminate?: boolean;
|
|
8
|
+
};
|
|
9
|
+
type ProducerResponse = {
|
|
10
|
+
identifier: number;
|
|
11
|
+
action: string;
|
|
12
|
+
timeout?: number;
|
|
13
|
+
times: number;
|
|
14
|
+
random?: boolean;
|
|
15
|
+
result?: string[];
|
|
16
|
+
};
|
|
17
|
+
declare let shuttingDown: boolean;
|
|
18
|
+
declare const completeAndExit: (logMessage?: string) => void;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
let shuttingDown = false;
|
|
3
|
+
const completeAndExit = (logMessage) => {
|
|
4
|
+
if (shuttingDown) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
shuttingDown = true;
|
|
8
|
+
if (logMessage) {
|
|
9
|
+
console.log(logMessage);
|
|
10
|
+
}
|
|
11
|
+
setImmediate(() => process.exit(0));
|
|
12
|
+
};
|
|
13
|
+
process.on("message", (args) => {
|
|
14
|
+
const result = [];
|
|
15
|
+
const { identifier, action, timeout, times, random, terminate } = args;
|
|
16
|
+
const tick = (count) => {
|
|
17
|
+
const logParts = [Date.now(), 'PRODUCER', identifier, action];
|
|
18
|
+
if (timeout) {
|
|
19
|
+
logParts.push(timeout);
|
|
20
|
+
}
|
|
21
|
+
if (times && count) {
|
|
22
|
+
logParts.push(`${count}/${times}`, random ?? false);
|
|
23
|
+
}
|
|
24
|
+
const log = logParts.join(' - ');
|
|
25
|
+
result.push(log);
|
|
26
|
+
const response = { identifier, action, timeout, times, random };
|
|
27
|
+
if (result.length === times) {
|
|
28
|
+
response.result = [...result];
|
|
29
|
+
}
|
|
30
|
+
process.send?.(response);
|
|
31
|
+
if (response.result) {
|
|
32
|
+
completeAndExit();
|
|
33
|
+
}
|
|
34
|
+
else if (!times) {
|
|
35
|
+
completeAndExit();
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
if (terminate) {
|
|
39
|
+
const log = [Date.now(), "PRODUCER", identifier, action, "Quitting!"].join(" - ");
|
|
40
|
+
completeAndExit(log);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (!timeout) {
|
|
44
|
+
tick(times);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const getTimeout = () => {
|
|
48
|
+
if (!random) {
|
|
49
|
+
return timeout;
|
|
50
|
+
}
|
|
51
|
+
return Math.floor(Math.random() * timeout);
|
|
52
|
+
};
|
|
53
|
+
let actionCount = 0;
|
|
54
|
+
const iterator = () => {
|
|
55
|
+
const currentTimeout = getTimeout();
|
|
56
|
+
setTimeout(() => {
|
|
57
|
+
actionCount += 1;
|
|
58
|
+
tick(actionCount);
|
|
59
|
+
if (actionCount < times) {
|
|
60
|
+
iterator();
|
|
61
|
+
}
|
|
62
|
+
}, currentTimeout);
|
|
63
|
+
};
|
|
64
|
+
iterator();
|
|
65
|
+
});
|
|
66
|
+
//# sourceMappingURL=ProducerChildProcess.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProducerChildProcess.js","sourceRoot":"","sources":["../../../src/tests/ProducerCh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