@nsshunt/ststestrunner 1.1.72 → 1.1.74
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 +90 -51
- package/dist/ststestrunner.cjs.map +1 -1
- package/dist/ststestrunner.mjs +90 -51
- package/dist/ststestrunner.mjs.map +1 -1
- package/package.json +1 -1
- package/types/libmodule/testCaseFhirBase.d.ts +2 -2
- package/types/libmodule/testCaseFhirBase.d.ts.map +1 -1
- package/types/libmodule/testCaseFhirQueryBase.d.ts +2 -0
- package/types/libmodule/testCaseFhirQueryBase.d.ts.map +1 -1
package/dist/ststestrunner.mjs
CHANGED
|
@@ -31,6 +31,7 @@ var TestCaseFhirBase = class {
|
|
|
31
31
|
#resetSocketClientTrigger = 50;
|
|
32
32
|
#clientSocketFetchCount = 0;
|
|
33
33
|
#authAgentManager;
|
|
34
|
+
_authMaxTimeout = 5e3;
|
|
34
35
|
accessTokenTime = performance.now();
|
|
35
36
|
newTokenLimitTime = 30;
|
|
36
37
|
restFhirClient = null;
|
|
@@ -180,20 +181,17 @@ var TestCaseFhirBase = class {
|
|
|
180
181
|
this.Debug(chalk.yellow(`[${this.runnerExecutionWorker.id}] release hold (lock) Time taken for socket connection and set object: [${performance.now() - start}ms]`));
|
|
181
182
|
return fhirClient;
|
|
182
183
|
} catch (error) {
|
|
183
|
-
this.
|
|
184
|
+
this.Error(error);
|
|
184
185
|
throw error;
|
|
185
186
|
}
|
|
186
187
|
};
|
|
187
188
|
#LogMessage = (message) => {};
|
|
188
|
-
LogErrorMessage = (message) => {
|
|
189
|
-
this.#runner.instrumentData.message.push(chalk.red(`${message}`));
|
|
190
|
-
};
|
|
191
189
|
Debug = (message) => {
|
|
192
190
|
this.#runnerExecutionWorker.logger.debug(message);
|
|
193
191
|
};
|
|
194
192
|
Error = (message) => {
|
|
195
|
-
this.LogErrorMessage(message);
|
|
196
193
|
this.#runnerExecutionWorker.logger.error(message);
|
|
194
|
+
this.#runner.instrumentData.message.push(chalk.red(`${message}`));
|
|
197
195
|
};
|
|
198
196
|
Warning = (message) => {
|
|
199
197
|
this.#runnerExecutionWorker.logger.warn(message);
|
|
@@ -235,13 +233,9 @@ var TestCaseFhirBase = class {
|
|
|
235
233
|
const match = uri.match(this.#originRegex);
|
|
236
234
|
return match ? match[1] : null;
|
|
237
235
|
};
|
|
238
|
-
GetAPITokenFromAuthServerUsingScope = async (options
|
|
236
|
+
GetAPITokenFromAuthServerUsingScope = async (options) => {
|
|
239
237
|
const { scope, clientId, authClientSecret, endPoint } = options;
|
|
240
238
|
let stage = "1";
|
|
241
|
-
const invokeErrorCb = (error) => {
|
|
242
|
-
this.Debug(error);
|
|
243
|
-
errorCb(error);
|
|
244
|
-
};
|
|
245
239
|
try {
|
|
246
240
|
stage = "2";
|
|
247
241
|
const scopes = scope.split(" ");
|
|
@@ -268,10 +262,7 @@ var TestCaseFhirBase = class {
|
|
|
268
262
|
}
|
|
269
263
|
}
|
|
270
264
|
stage = "4";
|
|
271
|
-
if (error)
|
|
272
|
-
invokeErrorCb(error);
|
|
273
|
-
return "";
|
|
274
|
-
}
|
|
265
|
+
if (error) throw error;
|
|
275
266
|
stage = "5";
|
|
276
267
|
const payload = {
|
|
277
268
|
client_id: clientId,
|
|
@@ -300,11 +291,8 @@ var TestCaseFhirBase = class {
|
|
|
300
291
|
this.#runner.instrumentData.authenticationCount++;
|
|
301
292
|
stage = "7";
|
|
302
293
|
if (retVal.status) {
|
|
303
|
-
if (retVal.status !== 200) this.
|
|
304
|
-
} else
|
|
305
|
-
invokeErrorCb(new Error(chalk.red(`Error (AuthUtilsNode:GetAPITokenFromServer:No retVal.status)`)));
|
|
306
|
-
return "";
|
|
307
|
-
}
|
|
294
|
+
if (retVal.status !== 200) this.Warning(chalk.magenta(`TestCaseFhirBase:GetAPITokenFromAuthServerUsingScope(): Invalid response from server: [${retVal.status}]`));
|
|
295
|
+
} else throw new Error(chalk.red(`No retVal.status)`));
|
|
308
296
|
stage = "8";
|
|
309
297
|
if (retVal.data) {
|
|
310
298
|
stage = "9";
|
|
@@ -313,13 +301,11 @@ var TestCaseFhirBase = class {
|
|
|
313
301
|
return retVal.data.access_token;
|
|
314
302
|
} else {
|
|
315
303
|
stage = "13";
|
|
316
|
-
|
|
317
|
-
return "";
|
|
304
|
+
throw new Error(`No retVal.data.access_token)`);
|
|
318
305
|
}
|
|
319
306
|
} else {
|
|
320
307
|
stage = "14";
|
|
321
|
-
|
|
322
|
-
return "";
|
|
308
|
+
throw new Error(`No retVal.data)`);
|
|
323
309
|
}
|
|
324
310
|
} catch (error) {
|
|
325
311
|
this.Error(error);
|
|
@@ -329,34 +315,64 @@ var TestCaseFhirBase = class {
|
|
|
329
315
|
} catch (error) {
|
|
330
316
|
details = `Could not JSON.stringify(error.response.data)`;
|
|
331
317
|
}
|
|
332
|
-
|
|
333
|
-
|
|
318
|
+
error.message = `TestCaseFhirBase:GetAPITokenFromAuthServerUsingScope(): Error: [${error}], Stage: [${stage}], Details: [${details}]`;
|
|
319
|
+
throw error;
|
|
334
320
|
}
|
|
335
321
|
};
|
|
336
|
-
GetAccessTokenForSocketClientAccess = () => {
|
|
337
|
-
const
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
322
|
+
GetAccessTokenForSocketClientAccess = async () => {
|
|
323
|
+
const timeout = setTimeout(() => {
|
|
324
|
+
this.Warning(`TestCaseFhirBase:GetAccessTokenForSocketClientAccess(): Timeout: [${this._authMaxTimeout}] exceeded for getting access token ...`);
|
|
325
|
+
}, this._authMaxTimeout);
|
|
326
|
+
const start = performance.now();
|
|
327
|
+
try {
|
|
328
|
+
const scopes = `api://fb6513e4-16fe-4931-bed8-33b82b404a14/_.stsfhir5:SocketConnection`.split(" ").sort().join(" ");
|
|
329
|
+
const authendpointUrl = `${this.#options.authOptions.asendpoint}:${this.#options.authOptions.asport}`;
|
|
330
|
+
const retVal = await this.GetAPITokenFromAuthServerUsingScope({
|
|
331
|
+
clientId: "d8277fce-bb48-44c2-bbf1-257fe13a444b",
|
|
332
|
+
authClientSecret: "64e3ef37-c7b8-4cb1-880a-e6ad3ab36e3c",
|
|
333
|
+
scope: scopes,
|
|
334
|
+
endPoint: authendpointUrl
|
|
335
|
+
});
|
|
336
|
+
clearTimeout(timeout);
|
|
337
|
+
const totalTime = performance.now() - start;
|
|
338
|
+
if (totalTime > this._authMaxTimeout) this.Warning(chalk.magenta(`TestCaseFhirBase:GetAccessTokenForSocketClientAccess(): The total time for getting the access token: [${totalTime}]`));
|
|
339
|
+
return retVal;
|
|
340
|
+
} catch (error) {
|
|
341
|
+
clearTimeout(timeout);
|
|
342
|
+
error.message = `TestCaseFhirBase:GetAccessTokenForSocketClientAccess(): Error: [${error}], Duration until error: [${performance.now() - start}]`;
|
|
343
|
+
this.Error(error);
|
|
344
|
+
return "";
|
|
345
|
+
}
|
|
345
346
|
};
|
|
346
347
|
GetAccessToken = async () => {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
348
|
+
let timeout = void 0;
|
|
349
|
+
let start = performance.now();
|
|
350
|
+
try {
|
|
351
|
+
if (start - this.accessTokenTime > this.newTokenLimitTime * 1e3) this.#accesssToken = null;
|
|
352
|
+
if (this.#accesssToken) return this.#accesssToken;
|
|
353
|
+
timeout = setTimeout(() => {
|
|
354
|
+
this.Warning(chalk.magenta(`TestCaseFhirBase:GetAccessToken(): Timeout: [${this._authMaxTimeout}] exceeded for getting access token ...`));
|
|
355
|
+
}, this._authMaxTimeout);
|
|
356
|
+
const scopes = `api://fb6513e4-16fe-4931-bed8-33b82b404a14/_.stsfhir5:All`.split(" ").sort().join(" ");
|
|
357
|
+
const authendpointUrl = `${this.#options.authOptions.asendpoint}:${this.#options.authOptions.asport}`;
|
|
358
|
+
const retVal = await this.GetAPITokenFromAuthServerUsingScope({
|
|
359
|
+
clientId: "d8277fce-bb48-44c2-bbf1-257fe13a444b",
|
|
360
|
+
authClientSecret: "64e3ef37-c7b8-4cb1-880a-e6ad3ab36e3c",
|
|
361
|
+
scope: scopes,
|
|
362
|
+
endPoint: authendpointUrl
|
|
363
|
+
});
|
|
364
|
+
this.accessTokenTime = performance.now();
|
|
365
|
+
this.#accesssToken = retVal;
|
|
366
|
+
if (timeout) clearTimeout(timeout);
|
|
367
|
+
const totalTime = performance.now() - start;
|
|
368
|
+
if (totalTime > this._authMaxTimeout) this.Warning(chalk.magenta(`TestCaseFhirBase:GetAccessToken(): The total time for getting the access token: [${totalTime}]`));
|
|
369
|
+
return retVal;
|
|
370
|
+
} catch (error) {
|
|
371
|
+
if (timeout) clearTimeout(timeout);
|
|
372
|
+
error.message = `TestCaseFhirBase:GetAccessToken(): Error: [${error}], Duration until error: [${performance.now() - start}]`;
|
|
373
|
+
this.Error(error);
|
|
374
|
+
return "";
|
|
375
|
+
}
|
|
360
376
|
};
|
|
361
377
|
GetPersonRecord = async (prefix, index, version) => {
|
|
362
378
|
const { workerIndex, runnerIndex, runId } = this.#options;
|
|
@@ -488,6 +504,7 @@ var TestCaseFhirBase = class {
|
|
|
488
504
|
//#endregion
|
|
489
505
|
//#region src/libmodule/testCaseFhirQueryBase.ts
|
|
490
506
|
var TestCaseFhirQueryBase = class extends TestCaseFhirBase {
|
|
507
|
+
_longExecTimeoutVal = 5e3;
|
|
491
508
|
constructor(workerInstance, runner) {
|
|
492
509
|
super(workerInstance, runner);
|
|
493
510
|
}
|
|
@@ -508,17 +525,26 @@ var TestCaseFhirQueryBase = class extends TestCaseFhirBase {
|
|
|
508
525
|
if (this.runner.instrumentData.requestCount % this.runner.options.clientResetMod === 0) this.#ResetClient("#ResetClient triggered");
|
|
509
526
|
}
|
|
510
527
|
};
|
|
528
|
+
_GetDetail = () => {
|
|
529
|
+
return `testType: [${this.runner.options.testType}], description: [${this.runner.options.description}], workerManagerId: [${this.runner.workerManagerId}], Iteration: [${this.runner.iteration}]`;
|
|
530
|
+
};
|
|
511
531
|
ExecuteRunner = async () => {
|
|
512
|
-
if (this.runner.iteration % 100 === 0) this.Debug(`TestCaseFhirQueryBase:ExecuteRunner(): ${this.
|
|
532
|
+
if (this.runner.iteration % 100 === 0) this.Debug(`TestCaseFhirQueryBase:ExecuteRunner(): ${this._GetDetail()}`);
|
|
513
533
|
const start = performance.now();
|
|
514
534
|
this.runner.instrumentData.activeRequestCount++;
|
|
515
535
|
this.#CheckResetClient();
|
|
536
|
+
const longExecTimeout = setTimeout(() => {
|
|
537
|
+
this.Debug(chalk.magenta(`TestCaseFhirQueryBase:ExecuteRunner(): *** ==> Long execution: [${this._longExecTimeoutVal}] exceeded - still waiting ...`));
|
|
538
|
+
this.Debug(chalk.magenta(`TestCaseFhirQueryBase:ExecuteRunner(): ==> ${this._GetDetail()}`));
|
|
539
|
+
}, this._longExecTimeoutVal);
|
|
516
540
|
try {
|
|
517
541
|
await this.ExecuteQuery();
|
|
542
|
+
clearInterval(longExecTimeout);
|
|
518
543
|
} catch (error) {
|
|
544
|
+
clearInterval(longExecTimeout);
|
|
519
545
|
this.runner.instrumentData.errorCount++;
|
|
520
|
-
const message = `TestCaseFhirQueryBase:ExecuteRunner():
|
|
521
|
-
this.
|
|
546
|
+
const message = `TestCaseFhirQueryBase:ExecuteRunner(): Error: [${error}], Error Count: [${this.runner.instrumentData.errorCount}], ${this._GetDetail()}`;
|
|
547
|
+
this.Error(message);
|
|
522
548
|
this.#ResetClient(message);
|
|
523
549
|
}
|
|
524
550
|
this.runner.instrumentData.coreCount = 1;
|
|
@@ -527,8 +553,21 @@ var TestCaseFhirQueryBase = class extends TestCaseFhirBase {
|
|
|
527
553
|
this.runner.instrumentData.activeRequestCount--;
|
|
528
554
|
const diff = performance.now() - start;
|
|
529
555
|
this.runner.instrumentData.duration = diff;
|
|
530
|
-
if (diff >
|
|
556
|
+
if (diff > this._longExecTimeoutVal) {
|
|
557
|
+
this.Error(chalk.red(`TestCaseFhirQueryBase:ExecuteRunner(): *** ==> Long execution: [${diff}] Completed`));
|
|
558
|
+
this.Error(chalk.red(`TestCaseFhirQueryBase:ExecuteRunner(): ==> ${this._GetDetail()}`));
|
|
559
|
+
this.Error(chalk.red(`TestCaseFhirQueryBase:ExecuteRunner(): ==> Note: While not specifically an error, this is logged as an error.`));
|
|
560
|
+
} else if (diff > 200) {
|
|
561
|
+
this.Debug(chalk.rgb(155, 120, 200)(`TestCaseFhirQueryBase:ExecuteRunner(): *** ==> Long execution: [${diff}] Completed`));
|
|
562
|
+
this.Debug(chalk.rgb(155, 120, 200)(`TestCaseFhirQueryBase:ExecuteRunner(): ==> ${this._GetDetail()}`));
|
|
563
|
+
}
|
|
564
|
+
const longExecTimeoutpublishTelemetry = setTimeout(() => {
|
|
565
|
+
this.Error(chalk.red(`TestCaseFhirQueryBase:ExecuteRunner(): *** ==> Long execution: [${this._longExecTimeoutVal}] for PublishTelemetry()`));
|
|
566
|
+
this.Error(chalk.red(`TestCaseFhirQueryBase:ExecuteRunner(): ==> ${this._GetDetail()}`));
|
|
567
|
+
this.Error(chalk.red(`TestCaseFhirQueryBase:ExecuteRunner(): ==> Note: While not specifically an error, this is logged as an error.`));
|
|
568
|
+
}, this._longExecTimeoutVal);
|
|
531
569
|
await this.PublishTelemetry();
|
|
570
|
+
clearInterval(longExecTimeoutpublishTelemetry);
|
|
532
571
|
return true;
|
|
533
572
|
};
|
|
534
573
|
};
|