@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.cjs
CHANGED
|
@@ -54,6 +54,7 @@ var TestCaseFhirBase = class {
|
|
|
54
54
|
#resetSocketClientTrigger = 50;
|
|
55
55
|
#clientSocketFetchCount = 0;
|
|
56
56
|
#authAgentManager;
|
|
57
|
+
_authMaxTimeout = 5e3;
|
|
57
58
|
accessTokenTime = performance.now();
|
|
58
59
|
newTokenLimitTime = 30;
|
|
59
60
|
restFhirClient = null;
|
|
@@ -203,20 +204,17 @@ var TestCaseFhirBase = class {
|
|
|
203
204
|
this.Debug(chalk.default.yellow(`[${this.runnerExecutionWorker.id}] release hold (lock) Time taken for socket connection and set object: [${performance.now() - start}ms]`));
|
|
204
205
|
return fhirClient;
|
|
205
206
|
} catch (error) {
|
|
206
|
-
this.
|
|
207
|
+
this.Error(error);
|
|
207
208
|
throw error;
|
|
208
209
|
}
|
|
209
210
|
};
|
|
210
211
|
#LogMessage = (message) => {};
|
|
211
|
-
LogErrorMessage = (message) => {
|
|
212
|
-
this.#runner.instrumentData.message.push(chalk.default.red(`${message}`));
|
|
213
|
-
};
|
|
214
212
|
Debug = (message) => {
|
|
215
213
|
this.#runnerExecutionWorker.logger.debug(message);
|
|
216
214
|
};
|
|
217
215
|
Error = (message) => {
|
|
218
|
-
this.LogErrorMessage(message);
|
|
219
216
|
this.#runnerExecutionWorker.logger.error(message);
|
|
217
|
+
this.#runner.instrumentData.message.push(chalk.default.red(`${message}`));
|
|
220
218
|
};
|
|
221
219
|
Warning = (message) => {
|
|
222
220
|
this.#runnerExecutionWorker.logger.warn(message);
|
|
@@ -258,13 +256,9 @@ var TestCaseFhirBase = class {
|
|
|
258
256
|
const match = uri.match(this.#originRegex);
|
|
259
257
|
return match ? match[1] : null;
|
|
260
258
|
};
|
|
261
|
-
GetAPITokenFromAuthServerUsingScope = async (options
|
|
259
|
+
GetAPITokenFromAuthServerUsingScope = async (options) => {
|
|
262
260
|
const { scope, clientId, authClientSecret, endPoint } = options;
|
|
263
261
|
let stage = "1";
|
|
264
|
-
const invokeErrorCb = (error) => {
|
|
265
|
-
this.Debug(error);
|
|
266
|
-
errorCb(error);
|
|
267
|
-
};
|
|
268
262
|
try {
|
|
269
263
|
stage = "2";
|
|
270
264
|
const scopes = scope.split(" ");
|
|
@@ -291,10 +285,7 @@ var TestCaseFhirBase = class {
|
|
|
291
285
|
}
|
|
292
286
|
}
|
|
293
287
|
stage = "4";
|
|
294
|
-
if (error)
|
|
295
|
-
invokeErrorCb(error);
|
|
296
|
-
return "";
|
|
297
|
-
}
|
|
288
|
+
if (error) throw error;
|
|
298
289
|
stage = "5";
|
|
299
290
|
const payload = {
|
|
300
291
|
client_id: clientId,
|
|
@@ -323,11 +314,8 @@ var TestCaseFhirBase = class {
|
|
|
323
314
|
this.#runner.instrumentData.authenticationCount++;
|
|
324
315
|
stage = "7";
|
|
325
316
|
if (retVal.status) {
|
|
326
|
-
if (retVal.status !== 200) this.
|
|
327
|
-
} else
|
|
328
|
-
invokeErrorCb(new Error(chalk.default.red(`Error (AuthUtilsNode:GetAPITokenFromServer:No retVal.status)`)));
|
|
329
|
-
return "";
|
|
330
|
-
}
|
|
317
|
+
if (retVal.status !== 200) this.Warning(chalk.default.magenta(`TestCaseFhirBase:GetAPITokenFromAuthServerUsingScope(): Invalid response from server: [${retVal.status}]`));
|
|
318
|
+
} else throw new Error(chalk.default.red(`No retVal.status)`));
|
|
331
319
|
stage = "8";
|
|
332
320
|
if (retVal.data) {
|
|
333
321
|
stage = "9";
|
|
@@ -336,13 +324,11 @@ var TestCaseFhirBase = class {
|
|
|
336
324
|
return retVal.data.access_token;
|
|
337
325
|
} else {
|
|
338
326
|
stage = "13";
|
|
339
|
-
|
|
340
|
-
return "";
|
|
327
|
+
throw new Error(`No retVal.data.access_token)`);
|
|
341
328
|
}
|
|
342
329
|
} else {
|
|
343
330
|
stage = "14";
|
|
344
|
-
|
|
345
|
-
return "";
|
|
331
|
+
throw new Error(`No retVal.data)`);
|
|
346
332
|
}
|
|
347
333
|
} catch (error) {
|
|
348
334
|
this.Error(error);
|
|
@@ -352,34 +338,64 @@ var TestCaseFhirBase = class {
|
|
|
352
338
|
} catch (error) {
|
|
353
339
|
details = `Could not JSON.stringify(error.response.data)`;
|
|
354
340
|
}
|
|
355
|
-
|
|
356
|
-
|
|
341
|
+
error.message = `TestCaseFhirBase:GetAPITokenFromAuthServerUsingScope(): Error: [${error}], Stage: [${stage}], Details: [${details}]`;
|
|
342
|
+
throw error;
|
|
357
343
|
}
|
|
358
344
|
};
|
|
359
|
-
GetAccessTokenForSocketClientAccess = () => {
|
|
360
|
-
const
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
345
|
+
GetAccessTokenForSocketClientAccess = async () => {
|
|
346
|
+
const timeout = setTimeout(() => {
|
|
347
|
+
this.Warning(`TestCaseFhirBase:GetAccessTokenForSocketClientAccess(): Timeout: [${this._authMaxTimeout}] exceeded for getting access token ...`);
|
|
348
|
+
}, this._authMaxTimeout);
|
|
349
|
+
const start = performance.now();
|
|
350
|
+
try {
|
|
351
|
+
const scopes = `api://fb6513e4-16fe-4931-bed8-33b82b404a14/_.stsfhir5:SocketConnection`.split(" ").sort().join(" ");
|
|
352
|
+
const authendpointUrl = `${this.#options.authOptions.asendpoint}:${this.#options.authOptions.asport}`;
|
|
353
|
+
const retVal = await this.GetAPITokenFromAuthServerUsingScope({
|
|
354
|
+
clientId: "d8277fce-bb48-44c2-bbf1-257fe13a444b",
|
|
355
|
+
authClientSecret: "64e3ef37-c7b8-4cb1-880a-e6ad3ab36e3c",
|
|
356
|
+
scope: scopes,
|
|
357
|
+
endPoint: authendpointUrl
|
|
358
|
+
});
|
|
359
|
+
clearTimeout(timeout);
|
|
360
|
+
const totalTime = performance.now() - start;
|
|
361
|
+
if (totalTime > this._authMaxTimeout) this.Warning(chalk.default.magenta(`TestCaseFhirBase:GetAccessTokenForSocketClientAccess(): The total time for getting the access token: [${totalTime}]`));
|
|
362
|
+
return retVal;
|
|
363
|
+
} catch (error) {
|
|
364
|
+
clearTimeout(timeout);
|
|
365
|
+
error.message = `TestCaseFhirBase:GetAccessTokenForSocketClientAccess(): Error: [${error}], Duration until error: [${performance.now() - start}]`;
|
|
366
|
+
this.Error(error);
|
|
367
|
+
return "";
|
|
368
|
+
}
|
|
368
369
|
};
|
|
369
370
|
GetAccessToken = async () => {
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
371
|
+
let timeout = void 0;
|
|
372
|
+
let start = performance.now();
|
|
373
|
+
try {
|
|
374
|
+
if (start - this.accessTokenTime > this.newTokenLimitTime * 1e3) this.#accesssToken = null;
|
|
375
|
+
if (this.#accesssToken) return this.#accesssToken;
|
|
376
|
+
timeout = setTimeout(() => {
|
|
377
|
+
this.Warning(chalk.default.magenta(`TestCaseFhirBase:GetAccessToken(): Timeout: [${this._authMaxTimeout}] exceeded for getting access token ...`));
|
|
378
|
+
}, this._authMaxTimeout);
|
|
379
|
+
const scopes = `api://fb6513e4-16fe-4931-bed8-33b82b404a14/_.stsfhir5:All`.split(" ").sort().join(" ");
|
|
380
|
+
const authendpointUrl = `${this.#options.authOptions.asendpoint}:${this.#options.authOptions.asport}`;
|
|
381
|
+
const retVal = await this.GetAPITokenFromAuthServerUsingScope({
|
|
382
|
+
clientId: "d8277fce-bb48-44c2-bbf1-257fe13a444b",
|
|
383
|
+
authClientSecret: "64e3ef37-c7b8-4cb1-880a-e6ad3ab36e3c",
|
|
384
|
+
scope: scopes,
|
|
385
|
+
endPoint: authendpointUrl
|
|
386
|
+
});
|
|
387
|
+
this.accessTokenTime = performance.now();
|
|
388
|
+
this.#accesssToken = retVal;
|
|
389
|
+
if (timeout) clearTimeout(timeout);
|
|
390
|
+
const totalTime = performance.now() - start;
|
|
391
|
+
if (totalTime > this._authMaxTimeout) this.Warning(chalk.default.magenta(`TestCaseFhirBase:GetAccessToken(): The total time for getting the access token: [${totalTime}]`));
|
|
392
|
+
return retVal;
|
|
393
|
+
} catch (error) {
|
|
394
|
+
if (timeout) clearTimeout(timeout);
|
|
395
|
+
error.message = `TestCaseFhirBase:GetAccessToken(): Error: [${error}], Duration until error: [${performance.now() - start}]`;
|
|
396
|
+
this.Error(error);
|
|
397
|
+
return "";
|
|
398
|
+
}
|
|
383
399
|
};
|
|
384
400
|
GetPersonRecord = async (prefix, index, version) => {
|
|
385
401
|
const { workerIndex, runnerIndex, runId } = this.#options;
|
|
@@ -511,6 +527,7 @@ var TestCaseFhirBase = class {
|
|
|
511
527
|
//#endregion
|
|
512
528
|
//#region src/libmodule/testCaseFhirQueryBase.ts
|
|
513
529
|
var TestCaseFhirQueryBase = class extends TestCaseFhirBase {
|
|
530
|
+
_longExecTimeoutVal = 5e3;
|
|
514
531
|
constructor(workerInstance, runner) {
|
|
515
532
|
super(workerInstance, runner);
|
|
516
533
|
}
|
|
@@ -531,17 +548,26 @@ var TestCaseFhirQueryBase = class extends TestCaseFhirBase {
|
|
|
531
548
|
if (this.runner.instrumentData.requestCount % this.runner.options.clientResetMod === 0) this.#ResetClient("#ResetClient triggered");
|
|
532
549
|
}
|
|
533
550
|
};
|
|
551
|
+
_GetDetail = () => {
|
|
552
|
+
return `testType: [${this.runner.options.testType}], description: [${this.runner.options.description}], workerManagerId: [${this.runner.workerManagerId}], Iteration: [${this.runner.iteration}]`;
|
|
553
|
+
};
|
|
534
554
|
ExecuteRunner = async () => {
|
|
535
|
-
if (this.runner.iteration % 100 === 0) this.Debug(`TestCaseFhirQueryBase:ExecuteRunner(): ${this.
|
|
555
|
+
if (this.runner.iteration % 100 === 0) this.Debug(`TestCaseFhirQueryBase:ExecuteRunner(): ${this._GetDetail()}`);
|
|
536
556
|
const start = performance.now();
|
|
537
557
|
this.runner.instrumentData.activeRequestCount++;
|
|
538
558
|
this.#CheckResetClient();
|
|
559
|
+
const longExecTimeout = setTimeout(() => {
|
|
560
|
+
this.Debug(chalk.default.magenta(`TestCaseFhirQueryBase:ExecuteRunner(): *** ==> Long execution: [${this._longExecTimeoutVal}] exceeded - still waiting ...`));
|
|
561
|
+
this.Debug(chalk.default.magenta(`TestCaseFhirQueryBase:ExecuteRunner(): ==> ${this._GetDetail()}`));
|
|
562
|
+
}, this._longExecTimeoutVal);
|
|
539
563
|
try {
|
|
540
564
|
await this.ExecuteQuery();
|
|
565
|
+
clearInterval(longExecTimeout);
|
|
541
566
|
} catch (error) {
|
|
567
|
+
clearInterval(longExecTimeout);
|
|
542
568
|
this.runner.instrumentData.errorCount++;
|
|
543
|
-
const message = `TestCaseFhirQueryBase:ExecuteRunner():
|
|
544
|
-
this.
|
|
569
|
+
const message = `TestCaseFhirQueryBase:ExecuteRunner(): Error: [${error}], Error Count: [${this.runner.instrumentData.errorCount}], ${this._GetDetail()}`;
|
|
570
|
+
this.Error(message);
|
|
545
571
|
this.#ResetClient(message);
|
|
546
572
|
}
|
|
547
573
|
this.runner.instrumentData.coreCount = 1;
|
|
@@ -550,8 +576,21 @@ var TestCaseFhirQueryBase = class extends TestCaseFhirBase {
|
|
|
550
576
|
this.runner.instrumentData.activeRequestCount--;
|
|
551
577
|
const diff = performance.now() - start;
|
|
552
578
|
this.runner.instrumentData.duration = diff;
|
|
553
|
-
if (diff >
|
|
579
|
+
if (diff > this._longExecTimeoutVal) {
|
|
580
|
+
this.Error(chalk.default.red(`TestCaseFhirQueryBase:ExecuteRunner(): *** ==> Long execution: [${diff}] Completed`));
|
|
581
|
+
this.Error(chalk.default.red(`TestCaseFhirQueryBase:ExecuteRunner(): ==> ${this._GetDetail()}`));
|
|
582
|
+
this.Error(chalk.default.red(`TestCaseFhirQueryBase:ExecuteRunner(): ==> Note: While not specifically an error, this is logged as an error.`));
|
|
583
|
+
} else if (diff > 200) {
|
|
584
|
+
this.Debug(chalk.default.rgb(155, 120, 200)(`TestCaseFhirQueryBase:ExecuteRunner(): *** ==> Long execution: [${diff}] Completed`));
|
|
585
|
+
this.Debug(chalk.default.rgb(155, 120, 200)(`TestCaseFhirQueryBase:ExecuteRunner(): ==> ${this._GetDetail()}`));
|
|
586
|
+
}
|
|
587
|
+
const longExecTimeoutpublishTelemetry = setTimeout(() => {
|
|
588
|
+
this.Error(chalk.default.red(`TestCaseFhirQueryBase:ExecuteRunner(): *** ==> Long execution: [${this._longExecTimeoutVal}] for PublishTelemetry()`));
|
|
589
|
+
this.Error(chalk.default.red(`TestCaseFhirQueryBase:ExecuteRunner(): ==> ${this._GetDetail()}`));
|
|
590
|
+
this.Error(chalk.default.red(`TestCaseFhirQueryBase:ExecuteRunner(): ==> Note: While not specifically an error, this is logged as an error.`));
|
|
591
|
+
}, this._longExecTimeoutVal);
|
|
554
592
|
await this.PublishTelemetry();
|
|
593
|
+
clearInterval(longExecTimeoutpublishTelemetry);
|
|
555
594
|
return true;
|
|
556
595
|
};
|
|
557
596
|
};
|