@nsshunt/ststestrunner 1.1.8 → 1.1.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/dist/ststestrunner.cjs +48 -850
- package/dist/ststestrunner.cjs.map +1 -1
- package/dist/ststestrunner.mjs +49 -851
- package/dist/ststestrunner.mjs.map +1 -1
- package/package.json +3 -10
- package/types/commonTypes.d.ts +1 -39
- package/types/commonTypes.d.ts.map +1 -1
- package/types/index.d.ts +1 -2
- package/types/index.d.ts.map +1 -1
- package/types/libmodule/asyncRunnerFactory.d.ts +5 -0
- package/types/libmodule/asyncRunnerFactory.d.ts.map +1 -0
- package/types/libmodule/commonTypes.d.ts +11 -0
- package/types/libmodule/commonTypes.d.ts.map +1 -0
- package/types/libmodule/resourceDataGenerator.d.ts +7 -0
- package/types/libmodule/resourceDataGenerator.d.ts.map +1 -0
- package/types/libmodule/testCaseFhir01.d.ts.map +1 -0
- package/types/libmodule/testCaseFhir02.d.ts.map +1 -0
- package/types/libmodule/testCaseFhir03.d.ts.map +1 -0
- package/types/libmodule/testCaseFhir04.d.ts.map +1 -0
- package/types/libmodule/testCaseFhir05.d.ts.map +1 -0
- package/types/libmodule/testCaseFhir06.d.ts.map +1 -0
- package/types/libmodule/testCaseFhir07.d.ts.map +1 -0
- package/types/libmodule/testCaseFhir08.d.ts.map +1 -0
- package/types/libmodule/testCaseFhir09.d.ts.map +1 -0
- package/types/libmodule/testCaseFhir10.d.ts.map +1 -0
- package/types/{testCaseFhirBase.d.ts → libmodule/testCaseFhirBase.d.ts} +37 -2
- package/types/libmodule/testCaseFhirBase.d.ts.map +1 -0
- package/types/libmodule/testCaseFhirQueryBase.d.ts.map +1 -0
- package/types/libmodule/workerFhirTestCases.d.ts +12 -0
- package/types/libmodule/workerFhirTestCases.d.ts.map +1 -0
- package/types/redisTestRunStore.d.ts +0 -71
- package/types/redisTestRunStore.d.ts.map +0 -1
- package/types/setupFhirTestResources.d.ts +0 -14
- package/types/setupFhirTestResources.d.ts.map +0 -1
- package/types/startUpDelFhirResources.d.ts +0 -18
- package/types/startUpDelFhirResources.d.ts.map +0 -1
- package/types/testCase01.d.ts +0 -21
- package/types/testCase01.d.ts.map +0 -1
- package/types/testCaseFhir01.d.ts.map +0 -1
- package/types/testCaseFhir02.d.ts.map +0 -1
- package/types/testCaseFhir03.d.ts.map +0 -1
- package/types/testCaseFhir04.d.ts.map +0 -1
- package/types/testCaseFhir05.d.ts.map +0 -1
- package/types/testCaseFhir06.d.ts.map +0 -1
- package/types/testCaseFhir07.d.ts.map +0 -1
- package/types/testCaseFhir08.d.ts.map +0 -1
- package/types/testCaseFhir09.d.ts.map +0 -1
- package/types/testCaseFhir10.d.ts.map +0 -1
- package/types/testCaseFhirBase.d.ts.map +0 -1
- package/types/testCaseFhirQueryBase.d.ts.map +0 -1
- package/types/testshutdown.d.ts +0 -21
- package/types/testshutdown.d.ts.map +0 -1
- package/types/teststartup.d.ts +0 -21
- package/types/teststartup.d.ts.map +0 -1
- package/types/workerTestCases.d.ts +0 -17
- package/types/workerTestCases.d.ts.map +0 -1
- /package/types/{testCaseFhir01.d.ts → libmodule/testCaseFhir01.d.ts} +0 -0
- /package/types/{testCaseFhir02.d.ts → libmodule/testCaseFhir02.d.ts} +0 -0
- /package/types/{testCaseFhir03.d.ts → libmodule/testCaseFhir03.d.ts} +0 -0
- /package/types/{testCaseFhir04.d.ts → libmodule/testCaseFhir04.d.ts} +0 -0
- /package/types/{testCaseFhir05.d.ts → libmodule/testCaseFhir05.d.ts} +0 -0
- /package/types/{testCaseFhir06.d.ts → libmodule/testCaseFhir06.d.ts} +0 -0
- /package/types/{testCaseFhir07.d.ts → libmodule/testCaseFhir07.d.ts} +0 -0
- /package/types/{testCaseFhir08.d.ts → libmodule/testCaseFhir08.d.ts} +0 -0
- /package/types/{testCaseFhir09.d.ts → libmodule/testCaseFhir09.d.ts} +0 -0
- /package/types/{testCaseFhir10.d.ts → libmodule/testCaseFhir10.d.ts} +0 -0
- /package/types/{testCaseFhirQueryBase.d.ts → libmodule/testCaseFhirQueryBase.d.ts} +0 -0
package/dist/ststestrunner.mjs
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import { AbstractRunnerExecutionWorker
|
|
2
|
-
import chalk from "chalk";
|
|
1
|
+
import { AbstractRunnerExecutionWorker } from "@nsshunt/stsrunnerframework";
|
|
3
2
|
import { STSAxiosConfig, Sleep, createAgentManager, defaultLogger, isNode } from "@nsshunt/stsutils";
|
|
3
|
+
import chalk from "chalk";
|
|
4
4
|
import { AuthUtilsNode } from "@nsshunt/stsauthclient";
|
|
5
5
|
import { FhirRESTClient, FhirSocketClientAllInOne, FhirSocketClientIndividual, createRetryAxiosClient } from "@nsshunt/stsfhirclient";
|
|
6
6
|
import http from "node:http";
|
|
7
7
|
import https from "node:https";
|
|
8
|
-
import { randomUUID } from "node:crypto";
|
|
9
|
-
import { parentPort } from "node:worker_threads";
|
|
10
|
-
import { createClient } from "redis";
|
|
11
8
|
//#region \0rolldown/runtime.js
|
|
12
9
|
var __defProp = Object.defineProperty;
|
|
13
10
|
var __exportAll = (all, no_symbols) => {
|
|
@@ -20,157 +17,7 @@ var __exportAll = (all, no_symbols) => {
|
|
|
20
17
|
return target;
|
|
21
18
|
};
|
|
22
19
|
//#endregion
|
|
23
|
-
//#region src/
|
|
24
|
-
var TestCase01 = class {
|
|
25
|
-
#runner;
|
|
26
|
-
#workerInstance;
|
|
27
|
-
#logMessageDataSet = {};
|
|
28
|
-
#publishTelemetryTimeout = null;
|
|
29
|
-
#publishTelemetryCount = 0;
|
|
30
|
-
#maxBufferSize = 50;
|
|
31
|
-
#publishTelemetryTimeoutVal = 1e3;
|
|
32
|
-
#color;
|
|
33
|
-
#randomPastelColour;
|
|
34
|
-
#GetRandomHexColor() {
|
|
35
|
-
return `#${Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0")}`;
|
|
36
|
-
}
|
|
37
|
-
#GetRandomPastelColor = () => {
|
|
38
|
-
const r = Math.floor(Math.random() * 127 + 127);
|
|
39
|
-
const g = Math.floor(Math.random() * 127 + 127);
|
|
40
|
-
const b = Math.floor(Math.random() * 127 + 127);
|
|
41
|
-
return `#${((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1).toUpperCase()}`;
|
|
42
|
-
};
|
|
43
|
-
constructor(workerInstance, runner) {
|
|
44
|
-
this.#workerInstance = workerInstance;
|
|
45
|
-
this.#runner = runner;
|
|
46
|
-
this.#color = this.#GetRandomHexColor();
|
|
47
|
-
this.#randomPastelColour = this.#GetRandomPastelColor();
|
|
48
|
-
}
|
|
49
|
-
#debug = (message) => {
|
|
50
|
-
this.#workerInstance.logger.debug(message);
|
|
51
|
-
};
|
|
52
|
-
#GenLogMessage = (runner, iteration) => {
|
|
53
|
-
if (!this.#logMessageDataSet[runner.id]) this.#logMessageDataSet[runner.id] = {
|
|
54
|
-
adder: 1,
|
|
55
|
-
indent: 0
|
|
56
|
-
};
|
|
57
|
-
const logMessageData = this.#logMessageDataSet[runner.id];
|
|
58
|
-
let message = `${" ".repeat(logMessageData.indent)} [${runner.id}] >> Hello World << ${iteration}`;
|
|
59
|
-
message = chalk.hex(this.#randomPastelColour)(message);
|
|
60
|
-
runner.instrumentData.message.push(message);
|
|
61
|
-
this.#debug(message);
|
|
62
|
-
logMessageData.indent += logMessageData.adder;
|
|
63
|
-
if (logMessageData.indent > 20) logMessageData.adder = -1;
|
|
64
|
-
else if (logMessageData.indent === 0) logMessageData.adder = 1;
|
|
65
|
-
};
|
|
66
|
-
#SetupTimeout = async () => {
|
|
67
|
-
if (!this.#publishTelemetryTimeout) {
|
|
68
|
-
this.#publishTelemetryTimeout = setTimeout(async () => {
|
|
69
|
-
await this.#PublishTelemetryData();
|
|
70
|
-
this.#publishTelemetryCount = 0;
|
|
71
|
-
this.#publishTelemetryTimeout = null;
|
|
72
|
-
}, this.#publishTelemetryTimeoutVal);
|
|
73
|
-
if (isNode) this.#publishTelemetryTimeout.unref();
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
#PublishTelemetryData = async () => {
|
|
77
|
-
this.#workerInstance.PostTelemetryById(this.#runner.id);
|
|
78
|
-
this.#runner.instrumentData.velocity = 0;
|
|
79
|
-
this.#runner.instrumentData.message = [];
|
|
80
|
-
this.#runner.instrumentData.tx = 0;
|
|
81
|
-
this.#runner.instrumentData.rx = 0;
|
|
82
|
-
await this.SleepImmediate();
|
|
83
|
-
};
|
|
84
|
-
#ForcePublishTelemetryData = async () => {
|
|
85
|
-
await this.#PublishTelemetryData();
|
|
86
|
-
};
|
|
87
|
-
#PublishTelemetry = async () => {
|
|
88
|
-
this.#publishTelemetryCount++;
|
|
89
|
-
if (this.#publishTelemetryCount % this.#maxBufferSize === 0) {
|
|
90
|
-
this.#publishTelemetryCount = 0;
|
|
91
|
-
if (this.#publishTelemetryTimeout) {
|
|
92
|
-
clearTimeout(this.#publishTelemetryTimeout);
|
|
93
|
-
this.#publishTelemetryTimeout = null;
|
|
94
|
-
}
|
|
95
|
-
await this.#PublishTelemetryData();
|
|
96
|
-
}
|
|
97
|
-
if (!this.#publishTelemetryTimeout) this.#SetupTimeout();
|
|
98
|
-
};
|
|
99
|
-
SleepImmediate() {
|
|
100
|
-
return new Promise((resolve, reject) => {
|
|
101
|
-
resolve();
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
ExecuteRunner = async () => {
|
|
105
|
-
const start = performance.now();
|
|
106
|
-
const options = this.#runner.options;
|
|
107
|
-
this.#runner.instrumentData.coreCount = 1;
|
|
108
|
-
this.#runner.instrumentData.activeRequestCount++;
|
|
109
|
-
this.#runner.instrumentData.requestCount++;
|
|
110
|
-
this.#runner.instrumentData.velocity++;
|
|
111
|
-
this.#runner.instrumentData.tx += 256e3;
|
|
112
|
-
this.#runner.instrumentData.rx += 65e5;
|
|
113
|
-
if (this.#runner.instrumentData.requestCount % options.logMessageMod === 0) this.#GenLogMessage(this.#runner, this.#runner.iteration);
|
|
114
|
-
if (this.#runner.instrumentData.requestCount % 1 === 0) `${this.#runner.asyncRunnerContext.threadId}${this.#runner.asyncRunnerContext.id}${this.#runner.instrumentData.requestCount}${options.executionProfile.iterations}`;
|
|
115
|
-
this.#debug(chalk.hex(this.#color)(`${this.#runner.iteration} - ${this.#runner.instrumentData.requestCount} - ${(/* @__PURE__ */ new Date()).getTime()}`));
|
|
116
|
-
if (options.sleepDuration > 0) await Sleep(options.sleepDuration);
|
|
117
|
-
else await this.SleepImmediate();
|
|
118
|
-
this.#runner.instrumentData.activeRequestCount--;
|
|
119
|
-
const diff = performance.now() - start;
|
|
120
|
-
this.#runner.instrumentData.duration = diff;
|
|
121
|
-
await this.#PublishTelemetry();
|
|
122
|
-
return true;
|
|
123
|
-
};
|
|
124
|
-
#OutputLogMessage = async (message) => {
|
|
125
|
-
const messageOutput = chalk.grey(message);
|
|
126
|
-
this.#debug(messageOutput);
|
|
127
|
-
this.#runner.instrumentData.message.push(messageOutput);
|
|
128
|
-
await this.#PublishTelemetry();
|
|
129
|
-
};
|
|
130
|
-
StartRunner = async () => {
|
|
131
|
-
await this.#OutputLogMessage(`StartRunner [${this.#runner.id}]`);
|
|
132
|
-
await this.#ForcePublishTelemetryData();
|
|
133
|
-
return true;
|
|
134
|
-
};
|
|
135
|
-
StopRunner = async () => {
|
|
136
|
-
await this.#OutputLogMessage(`StopRunner [${this.#runner.id}]`);
|
|
137
|
-
await this.#ForcePublishTelemetryData();
|
|
138
|
-
return true;
|
|
139
|
-
};
|
|
140
|
-
TerminateRunner = async () => {
|
|
141
|
-
await this.#OutputLogMessage(`TerminateRunner [${this.#runner.id}]`);
|
|
142
|
-
await this.#ForcePublishTelemetryData();
|
|
143
|
-
return true;
|
|
144
|
-
};
|
|
145
|
-
Completed = async () => {
|
|
146
|
-
await this.#OutputLogMessage(`Completed [${this.#runner.id}] [${JSON.stringify(this.#runner.instrumentData)}]`);
|
|
147
|
-
await this.#ForcePublishTelemetryData();
|
|
148
|
-
return true;
|
|
149
|
-
};
|
|
150
|
-
PauseRunner = async () => {
|
|
151
|
-
await this.#OutputLogMessage(`PauseRunner [${this.#runner.id}]`);
|
|
152
|
-
await this.#ForcePublishTelemetryData();
|
|
153
|
-
return true;
|
|
154
|
-
};
|
|
155
|
-
ResumeRunner = async () => {
|
|
156
|
-
await this.#OutputLogMessage(`ResumeRunner [${this.#runner.id}]`);
|
|
157
|
-
await this.#ForcePublishTelemetryData();
|
|
158
|
-
return true;
|
|
159
|
-
};
|
|
160
|
-
ResetRunner = async () => {
|
|
161
|
-
await this.#OutputLogMessage(`ResetRunner [${this.#runner.id}]`);
|
|
162
|
-
this.#runner.instrumentData.requestCount = 0;
|
|
163
|
-
await this.#ForcePublishTelemetryData();
|
|
164
|
-
return true;
|
|
165
|
-
};
|
|
166
|
-
UpdateRunner = async () => {
|
|
167
|
-
await this.#OutputLogMessage(`UpdateOptions [${this.#runner.id}]`);
|
|
168
|
-
await this.#ForcePublishTelemetryData();
|
|
169
|
-
return true;
|
|
170
|
-
};
|
|
171
|
-
};
|
|
172
|
-
//#endregion
|
|
173
|
-
//#region src/testCaseFhirBase.ts
|
|
20
|
+
//#region src/libmodule/testCaseFhirBase.ts
|
|
174
21
|
var TestCaseFhirBase = class {
|
|
175
22
|
#options;
|
|
176
23
|
#randomDataRecordset = [];
|
|
@@ -483,44 +330,12 @@ var TestCaseFhirBase = class {
|
|
|
483
330
|
this.#accesssToken = retVal;
|
|
484
331
|
return retVal;
|
|
485
332
|
};
|
|
486
|
-
GetPersonRecord_ZZ = async (prefix, index, version) => {
|
|
487
|
-
const { workerIndex, runnerIndex, runId } = this.#options;
|
|
488
|
-
const useId = `${prefix}-${index}`;
|
|
489
|
-
let firstName;
|
|
490
|
-
let lastName;
|
|
491
|
-
if (this.#options.useRedisForNames === true) {
|
|
492
|
-
const loaded = await (await this.runnerExecutionWorker.GetStore()).getRecord(runId, `${workerIndex}_${runnerIndex}_${this.runner.iteration}`);
|
|
493
|
-
firstName = loaded.givenName;
|
|
494
|
-
lastName = loaded.familyName;
|
|
495
|
-
} else {
|
|
496
|
-
const name = this.runnerExecutionWorker.GetFakerName(this.runner.iteration);
|
|
497
|
-
firstName = name.firstName;
|
|
498
|
-
lastName = name.lastName;
|
|
499
|
-
}
|
|
500
|
-
return {
|
|
501
|
-
id: useId,
|
|
502
|
-
resourceType: "Person",
|
|
503
|
-
name: [{
|
|
504
|
-
family: lastName,
|
|
505
|
-
given: [firstName],
|
|
506
|
-
use: `usual`
|
|
507
|
-
}],
|
|
508
|
-
text: {
|
|
509
|
-
div: `New Record ${this.runner.iteration}`,
|
|
510
|
-
status: "generated"
|
|
511
|
-
},
|
|
512
|
-
meta: {
|
|
513
|
-
versionId: version,
|
|
514
|
-
lastUpdated: (/* @__PURE__ */ new Date()).toISOString()
|
|
515
|
-
}
|
|
516
|
-
};
|
|
517
|
-
};
|
|
518
333
|
GetPersonRecord = async (prefix, index, version) => {
|
|
334
|
+
const { workerIndex, runnerIndex, runId } = this.#options;
|
|
519
335
|
const useId = `${prefix}-${index}`;
|
|
520
|
-
let name;
|
|
521
336
|
let firstName;
|
|
522
337
|
let lastName;
|
|
523
|
-
name = this.runnerExecutionWorker.GetFakerName(this.runner.iteration);
|
|
338
|
+
const name = this.runnerExecutionWorker.resourceDataGenerator.GetFakerName(this.runner.iteration);
|
|
524
339
|
firstName = name.firstName;
|
|
525
340
|
lastName = name.lastName;
|
|
526
341
|
return {
|
|
@@ -646,7 +461,7 @@ var TestCaseFhirBase = class {
|
|
|
646
461
|
};
|
|
647
462
|
};
|
|
648
463
|
//#endregion
|
|
649
|
-
//#region src/testCaseFhirQueryBase.ts
|
|
464
|
+
//#region src/libmodule/testCaseFhirQueryBase.ts
|
|
650
465
|
var TestCaseFhirQueryBase = class extends TestCaseFhirBase {
|
|
651
466
|
constructor(workerInstance, runner) {
|
|
652
467
|
super(workerInstance, runner);
|
|
@@ -693,7 +508,7 @@ var TestCaseFhirQueryBase = class extends TestCaseFhirBase {
|
|
|
693
508
|
};
|
|
694
509
|
};
|
|
695
510
|
//#endregion
|
|
696
|
-
//#region src/testCaseFhir01.ts
|
|
511
|
+
//#region src/libmodule/testCaseFhir01.ts
|
|
697
512
|
var TestCaseFhir01 = class extends TestCaseFhirQueryBase {
|
|
698
513
|
ExecuteQuery = async () => {
|
|
699
514
|
await this.GetAccessToken();
|
|
@@ -702,7 +517,7 @@ var TestCaseFhir01 = class extends TestCaseFhirQueryBase {
|
|
|
702
517
|
};
|
|
703
518
|
};
|
|
704
519
|
//#endregion
|
|
705
|
-
//#region src/testCaseFhir02.ts
|
|
520
|
+
//#region src/libmodule/testCaseFhir02.ts
|
|
706
521
|
var TestCaseFhir02 = class extends TestCaseFhirQueryBase {
|
|
707
522
|
ExecuteQuery = async () => {
|
|
708
523
|
try {
|
|
@@ -717,7 +532,7 @@ var TestCaseFhir02 = class extends TestCaseFhirQueryBase {
|
|
|
717
532
|
};
|
|
718
533
|
};
|
|
719
534
|
//#endregion
|
|
720
|
-
//#region src/testCaseFhir03.ts
|
|
535
|
+
//#region src/libmodule/testCaseFhir03.ts
|
|
721
536
|
var TestCaseFhir03 = class extends TestCaseFhirQueryBase {
|
|
722
537
|
ExecuteQuery = async () => {
|
|
723
538
|
const client = await this.GetClient();
|
|
@@ -732,7 +547,7 @@ var TestCaseFhir03 = class extends TestCaseFhirQueryBase {
|
|
|
732
547
|
};
|
|
733
548
|
};
|
|
734
549
|
//#endregion
|
|
735
|
-
//#region src/testCaseFhir04.ts
|
|
550
|
+
//#region src/libmodule/testCaseFhir04.ts
|
|
736
551
|
var TestCaseFhir04 = class extends TestCaseFhirQueryBase {
|
|
737
552
|
ExecuteQuery = async () => {
|
|
738
553
|
const client = await this.GetClient();
|
|
@@ -767,7 +582,7 @@ var TestCaseFhir04 = class extends TestCaseFhirQueryBase {
|
|
|
767
582
|
};
|
|
768
583
|
};
|
|
769
584
|
//#endregion
|
|
770
|
-
//#region src/testCaseFhir05.ts
|
|
585
|
+
//#region src/libmodule/testCaseFhir05.ts
|
|
771
586
|
var TestCaseFhir05 = class extends TestCaseFhirQueryBase {
|
|
772
587
|
ExecuteQuery = async () => {
|
|
773
588
|
const client = await this.GetClient();
|
|
@@ -789,7 +604,7 @@ var TestCaseFhir05 = class extends TestCaseFhirQueryBase {
|
|
|
789
604
|
};
|
|
790
605
|
};
|
|
791
606
|
//#endregion
|
|
792
|
-
//#region src/testCaseFhir06.ts
|
|
607
|
+
//#region src/libmodule/testCaseFhir06.ts
|
|
793
608
|
var TestCaseFhir06 = class extends TestCaseFhirQueryBase {
|
|
794
609
|
ExecuteQuery = async () => {
|
|
795
610
|
try {
|
|
@@ -1458,7 +1273,7 @@ Object.assign({}, core_exports, duplex_exports, {
|
|
|
1458
1273
|
unescapePathComponent
|
|
1459
1274
|
});
|
|
1460
1275
|
//#endregion
|
|
1461
|
-
//#region src/testCaseFhir07.ts
|
|
1276
|
+
//#region src/libmodule/testCaseFhir07.ts
|
|
1462
1277
|
var TestCaseFhir07 = class extends TestCaseFhirQueryBase {
|
|
1463
1278
|
ExecuteQuery = async () => {
|
|
1464
1279
|
const client = await this.GetClient();
|
|
@@ -1471,7 +1286,7 @@ var TestCaseFhir07 = class extends TestCaseFhirQueryBase {
|
|
|
1471
1286
|
};
|
|
1472
1287
|
};
|
|
1473
1288
|
//#endregion
|
|
1474
|
-
//#region src/testCaseFhir08.ts
|
|
1289
|
+
//#region src/libmodule/testCaseFhir08.ts
|
|
1475
1290
|
var TestCaseFhir08 = class extends TestCaseFhirQueryBase {
|
|
1476
1291
|
ExecuteQuery = async () => {
|
|
1477
1292
|
try {
|
|
@@ -1487,7 +1302,7 @@ var TestCaseFhir08 = class extends TestCaseFhirQueryBase {
|
|
|
1487
1302
|
};
|
|
1488
1303
|
};
|
|
1489
1304
|
//#endregion
|
|
1490
|
-
//#region src/testCaseFhir09.ts
|
|
1305
|
+
//#region src/libmodule/testCaseFhir09.ts
|
|
1491
1306
|
var TestCaseFhir09 = class extends TestCaseFhirQueryBase {
|
|
1492
1307
|
ExecuteQuery = async () => {
|
|
1493
1308
|
const client = await this.GetClient();
|
|
@@ -1500,7 +1315,7 @@ var TestCaseFhir09 = class extends TestCaseFhirQueryBase {
|
|
|
1500
1315
|
};
|
|
1501
1316
|
};
|
|
1502
1317
|
//#endregion
|
|
1503
|
-
//#region src/testCaseFhir10.ts
|
|
1318
|
+
//#region src/libmodule/testCaseFhir10.ts
|
|
1504
1319
|
var TestCaseFhir10 = class extends TestCaseFhirQueryBase {
|
|
1505
1320
|
ExecuteQuery = async () => {
|
|
1506
1321
|
const client = await this.GetClient();
|
|
@@ -1509,14 +1324,23 @@ var TestCaseFhir10 = class extends TestCaseFhirQueryBase {
|
|
|
1509
1324
|
};
|
|
1510
1325
|
};
|
|
1511
1326
|
//#endregion
|
|
1512
|
-
//#region src/
|
|
1513
|
-
var
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1327
|
+
//#region src/libmodule/asyncRunnerFactory.ts
|
|
1328
|
+
var AsyncRunnerFactory = class {
|
|
1329
|
+
static CreateAsyncRunner = async (runnerExecutionWorker, testRunnerTelemetryPayload) => {
|
|
1330
|
+
const { runner } = testRunnerTelemetryPayload;
|
|
1331
|
+
switch (runner.options.testType) {
|
|
1332
|
+
case "TestCaseFhir01": return new TestCaseFhir01(runnerExecutionWorker, runner);
|
|
1333
|
+
case "TestCaseFhir02": return new TestCaseFhir02(runnerExecutionWorker, runner);
|
|
1334
|
+
case "TestCaseFhir03": return new TestCaseFhir03(runnerExecutionWorker, runner);
|
|
1335
|
+
case "TestCaseFhir04": return new TestCaseFhir04(runnerExecutionWorker, runner);
|
|
1336
|
+
case "TestCaseFhir05": return new TestCaseFhir05(runnerExecutionWorker, runner);
|
|
1337
|
+
case "TestCaseFhir06": return new TestCaseFhir06(runnerExecutionWorker, runner);
|
|
1338
|
+
case "TestCaseFhir07": return new TestCaseFhir07(runnerExecutionWorker, runner);
|
|
1339
|
+
case "TestCaseFhir08": return new TestCaseFhir08(runnerExecutionWorker, runner);
|
|
1340
|
+
case "TestCaseFhir09": return new TestCaseFhir09(runnerExecutionWorker, runner);
|
|
1341
|
+
case "TestCaseFhir10": return new TestCaseFhir10(runnerExecutionWorker, runner);
|
|
1342
|
+
}
|
|
1343
|
+
return null;
|
|
1520
1344
|
};
|
|
1521
1345
|
};
|
|
1522
1346
|
//#endregion
|
|
@@ -35072,611 +34896,12 @@ var f = new er({ locale: [ys, {
|
|
|
35072
34896
|
}
|
|
35073
34897
|
}] });
|
|
35074
34898
|
//#endregion
|
|
35075
|
-
//#region src/
|
|
35076
|
-
var
|
|
35077
|
-
constructor(workerInstance, runner) {
|
|
35078
|
-
super(workerInstance, runner);
|
|
35079
|
-
}
|
|
35080
|
-
#debug = (message) => defaultLogger.debug(`SetupFhirTestResources: ${message}`);
|
|
35081
|
-
#error = (message) => defaultLogger.error(`SetupFhirTestResources (error): ${message}`);
|
|
35082
|
-
#GetPersonRecord = (testRecordPrefix, prefix, index, blockSize) => {
|
|
35083
|
-
const id = `${testRecordPrefix}_${index}`;
|
|
35084
|
-
const records = [];
|
|
35085
|
-
for (let i = 0; i < blockSize; i++) {
|
|
35086
|
-
const givenName = f.person.firstName();
|
|
35087
|
-
const family = f.person.lastName();
|
|
35088
|
-
records.push({
|
|
35089
|
-
id: `${prefix}_${randomUUID()}`,
|
|
35090
|
-
givenName,
|
|
35091
|
-
family
|
|
35092
|
-
});
|
|
35093
|
-
}
|
|
35094
|
-
return {
|
|
35095
|
-
id,
|
|
35096
|
-
_resourceType: "Person",
|
|
35097
|
-
name: [{
|
|
35098
|
-
family: `Block: [${index}]`,
|
|
35099
|
-
given: [`${index}`],
|
|
35100
|
-
use: `usual`
|
|
35101
|
-
}],
|
|
35102
|
-
text: {
|
|
35103
|
-
div: ``,
|
|
35104
|
-
status: "generated"
|
|
35105
|
-
},
|
|
35106
|
-
address: [{ text: records }]
|
|
35107
|
-
};
|
|
35108
|
-
};
|
|
35109
|
-
ExecuteRunner = async () => {
|
|
35110
|
-
const iteration = this.runner.iteration;
|
|
35111
|
-
const start = performance.now();
|
|
35112
|
-
const options = this.runner.options;
|
|
35113
|
-
if (this.runner.iteration === 0) f.seed(123);
|
|
35114
|
-
this.runner.instrumentData.activeRequestCount++;
|
|
35115
|
-
const personRecord = this.#GetPersonRecord(options.testBlocksPrefix, options.personPrefix, this.runner.iteration, options.blockSize);
|
|
35116
|
-
this.#debug(chalk.yellow(`ExecuteRunner(): Record Length: [${JSON.stringify(personRecord).length}]`));
|
|
35117
|
-
try {
|
|
35118
|
-
const retVal = await this.fhirClient.PostResource("Person", personRecord);
|
|
35119
|
-
this.#debug(chalk.yellow(`ExecuteRunner():CreateResource: Return ID: [${retVal?.body.id}]`));
|
|
35120
|
-
} catch (error) {
|
|
35121
|
-
this.#error(chalk.red(`ExecuteRunner():CreateResource: Error: [${error}]`));
|
|
35122
|
-
this.runner.instrumentData.errorCount++;
|
|
35123
|
-
}
|
|
35124
|
-
this.runner.instrumentData.coreCount = 1;
|
|
35125
|
-
this.runner.instrumentData.requestCount++;
|
|
35126
|
-
this.runner.instrumentData.velocity++;
|
|
35127
|
-
this.runner.instrumentData.activeRequestCount--;
|
|
35128
|
-
const outputMessage = `Iteration: [${iteration}] Request Count: [${this.runner.instrumentData.requestCount}] ${personRecord.id}`;
|
|
35129
|
-
this.runner.instrumentData.message.push(chalk.green(outputMessage));
|
|
35130
|
-
const diff = performance.now() - start;
|
|
35131
|
-
this.runner.instrumentData.duration = diff;
|
|
35132
|
-
await this.PublishTelemetry();
|
|
35133
|
-
return true;
|
|
35134
|
-
};
|
|
35135
|
-
};
|
|
35136
|
-
//#endregion
|
|
35137
|
-
//#region src/teststartup.ts
|
|
35138
|
-
var TestStartUp = class {
|
|
35139
|
-
#runner;
|
|
35140
|
-
#runnerExecutionWorker;
|
|
35141
|
-
#logMessageDataSet = {};
|
|
35142
|
-
#publishTelemetryTimeout = null;
|
|
35143
|
-
#publishTelemetryCount = 0;
|
|
35144
|
-
#maxBufferSize = 50;
|
|
35145
|
-
#publishTelemetryTimeoutVal = 1e3;
|
|
35146
|
-
#color;
|
|
35147
|
-
#randomPastelColour;
|
|
35148
|
-
#GetRandomHexColor() {
|
|
35149
|
-
return `#${Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0")}`;
|
|
35150
|
-
}
|
|
35151
|
-
#GetRandomPastelColor = () => {
|
|
35152
|
-
const r = Math.floor(Math.random() * 127 + 127);
|
|
35153
|
-
const g = Math.floor(Math.random() * 127 + 127);
|
|
35154
|
-
const b = Math.floor(Math.random() * 127 + 127);
|
|
35155
|
-
return `#${((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1).toUpperCase()}`;
|
|
35156
|
-
};
|
|
35157
|
-
constructor(workerInstance, runner) {
|
|
35158
|
-
this.#runnerExecutionWorker = workerInstance;
|
|
35159
|
-
this.#runner = runner;
|
|
35160
|
-
this.#color = this.#GetRandomHexColor();
|
|
35161
|
-
this.#randomPastelColour = this.#GetRandomPastelColor();
|
|
35162
|
-
}
|
|
35163
|
-
#debug = (message) => {
|
|
35164
|
-
this.#runnerExecutionWorker.logger.debug(message);
|
|
35165
|
-
};
|
|
35166
|
-
#GenLogMessage = (runner, iteration) => {
|
|
35167
|
-
if (!this.#logMessageDataSet[runner.id]) this.#logMessageDataSet[runner.id] = {
|
|
35168
|
-
adder: 1,
|
|
35169
|
-
indent: 0
|
|
35170
|
-
};
|
|
35171
|
-
const logMessageData = this.#logMessageDataSet[runner.id];
|
|
35172
|
-
let message = `${" ".repeat(logMessageData.indent)} [${runner.id}] >> Hello World << ${iteration}`;
|
|
35173
|
-
message = chalk.hex(this.#randomPastelColour)(message);
|
|
35174
|
-
runner.instrumentData.message.push(message);
|
|
35175
|
-
this.#debug(message);
|
|
35176
|
-
logMessageData.indent += logMessageData.adder;
|
|
35177
|
-
if (logMessageData.indent > 20) logMessageData.adder = -1;
|
|
35178
|
-
else if (logMessageData.indent === 0) logMessageData.adder = 1;
|
|
35179
|
-
};
|
|
35180
|
-
#SetupTimeout = async () => {
|
|
35181
|
-
if (!this.#publishTelemetryTimeout) {
|
|
35182
|
-
this.#publishTelemetryTimeout = setTimeout(async () => {
|
|
35183
|
-
await this.#PublishTelemetryData();
|
|
35184
|
-
this.#publishTelemetryCount = 0;
|
|
35185
|
-
this.#publishTelemetryTimeout = null;
|
|
35186
|
-
}, this.#publishTelemetryTimeoutVal);
|
|
35187
|
-
if (isNode) this.#publishTelemetryTimeout.unref();
|
|
35188
|
-
}
|
|
35189
|
-
};
|
|
35190
|
-
#PublishTelemetryData = async () => {
|
|
35191
|
-
this.#runnerExecutionWorker.PostTelemetryById(this.#runner.id);
|
|
35192
|
-
this.#runner.instrumentData.velocity = 0;
|
|
35193
|
-
this.#runner.instrumentData.message = [];
|
|
35194
|
-
this.#runner.instrumentData.tx = 0;
|
|
35195
|
-
this.#runner.instrumentData.rx = 0;
|
|
35196
|
-
await this.SleepImmediate();
|
|
35197
|
-
};
|
|
35198
|
-
#ForcePublishTelemetryData = async () => {
|
|
35199
|
-
await this.#PublishTelemetryData();
|
|
35200
|
-
};
|
|
35201
|
-
#PublishTelemetry = async () => {
|
|
35202
|
-
this.#publishTelemetryCount++;
|
|
35203
|
-
if (this.#publishTelemetryCount % this.#maxBufferSize === 0) {
|
|
35204
|
-
this.#publishTelemetryCount = 0;
|
|
35205
|
-
if (this.#publishTelemetryTimeout) {
|
|
35206
|
-
clearTimeout(this.#publishTelemetryTimeout);
|
|
35207
|
-
this.#publishTelemetryTimeout = null;
|
|
35208
|
-
}
|
|
35209
|
-
await this.#PublishTelemetryData();
|
|
35210
|
-
}
|
|
35211
|
-
if (!this.#publishTelemetryTimeout) this.#SetupTimeout();
|
|
35212
|
-
};
|
|
35213
|
-
SleepImmediate() {
|
|
35214
|
-
return new Promise((resolve, reject) => {
|
|
35215
|
-
resolve();
|
|
35216
|
-
});
|
|
35217
|
-
}
|
|
35218
|
-
ExecuteRunner = async () => {
|
|
35219
|
-
const start = performance.now();
|
|
35220
|
-
this.#runner.options;
|
|
35221
|
-
this.#runner.instrumentData.coreCount = 1;
|
|
35222
|
-
this.#runner.instrumentData.activeRequestCount++;
|
|
35223
|
-
this.#runner.instrumentData.requestCount++;
|
|
35224
|
-
this.#runner.instrumentData.velocity++;
|
|
35225
|
-
this.#runner.instrumentData.tx += 256e3;
|
|
35226
|
-
this.#runner.instrumentData.rx += 65e5;
|
|
35227
|
-
this.#debug(chalk.hex(this.#color)(`${this.#runner.iteration} - ${this.#runner.instrumentData.requestCount} - ${(/* @__PURE__ */ new Date()).getTime()}`));
|
|
35228
|
-
this.#debug(chalk.hex(this.#color)(`Begin the startup process ...`));
|
|
35229
|
-
for (let i = 0; i < 50; i++) {
|
|
35230
|
-
this.#debug(chalk.hex(this.#color)(` STARTUP --> ${performance.now()}`));
|
|
35231
|
-
await Sleep(100);
|
|
35232
|
-
}
|
|
35233
|
-
this.#debug(chalk.hex(this.#color)(`End the startup process ...`));
|
|
35234
|
-
this.#runner.instrumentData.activeRequestCount--;
|
|
35235
|
-
const diff = performance.now() - start;
|
|
35236
|
-
this.#runner.instrumentData.duration = diff;
|
|
35237
|
-
await this.#PublishTelemetry();
|
|
35238
|
-
return true;
|
|
35239
|
-
};
|
|
35240
|
-
#OutputLogMessage = async (message) => {
|
|
35241
|
-
const messageOutput = chalk.grey(message);
|
|
35242
|
-
this.#debug(messageOutput);
|
|
35243
|
-
this.#runner.instrumentData.message.push(messageOutput);
|
|
35244
|
-
await this.#PublishTelemetry();
|
|
35245
|
-
};
|
|
35246
|
-
StartRunner = async () => {
|
|
35247
|
-
await this.#OutputLogMessage(`StartRunner [${this.#runner.id}]`);
|
|
35248
|
-
await this.#ForcePublishTelemetryData();
|
|
35249
|
-
return true;
|
|
35250
|
-
};
|
|
35251
|
-
StopRunner = async () => {
|
|
35252
|
-
await this.#OutputLogMessage(`StopRunner [${this.#runner.id}]`);
|
|
35253
|
-
await this.#ForcePublishTelemetryData();
|
|
35254
|
-
return true;
|
|
35255
|
-
};
|
|
35256
|
-
TerminateRunner = async () => {
|
|
35257
|
-
await this.#OutputLogMessage(`TerminateRunner [${this.#runner.id}]`);
|
|
35258
|
-
await this.#ForcePublishTelemetryData();
|
|
35259
|
-
return true;
|
|
35260
|
-
};
|
|
35261
|
-
Completed = async () => {
|
|
35262
|
-
await this.#OutputLogMessage(`Completed [${this.#runner.id}] [${JSON.stringify(this.#runner.instrumentData)}]`);
|
|
35263
|
-
await this.#ForcePublishTelemetryData();
|
|
35264
|
-
return true;
|
|
35265
|
-
};
|
|
35266
|
-
PauseRunner = async () => {
|
|
35267
|
-
await this.#OutputLogMessage(`PauseRunner [${this.#runner.id}]`);
|
|
35268
|
-
await this.#ForcePublishTelemetryData();
|
|
35269
|
-
return true;
|
|
35270
|
-
};
|
|
35271
|
-
ResumeRunner = async () => {
|
|
35272
|
-
await this.#OutputLogMessage(`ResumeRunner [${this.#runner.id}]`);
|
|
35273
|
-
await this.#ForcePublishTelemetryData();
|
|
35274
|
-
return true;
|
|
35275
|
-
};
|
|
35276
|
-
ResetRunner = async () => {
|
|
35277
|
-
await this.#OutputLogMessage(`ResetRunner [${this.#runner.id}]`);
|
|
35278
|
-
this.#runner.instrumentData.requestCount = 0;
|
|
35279
|
-
await this.#ForcePublishTelemetryData();
|
|
35280
|
-
return true;
|
|
35281
|
-
};
|
|
35282
|
-
UpdateRunner = async () => {
|
|
35283
|
-
await this.#OutputLogMessage(`UpdateOptions [${this.#runner.id}]`);
|
|
35284
|
-
await this.#ForcePublishTelemetryData();
|
|
35285
|
-
return true;
|
|
35286
|
-
};
|
|
35287
|
-
};
|
|
35288
|
-
//#endregion
|
|
35289
|
-
//#region src/testshutdown.ts
|
|
35290
|
-
var TestShutDown = class {
|
|
35291
|
-
#runner;
|
|
35292
|
-
#workerInstance;
|
|
35293
|
-
#logMessageDataSet = {};
|
|
35294
|
-
#publishTelemetryTimeout = null;
|
|
35295
|
-
#publishTelemetryCount = 0;
|
|
35296
|
-
#maxBufferSize = 50;
|
|
35297
|
-
#publishTelemetryTimeoutVal = 1e3;
|
|
35298
|
-
#color;
|
|
35299
|
-
#randomPastelColour;
|
|
35300
|
-
#GetRandomHexColor() {
|
|
35301
|
-
return `#${Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0")}`;
|
|
35302
|
-
}
|
|
35303
|
-
#GetRandomPastelColor = () => {
|
|
35304
|
-
const r = Math.floor(Math.random() * 127 + 127);
|
|
35305
|
-
const g = Math.floor(Math.random() * 127 + 127);
|
|
35306
|
-
const b = Math.floor(Math.random() * 127 + 127);
|
|
35307
|
-
return `#${((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1).toUpperCase()}`;
|
|
35308
|
-
};
|
|
35309
|
-
constructor(workerInstance, runner) {
|
|
35310
|
-
this.#workerInstance = workerInstance;
|
|
35311
|
-
this.#runner = runner;
|
|
35312
|
-
this.#color = this.#GetRandomHexColor();
|
|
35313
|
-
this.#randomPastelColour = this.#GetRandomPastelColor();
|
|
35314
|
-
}
|
|
35315
|
-
#debug = (message) => {
|
|
35316
|
-
this.#workerInstance.logger.debug(message);
|
|
35317
|
-
};
|
|
35318
|
-
#GenLogMessage = (runner, iteration) => {
|
|
35319
|
-
if (!this.#logMessageDataSet[runner.id]) this.#logMessageDataSet[runner.id] = {
|
|
35320
|
-
adder: 1,
|
|
35321
|
-
indent: 0
|
|
35322
|
-
};
|
|
35323
|
-
const logMessageData = this.#logMessageDataSet[runner.id];
|
|
35324
|
-
let message = `${" ".repeat(logMessageData.indent)} [${runner.id}] >> Hello World << ${iteration}`;
|
|
35325
|
-
message = chalk.hex(this.#randomPastelColour)(message);
|
|
35326
|
-
runner.instrumentData.message.push(message);
|
|
35327
|
-
this.#debug(message);
|
|
35328
|
-
logMessageData.indent += logMessageData.adder;
|
|
35329
|
-
if (logMessageData.indent > 20) logMessageData.adder = -1;
|
|
35330
|
-
else if (logMessageData.indent === 0) logMessageData.adder = 1;
|
|
35331
|
-
};
|
|
35332
|
-
#SetupTimeout = async () => {
|
|
35333
|
-
if (!this.#publishTelemetryTimeout) {
|
|
35334
|
-
this.#publishTelemetryTimeout = setTimeout(async () => {
|
|
35335
|
-
await this.#PublishTelemetryData();
|
|
35336
|
-
this.#publishTelemetryCount = 0;
|
|
35337
|
-
this.#publishTelemetryTimeout = null;
|
|
35338
|
-
}, this.#publishTelemetryTimeoutVal);
|
|
35339
|
-
if (isNode) this.#publishTelemetryTimeout.unref();
|
|
35340
|
-
}
|
|
35341
|
-
};
|
|
35342
|
-
#PublishTelemetryData = async () => {
|
|
35343
|
-
this.#workerInstance.PostTelemetryById(this.#runner.id);
|
|
35344
|
-
this.#runner.instrumentData.velocity = 0;
|
|
35345
|
-
this.#runner.instrumentData.message = [];
|
|
35346
|
-
this.#runner.instrumentData.tx = 0;
|
|
35347
|
-
this.#runner.instrumentData.rx = 0;
|
|
35348
|
-
await this.SleepImmediate();
|
|
35349
|
-
};
|
|
35350
|
-
#ForcePublishTelemetryData = async () => {
|
|
35351
|
-
await this.#PublishTelemetryData();
|
|
35352
|
-
};
|
|
35353
|
-
#PublishTelemetry = async () => {
|
|
35354
|
-
this.#publishTelemetryCount++;
|
|
35355
|
-
if (this.#publishTelemetryCount % this.#maxBufferSize === 0) {
|
|
35356
|
-
this.#publishTelemetryCount = 0;
|
|
35357
|
-
if (this.#publishTelemetryTimeout) {
|
|
35358
|
-
clearTimeout(this.#publishTelemetryTimeout);
|
|
35359
|
-
this.#publishTelemetryTimeout = null;
|
|
35360
|
-
}
|
|
35361
|
-
await this.#PublishTelemetryData();
|
|
35362
|
-
}
|
|
35363
|
-
if (!this.#publishTelemetryTimeout) this.#SetupTimeout();
|
|
35364
|
-
};
|
|
35365
|
-
SleepImmediate() {
|
|
35366
|
-
return new Promise((resolve, reject) => {
|
|
35367
|
-
resolve();
|
|
35368
|
-
});
|
|
35369
|
-
}
|
|
35370
|
-
ExecuteRunner = async () => {
|
|
35371
|
-
const start = performance.now();
|
|
35372
|
-
this.#runner.options;
|
|
35373
|
-
this.#runner.instrumentData.coreCount = 1;
|
|
35374
|
-
this.#runner.instrumentData.activeRequestCount++;
|
|
35375
|
-
this.#runner.instrumentData.requestCount++;
|
|
35376
|
-
this.#runner.instrumentData.velocity++;
|
|
35377
|
-
this.#runner.instrumentData.tx += 256e3;
|
|
35378
|
-
this.#runner.instrumentData.rx += 65e5;
|
|
35379
|
-
this.#debug(chalk.hex(this.#color)(`${this.#runner.iteration} - ${this.#runner.instrumentData.requestCount} - ${(/* @__PURE__ */ new Date()).getTime()}`));
|
|
35380
|
-
this.#debug(chalk.hex(this.#color)(`Begin the shutdown process ...`));
|
|
35381
|
-
for (let i = 0; i < 50; i++) {
|
|
35382
|
-
this.#debug(chalk.hex(this.#color)(` SHUTDOWN --> ${performance.now()}`));
|
|
35383
|
-
await Sleep(100);
|
|
35384
|
-
}
|
|
35385
|
-
this.#debug(chalk.hex(this.#color)(`End the startup process ...`));
|
|
35386
|
-
this.#runner.instrumentData.activeRequestCount--;
|
|
35387
|
-
const diff = performance.now() - start;
|
|
35388
|
-
this.#runner.instrumentData.duration = diff;
|
|
35389
|
-
await this.#PublishTelemetry();
|
|
35390
|
-
return true;
|
|
35391
|
-
};
|
|
35392
|
-
#OutputLogMessage = async (message) => {
|
|
35393
|
-
const messageOutput = chalk.grey(message);
|
|
35394
|
-
this.#debug(messageOutput);
|
|
35395
|
-
this.#runner.instrumentData.message.push(messageOutput);
|
|
35396
|
-
await this.#PublishTelemetry();
|
|
35397
|
-
};
|
|
35398
|
-
StartRunner = async () => {
|
|
35399
|
-
await this.#OutputLogMessage(`StartRunner [${this.#runner.id}]`);
|
|
35400
|
-
await this.#ForcePublishTelemetryData();
|
|
35401
|
-
return true;
|
|
35402
|
-
};
|
|
35403
|
-
StopRunner = async () => {
|
|
35404
|
-
await this.#OutputLogMessage(`StopRunner [${this.#runner.id}]`);
|
|
35405
|
-
await this.#ForcePublishTelemetryData();
|
|
35406
|
-
return true;
|
|
35407
|
-
};
|
|
35408
|
-
TerminateRunner = async () => {
|
|
35409
|
-
await this.#OutputLogMessage(`TerminateRunner [${this.#runner.id}]`);
|
|
35410
|
-
await this.#ForcePublishTelemetryData();
|
|
35411
|
-
return true;
|
|
35412
|
-
};
|
|
35413
|
-
Completed = async () => {
|
|
35414
|
-
await this.#OutputLogMessage(`Completed [${this.#runner.id}] [${JSON.stringify(this.#runner.instrumentData)}]`);
|
|
35415
|
-
await this.#ForcePublishTelemetryData();
|
|
35416
|
-
return true;
|
|
35417
|
-
};
|
|
35418
|
-
PauseRunner = async () => {
|
|
35419
|
-
await this.#OutputLogMessage(`PauseRunner [${this.#runner.id}]`);
|
|
35420
|
-
await this.#ForcePublishTelemetryData();
|
|
35421
|
-
return true;
|
|
35422
|
-
};
|
|
35423
|
-
ResumeRunner = async () => {
|
|
35424
|
-
await this.#OutputLogMessage(`ResumeRunner [${this.#runner.id}]`);
|
|
35425
|
-
await this.#ForcePublishTelemetryData();
|
|
35426
|
-
return true;
|
|
35427
|
-
};
|
|
35428
|
-
ResetRunner = async () => {
|
|
35429
|
-
await this.#OutputLogMessage(`ResetRunner [${this.#runner.id}]`);
|
|
35430
|
-
this.#runner.instrumentData.requestCount = 0;
|
|
35431
|
-
await this.#ForcePublishTelemetryData();
|
|
35432
|
-
return true;
|
|
35433
|
-
};
|
|
35434
|
-
UpdateRunner = async () => {
|
|
35435
|
-
await this.#OutputLogMessage(`UpdateOptions [${this.#runner.id}]`);
|
|
35436
|
-
await this.#ForcePublishTelemetryData();
|
|
35437
|
-
return true;
|
|
35438
|
-
};
|
|
35439
|
-
};
|
|
35440
|
-
//#endregion
|
|
35441
|
-
//#region src/redisTestRunStore.ts
|
|
35442
|
-
var RedisTestRunStore = class {
|
|
35443
|
-
client;
|
|
35444
|
-
keyPrefix;
|
|
35445
|
-
defaultTtlSeconds;
|
|
35446
|
-
batchSize;
|
|
35447
|
-
maxDeleteBatchSize;
|
|
35448
|
-
connected = false;
|
|
35449
|
-
constructor(options) {
|
|
35450
|
-
this.options = options;
|
|
35451
|
-
this.keyPrefix = options.keyPrefix ?? "testrun";
|
|
35452
|
-
this.defaultTtlSeconds = options.defaultTtlSeconds ?? 3600;
|
|
35453
|
-
this.batchSize = options.batchSize ?? 1e3;
|
|
35454
|
-
this.maxDeleteBatchSize = options.maxDeleteBatchSize ?? 1e3;
|
|
35455
|
-
this.client = createClient({ url: options.redisUrl });
|
|
35456
|
-
this.client.on("error", (err) => {
|
|
35457
|
-
console.error("[RedisTestRunStore] Redis error:", err);
|
|
35458
|
-
});
|
|
35459
|
-
}
|
|
35460
|
-
async connect() {
|
|
35461
|
-
if (this.connected) return;
|
|
35462
|
-
await this.client.connect();
|
|
35463
|
-
this.connected = true;
|
|
35464
|
-
}
|
|
35465
|
-
async disconnect() {
|
|
35466
|
-
if (!this.connected) return;
|
|
35467
|
-
await this.client.quit();
|
|
35468
|
-
this.connected = false;
|
|
35469
|
-
}
|
|
35470
|
-
async ping() {
|
|
35471
|
-
await this.ensureConnected();
|
|
35472
|
-
return this.client.ping();
|
|
35473
|
-
}
|
|
35474
|
-
createRunId(prefix = "run") {
|
|
35475
|
-
return `${prefix}_${Date.now()}_${randomUUID()}`;
|
|
35476
|
-
}
|
|
35477
|
-
async seedRun(runId, records, options) {
|
|
35478
|
-
await this.ensureConnected();
|
|
35479
|
-
this.validateRunId(runId);
|
|
35480
|
-
if (!Array.isArray(records)) throw new Error("records must be an array");
|
|
35481
|
-
const ttlSeconds = options?.ttlSeconds ?? this.defaultTtlSeconds;
|
|
35482
|
-
const batchSize = options?.batchSize ?? this.batchSize;
|
|
35483
|
-
const storeMetadata = options?.storeMetadata ?? true;
|
|
35484
|
-
if (records.length === 0) {
|
|
35485
|
-
if (storeMetadata) await this.writeRunMetadata(runId, {
|
|
35486
|
-
runId,
|
|
35487
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
35488
|
-
recordCount: 0,
|
|
35489
|
-
ttlSeconds
|
|
35490
|
-
}, ttlSeconds);
|
|
35491
|
-
return;
|
|
35492
|
-
}
|
|
35493
|
-
for (const record of records) this.validateRecord(record);
|
|
35494
|
-
const trackingKey = this.getTrackingKey(runId);
|
|
35495
|
-
const recordChunks = this.chunk(records, batchSize);
|
|
35496
|
-
for (const chunk of recordChunks) {
|
|
35497
|
-
const multi = this.client.multi();
|
|
35498
|
-
for (const record of chunk) {
|
|
35499
|
-
const recordKey = this.getRecordKey(runId, record.id);
|
|
35500
|
-
const flatHash = this.toRedisHash(record);
|
|
35501
|
-
multi.hSet(recordKey, flatHash);
|
|
35502
|
-
multi.sAdd(trackingKey, recordKey);
|
|
35503
|
-
multi.expire(recordKey, ttlSeconds);
|
|
35504
|
-
}
|
|
35505
|
-
multi.expire(trackingKey, ttlSeconds);
|
|
35506
|
-
await multi.exec();
|
|
35507
|
-
}
|
|
35508
|
-
if (storeMetadata) await this.writeRunMetadata(runId, {
|
|
35509
|
-
runId,
|
|
35510
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
35511
|
-
recordCount: records.length,
|
|
35512
|
-
ttlSeconds
|
|
35513
|
-
}, ttlSeconds);
|
|
35514
|
-
}
|
|
35515
|
-
async getRecord(runId, recordId) {
|
|
35516
|
-
await this.ensureConnected();
|
|
35517
|
-
this.validateRunId(runId);
|
|
35518
|
-
this.validateRecordId(recordId);
|
|
35519
|
-
const recordKey = this.getRecordKey(runId, recordId);
|
|
35520
|
-
const data = await this.client.hGetAll(recordKey);
|
|
35521
|
-
return Object.keys(data).length === 0 ? null : data;
|
|
35522
|
-
}
|
|
35523
|
-
async hasRecord(runId, recordId) {
|
|
35524
|
-
await this.ensureConnected();
|
|
35525
|
-
this.validateRunId(runId);
|
|
35526
|
-
this.validateRecordId(recordId);
|
|
35527
|
-
const recordKey = this.getRecordKey(runId, recordId);
|
|
35528
|
-
return await this.client.exists(recordKey) === 1;
|
|
35529
|
-
}
|
|
35530
|
-
async deleteRecord(runId, recordId) {
|
|
35531
|
-
await this.ensureConnected();
|
|
35532
|
-
this.validateRunId(runId);
|
|
35533
|
-
this.validateRecordId(recordId);
|
|
35534
|
-
const recordKey = this.getRecordKey(runId, recordId);
|
|
35535
|
-
const trackingKey = this.getTrackingKey(runId);
|
|
35536
|
-
const multi = this.client.multi();
|
|
35537
|
-
multi.del(recordKey);
|
|
35538
|
-
multi.sRem(trackingKey, recordKey);
|
|
35539
|
-
const delResult = (await multi.exec())?.[0];
|
|
35540
|
-
return Number(delResult) > 0;
|
|
35541
|
-
}
|
|
35542
|
-
async countRunRecords(runId) {
|
|
35543
|
-
await this.ensureConnected();
|
|
35544
|
-
this.validateRunId(runId);
|
|
35545
|
-
const trackingKey = this.getTrackingKey(runId);
|
|
35546
|
-
return this.client.sCard(trackingKey);
|
|
35547
|
-
}
|
|
35548
|
-
async getRunMetadata(runId) {
|
|
35549
|
-
await this.ensureConnected();
|
|
35550
|
-
this.validateRunId(runId);
|
|
35551
|
-
const metadataKey = this.getMetadataKey(runId);
|
|
35552
|
-
const data = await this.client.hGetAll(metadataKey);
|
|
35553
|
-
return Object.keys(data).length === 0 ? null : data;
|
|
35554
|
-
}
|
|
35555
|
-
async cleanupRun(runId) {
|
|
35556
|
-
await this.ensureConnected();
|
|
35557
|
-
this.validateRunId(runId);
|
|
35558
|
-
const trackingKey = this.getTrackingKey(runId);
|
|
35559
|
-
const metadataKey = this.getMetadataKey(runId);
|
|
35560
|
-
const recordKeys = await this.client.sMembers(trackingKey);
|
|
35561
|
-
let deletedRecordKeys = 0;
|
|
35562
|
-
for (const chunk of this.chunk(recordKeys, this.maxDeleteBatchSize)) {
|
|
35563
|
-
if (chunk.length === 0) continue;
|
|
35564
|
-
deletedRecordKeys += await this.client.del(chunk);
|
|
35565
|
-
}
|
|
35566
|
-
const deletedTrackingKey = await this.client.del(trackingKey) > 0;
|
|
35567
|
-
const deletedMetadataKey = await this.client.del(metadataKey) > 0;
|
|
35568
|
-
return {
|
|
35569
|
-
runId,
|
|
35570
|
-
deletedRecordKeys,
|
|
35571
|
-
deletedTrackingKey,
|
|
35572
|
-
deletedMetadataKey
|
|
35573
|
-
};
|
|
35574
|
-
}
|
|
35575
|
-
async extendRunTtl(runId, ttlSeconds) {
|
|
35576
|
-
await this.ensureConnected();
|
|
35577
|
-
this.validateRunId(runId);
|
|
35578
|
-
const trackingKey = this.getTrackingKey(runId);
|
|
35579
|
-
const metadataKey = this.getMetadataKey(runId);
|
|
35580
|
-
const recordKeys = await this.client.sMembers(trackingKey);
|
|
35581
|
-
for (const chunk of this.chunk(recordKeys, this.batchSize)) {
|
|
35582
|
-
const multi = this.client.multi();
|
|
35583
|
-
for (const key of chunk) multi.expire(key, ttlSeconds);
|
|
35584
|
-
await multi.exec();
|
|
35585
|
-
}
|
|
35586
|
-
await this.client.expire(trackingKey, ttlSeconds);
|
|
35587
|
-
await this.client.expire(metadataKey, ttlSeconds);
|
|
35588
|
-
}
|
|
35589
|
-
async listRunRecordKeys(runId) {
|
|
35590
|
-
await this.ensureConnected();
|
|
35591
|
-
this.validateRunId(runId);
|
|
35592
|
-
return this.client.sMembers(this.getTrackingKey(runId));
|
|
35593
|
-
}
|
|
35594
|
-
async getRunTtl(runId) {
|
|
35595
|
-
await this.ensureConnected();
|
|
35596
|
-
this.validateRunId(runId);
|
|
35597
|
-
const trackingKey = this.getTrackingKey(runId);
|
|
35598
|
-
const metadataKey = this.getMetadataKey(runId);
|
|
35599
|
-
const [trackingKeyTtl, metadataKeyTtl] = await Promise.all([this.client.ttl(trackingKey), this.client.ttl(metadataKey)]);
|
|
35600
|
-
return {
|
|
35601
|
-
trackingKeyTtl,
|
|
35602
|
-
metadataKeyTtl
|
|
35603
|
-
};
|
|
35604
|
-
}
|
|
35605
|
-
async writeRunMetadata(runId, metadata, ttlSeconds) {
|
|
35606
|
-
const metadataKey = this.getMetadataKey(runId);
|
|
35607
|
-
const multi = this.client.multi();
|
|
35608
|
-
multi.hSet(metadataKey, {
|
|
35609
|
-
runId: metadata.runId,
|
|
35610
|
-
createdAt: metadata.createdAt,
|
|
35611
|
-
recordCount: String(metadata.recordCount),
|
|
35612
|
-
ttlSeconds: String(metadata.ttlSeconds)
|
|
35613
|
-
});
|
|
35614
|
-
multi.expire(metadataKey, ttlSeconds);
|
|
35615
|
-
await multi.exec();
|
|
35616
|
-
}
|
|
35617
|
-
getRecordKey(runId, recordId) {
|
|
35618
|
-
return `${this.keyPrefix}:${runId}:record:${recordId}`;
|
|
35619
|
-
}
|
|
35620
|
-
getTrackingKey(runId) {
|
|
35621
|
-
return `${this.keyPrefix}:${runId}:keys`;
|
|
35622
|
-
}
|
|
35623
|
-
getMetadataKey(runId) {
|
|
35624
|
-
return `${this.keyPrefix}:${runId}:meta`;
|
|
35625
|
-
}
|
|
35626
|
-
toRedisHash(record) {
|
|
35627
|
-
const out = {};
|
|
35628
|
-
for (const [key, value] of Object.entries(record)) {
|
|
35629
|
-
if (value === void 0) continue;
|
|
35630
|
-
out[key] = String(value);
|
|
35631
|
-
}
|
|
35632
|
-
return out;
|
|
35633
|
-
}
|
|
35634
|
-
chunk(items, size) {
|
|
35635
|
-
if (size <= 0) throw new Error("Chunk size must be > 0");
|
|
35636
|
-
const result = [];
|
|
35637
|
-
for (let i = 0; i < items.length; i += size) result.push(items.slice(i, i + size));
|
|
35638
|
-
return result;
|
|
35639
|
-
}
|
|
35640
|
-
validateRunId(runId) {
|
|
35641
|
-
if (!runId || typeof runId !== "string") throw new Error("runId must be a non-empty string");
|
|
35642
|
-
}
|
|
35643
|
-
validateRecordId(recordId) {
|
|
35644
|
-
if (!recordId || typeof recordId !== "string") throw new Error("recordId must be a non-empty string");
|
|
35645
|
-
}
|
|
35646
|
-
validateRecord(record) {
|
|
35647
|
-
if (!record || typeof record !== "object") throw new Error("record must be an object");
|
|
35648
|
-
if (!record.id || typeof record.id !== "string") throw new Error("record.id must be a non-empty string");
|
|
35649
|
-
if (typeof record.givenName !== "string") throw new Error(`record ${record.id}: givenName must be a string`);
|
|
35650
|
-
if (typeof record.familyName !== "string") throw new Error(`record ${record.id}: familyName must be a string`);
|
|
35651
|
-
if (typeof record.worker !== "number") throw new Error(`record ${record.id}: worker must be a number`);
|
|
35652
|
-
if (typeof record.runner !== "number") throw new Error(`record ${record.id}: runner must be a number`);
|
|
35653
|
-
if (typeof record.iteration !== "number") throw new Error(`record ${record.id}: iteration must be a number`);
|
|
35654
|
-
}
|
|
35655
|
-
async ensureConnected() {
|
|
35656
|
-
if (!this.connected) await this.connect();
|
|
35657
|
-
}
|
|
35658
|
-
};
|
|
35659
|
-
//#endregion
|
|
35660
|
-
//#region src/workerTestCases.ts
|
|
35661
|
-
var WorkerTestCases = class extends AbstractRunnerExecutionWorker {
|
|
35662
|
-
#port;
|
|
34899
|
+
//#region src/libmodule/resourceDataGenerator.ts
|
|
34900
|
+
var ResourceDataGenerator = class {
|
|
35663
34901
|
#randomNameList = {};
|
|
35664
|
-
_store;
|
|
35665
34902
|
constructor() {
|
|
35666
|
-
super();
|
|
35667
34903
|
f.seed(123);
|
|
35668
34904
|
}
|
|
35669
|
-
GetStore = async () => {
|
|
35670
|
-
if (!this._store) this._store = new RedisTestRunStore({
|
|
35671
|
-
redisUrl: this.Options.userData.redisStoreConnection,
|
|
35672
|
-
keyPrefix: "testrun",
|
|
35673
|
-
defaultTtlSeconds: 3600,
|
|
35674
|
-
batchSize: 1e3,
|
|
35675
|
-
maxDeleteBatchSize: 1e3
|
|
35676
|
-
});
|
|
35677
|
-
await this._store.ensureConnected();
|
|
35678
|
-
return this._store;
|
|
35679
|
-
};
|
|
35680
34905
|
GetFakerName = (index) => {
|
|
35681
34906
|
if (this.#randomNameList[index.toString()]) return this.#randomNameList[index.toString()];
|
|
35682
34907
|
const fakerNameTuple = {
|
|
@@ -35686,53 +34911,26 @@ var WorkerTestCases = class extends AbstractRunnerExecutionWorker {
|
|
|
35686
34911
|
this.#randomNameList[index.toString()] = fakerNameTuple;
|
|
35687
34912
|
return this.#randomNameList[index.toString()];
|
|
35688
34913
|
};
|
|
34914
|
+
};
|
|
34915
|
+
//#endregion
|
|
34916
|
+
//#region src/libmodule/workerFhirTestCases.ts
|
|
34917
|
+
var WorkerFhirTestCases = class extends AbstractRunnerExecutionWorker {
|
|
34918
|
+
_resourceDataGenerator;
|
|
34919
|
+
constructor() {
|
|
34920
|
+
super();
|
|
34921
|
+
this._resourceDataGenerator = new ResourceDataGenerator();
|
|
34922
|
+
}
|
|
34923
|
+
get resourceDataGenerator() {
|
|
34924
|
+
return this._resourceDataGenerator;
|
|
34925
|
+
}
|
|
35689
34926
|
get logger() {
|
|
35690
34927
|
return defaultLogger;
|
|
35691
34928
|
}
|
|
35692
|
-
SetPort = (message) => {
|
|
35693
|
-
console.log(chalk.red(`************** SetPort`));
|
|
35694
|
-
this.#port = message.payload.port;
|
|
35695
|
-
this.#port.on("message", (data) => {
|
|
35696
|
-
console.log(chalk.red(`************** on message`));
|
|
35697
|
-
if (isNode) this.ProcessMessage(data);
|
|
35698
|
-
else this.ProcessMessage(data.data);
|
|
35699
|
-
});
|
|
35700
|
-
this.ProcessMessage(message);
|
|
35701
|
-
};
|
|
35702
34929
|
CreateAsyncRunner = async (testRunnerTelemetryPayload) => {
|
|
35703
|
-
|
|
35704
|
-
switch (runner.options.testType) {
|
|
35705
|
-
case "TestStartUp": return new TestStartUp(this, runner);
|
|
35706
|
-
case "TestShutDown": return new TestShutDown(this, runner);
|
|
35707
|
-
case "StartUpDelFhirResources": return new StartUpDelFhirResources(this, runner);
|
|
35708
|
-
case "TestCase01": return new TestCase01(this, runner);
|
|
35709
|
-
case "TestCaseFhir01": return new TestCaseFhir01(this, runner);
|
|
35710
|
-
case "TestCaseFhir02": return new TestCaseFhir02(this, runner);
|
|
35711
|
-
case "TestCaseFhir03": return new TestCaseFhir03(this, runner);
|
|
35712
|
-
case "TestCaseFhir04": return new TestCaseFhir04(this, runner);
|
|
35713
|
-
case "TestCaseFhir05": return new TestCaseFhir05(this, runner);
|
|
35714
|
-
case "TestCaseFhir06": return new TestCaseFhir06(this, runner);
|
|
35715
|
-
case "TestCaseFhir07": return new TestCaseFhir07(this, runner);
|
|
35716
|
-
case "TestCaseFhir08": return new TestCaseFhir08(this, runner);
|
|
35717
|
-
case "TestCaseFhir09": return new TestCaseFhir09(this, runner);
|
|
35718
|
-
case "TestCaseFhir10": return new TestCaseFhir10(this, runner);
|
|
35719
|
-
case "SetupFhirTestResources": return new SetupFhirTestResources(this, runner);
|
|
35720
|
-
}
|
|
35721
|
-
return null;
|
|
34930
|
+
return AsyncRunnerFactory.CreateAsyncRunner(this, testRunnerTelemetryPayload);
|
|
35722
34931
|
};
|
|
35723
34932
|
};
|
|
35724
|
-
console.log(chalk.red(`************** SetPort`));
|
|
35725
|
-
var worker = new WorkerTestCases();
|
|
35726
|
-
parentPort?.on("message", (data) => {
|
|
35727
|
-
const { command, payload } = data;
|
|
35728
|
-
if (command === eIWMessageCommands.MessagePort) {
|
|
35729
|
-
payload.port.on("message", (data) => {
|
|
35730
|
-
worker.ProcessMessage(data);
|
|
35731
|
-
});
|
|
35732
|
-
worker.ProcessMessage(data);
|
|
35733
|
-
} else throw new Error(`Invalid command: [${command}]`);
|
|
35734
|
-
});
|
|
35735
34933
|
//#endregion
|
|
35736
|
-
export {
|
|
34934
|
+
export { WorkerFhirTestCases };
|
|
35737
34935
|
|
|
35738
34936
|
//# sourceMappingURL=ststestrunner.mjs.map
|