@nsshunt/ststestrunner 1.1.45 → 1.1.47

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.
@@ -52,6 +52,8 @@ var TestCaseFhirBase = class {
52
52
  #publishTelemetryTimeout = null;
53
53
  #publishTelemetryTimeoutVal = 1e3;
54
54
  #originRegex = /^(api:\/\/\w+)/;
55
+ #resetSocketClientTrigger = 100;
56
+ #clientSocketFetchCount = 0;
55
57
  #authAgentManager;
56
58
  accessTokenTime = performance.now();
57
59
  newTokenLimitTime = 30;
@@ -153,7 +155,15 @@ var TestCaseFhirBase = class {
153
155
  };
154
156
  GetFhirSocketClient = async () => {
155
157
  try {
156
- if (this.fhirClient) return this.fhirClient;
158
+ this.#clientSocketFetchCount++;
159
+ if (this.fhirClient) {
160
+ if (this.#clientSocketFetchCount % this.#resetSocketClientTrigger === 0) {
161
+ this.fhirClient.ResetSocket();
162
+ await (0, _nsshunt_stsutils.Sleep)(250);
163
+ this.fhirClient = null;
164
+ return this.GetFhirSocketClient();
165
+ }
166
+ }
157
167
  const fhirOptions = this.#options.fhirOptions;
158
168
  const options = {
159
169
  fhirServerEndpoint: fhirOptions.stsfhirserverendpoint,
@@ -166,7 +176,7 @@ var TestCaseFhirBase = class {
166
176
  agentManager: this.GetFhirAgentManager(),
167
177
  joinRooms: [],
168
178
  logger: this.#runnerExecutionWorker.logger,
169
- authToken: await this.GetAccessTokenForSocketClientAccess(),
179
+ GetConnectionAccessToken: this.GetAccessTokenForSocketClientAccess,
170
180
  GetAccessToken: this.GetAccessToken
171
181
  };
172
182
  if (this.runner.options.fhirOptions.stsfhirsocketclientmode === "socket-client-all-in-one") this.fhirClient = new _nsshunt_stsfhirclient.FhirSocketClientAllInOne("FhirSocketClient", options);
@@ -506,7 +516,7 @@ var TestCaseFhirQueryBase = class extends TestCaseFhirBase {
506
516
  }
507
517
  };
508
518
  ExecuteRunner = async () => {
509
- if (this.runner.iteration % 100 === 0) this.Debug(`${this.runner.options.testType}:${this.runner.workerManagerId} -->> Iteration: ${this.runner.options.description} ${this.runner.iteration}`);
519
+ if (this.runner.iteration % 100 === 0) this.Debug(`TestCaseFhirQueryBase:ExecuteRunner(): ${this.runner.options.testType}:${this.runner.workerManagerId} -->> Iteration: ${this.runner.options.description} ${this.runner.iteration}`);
510
520
  const start = performance.now();
511
521
  this.runner.instrumentData.activeRequestCount++;
512
522
  this.#CheckResetClient();
@@ -524,7 +534,7 @@ var TestCaseFhirQueryBase = class extends TestCaseFhirBase {
524
534
  this.runner.instrumentData.activeRequestCount--;
525
535
  const diff = performance.now() - start;
526
536
  this.runner.instrumentData.duration = diff;
527
- if (diff > 150) console.debug(chalk.default.magenta(`*** ==> Long execution: [${diff}]`));
537
+ if (diff > 150) this.Debug(chalk.default.magenta(`TestCaseFhirQueryBase:ExecuteRunner(): *** ==> Long execution: [${diff}]`));
528
538
  await this.PublishTelemetry();
529
539
  return true;
530
540
  };
@@ -533,9 +543,15 @@ var TestCaseFhirQueryBase = class extends TestCaseFhirBase {
533
543
  //#region src/libmodule/testCaseFhir01.ts
534
544
  var TestCaseFhir01 = class extends TestCaseFhirQueryBase {
535
545
  ExecuteQuery = async () => {
536
- await this.GetAccessToken();
537
- this.accesssToken = null;
538
- return null;
546
+ try {
547
+ await this.GetAccessToken();
548
+ this.accesssToken = null;
549
+ return null;
550
+ } catch (error) {
551
+ this.runner.instrumentData.errorCount++;
552
+ this.Error(`TestCaseFhir01:ExecuteQuery(): Error: [${error}]`);
553
+ throw error;
554
+ }
539
555
  };
540
556
  };
541
557
  //#endregion
@@ -548,8 +564,9 @@ var TestCaseFhir02 = class extends TestCaseFhirQueryBase {
548
564
  const personRecord = await this.GetPersonRecord(prefix, this.runner.iteration, "1");
549
565
  return (await client.PostResource("Person", personRecord)).body;
550
566
  } catch (error) {
551
- console.error(error);
552
- return null;
567
+ this.runner.instrumentData.errorCount++;
568
+ this.Error(`TestCaseFhir02:ExecuteQuery(): Error: [${error}]`);
569
+ throw error;
553
570
  }
554
571
  };
555
572
  };
@@ -557,49 +574,61 @@ var TestCaseFhir02 = class extends TestCaseFhirQueryBase {
557
574
  //#region src/libmodule/testCaseFhir03.ts
558
575
  var TestCaseFhir03 = class extends TestCaseFhirQueryBase {
559
576
  ExecuteQuery = async () => {
560
- const client = await this.GetClient();
561
- const personRecord = await this.GetPersonRecord(`${this.runner.options.personPrefix}`, this.runner.iteration, "1");
562
- const retVal = await client.GetResource("Person", personRecord.id);
563
- delete personRecord.meta;
564
- delete retVal.body.meta;
565
- const p1 = JSON.stringify(personRecord);
566
- const p2 = JSON.stringify(retVal.body);
567
- if (p1.localeCompare(p2) !== 0) this.runner.instrumentData.errorCount++;
568
- return retVal.body;
577
+ try {
578
+ const client = await this.GetClient();
579
+ const personRecord = await this.GetPersonRecord(`${this.runner.options.personPrefix}`, this.runner.iteration, "1");
580
+ const retVal = await client.GetResource("Person", personRecord.id);
581
+ delete personRecord.meta;
582
+ delete retVal.body.meta;
583
+ const p1 = JSON.stringify(personRecord);
584
+ const p2 = JSON.stringify(retVal.body);
585
+ if (p1.localeCompare(p2) !== 0) this.runner.instrumentData.errorCount++;
586
+ return retVal.body;
587
+ } catch (error) {
588
+ this.runner.instrumentData.errorCount++;
589
+ this.Error(`TestCaseFhir03:ExecuteQuery(): Error: [${error}]`);
590
+ throw error;
591
+ }
569
592
  };
570
593
  };
571
594
  //#endregion
572
595
  //#region src/libmodule/testCaseFhir04.ts
573
596
  var TestCaseFhir04 = class extends TestCaseFhirQueryBase {
574
597
  ExecuteQuery = async () => {
575
- const client = await this.GetClient();
576
- const personRecord = await this.GetPersonRecord(`${this.runner.options.personPrefix}`, this.runner.iteration, "1");
577
- const retVal = await client.GetResource("Person", personRecord.id);
578
- this.runner.instrumentData.requestCount++;
579
- const compPersonRecord = { ...personRecord };
580
- const loadedPersonRecorded = { ...retVal.body };
581
- delete compPersonRecord.meta;
582
- delete loadedPersonRecorded.meta;
583
- const p1 = JSON.stringify(compPersonRecord);
584
- const p2 = JSON.stringify(loadedPersonRecorded);
585
- if (p1.localeCompare(p2) !== 0) {
586
- this.runner.instrumentData.errorCount++;
587
- return retVal.body;
588
- }
589
- const originalPersonRecord = retVal.body;
590
- if (originalPersonRecord && originalPersonRecord.text) {
591
- originalPersonRecord.text.div = `Put record TestCaseFhir04 ${this.runner.iteration}`;
592
- const retVal = await client.PutResource("Person", originalPersonRecord, `W/"1"`);
593
- const updatedRecord = { ...retVal.body };
594
- delete updatedRecord.meta;
595
- delete originalPersonRecord.meta;
596
- const p1 = JSON.stringify(updatedRecord);
597
- const p2 = JSON.stringify(originalPersonRecord);
598
- if (p1.localeCompare(p2) !== 0) this.runner.instrumentData.errorCount++;
599
- return retVal.body;
600
- } else {
598
+ try {
599
+ const client = await this.GetClient();
600
+ const personRecord = await this.GetPersonRecord(`${this.runner.options.personPrefix}`, this.runner.iteration, "1");
601
+ const retVal = await client.GetResource("Person", personRecord.id);
602
+ this.runner.instrumentData.requestCount++;
603
+ const compPersonRecord = { ...personRecord };
604
+ const loadedPersonRecorded = { ...retVal.body };
605
+ delete compPersonRecord.meta;
606
+ delete loadedPersonRecorded.meta;
607
+ const p1 = JSON.stringify(compPersonRecord);
608
+ const p2 = JSON.stringify(loadedPersonRecorded);
609
+ if (p1.localeCompare(p2) !== 0) {
610
+ this.runner.instrumentData.errorCount++;
611
+ return retVal.body;
612
+ }
613
+ const originalPersonRecord = retVal.body;
614
+ if (originalPersonRecord && originalPersonRecord.text) {
615
+ originalPersonRecord.text.div = `Put record TestCaseFhir04 ${this.runner.iteration}`;
616
+ const retVal = await client.PutResource("Person", originalPersonRecord, `W/"1"`);
617
+ const updatedRecord = { ...retVal.body };
618
+ delete updatedRecord.meta;
619
+ delete originalPersonRecord.meta;
620
+ const p1 = JSON.stringify(updatedRecord);
621
+ const p2 = JSON.stringify(originalPersonRecord);
622
+ if (p1.localeCompare(p2) !== 0) this.runner.instrumentData.errorCount++;
623
+ return retVal.body;
624
+ } else {
625
+ this.runner.instrumentData.errorCount++;
626
+ return null;
627
+ }
628
+ } catch (error) {
601
629
  this.runner.instrumentData.errorCount++;
602
- return null;
630
+ this.Error(`TestCaseFhir04:ExecuteQuery(): Error: [${error}]`);
631
+ throw error;
603
632
  }
604
633
  };
605
634
  };
@@ -607,21 +636,27 @@ var TestCaseFhir04 = class extends TestCaseFhirQueryBase {
607
636
  //#region src/libmodule/testCaseFhir05.ts
608
637
  var TestCaseFhir05 = class extends TestCaseFhirQueryBase {
609
638
  ExecuteQuery = async () => {
610
- const client = await this.GetClient();
611
- const originalPersonRecord = await this.GetPersonRecord(`${this.runner.options.personPrefix}`, this.runner.iteration, "2");
612
- if (originalPersonRecord && originalPersonRecord.text) {
613
- originalPersonRecord.text.div = `Put record TestCaseFhir05 ${this.runner.iteration}`;
614
- const retVal = await client.PutResource("Person", originalPersonRecord, `W/"2"`);
615
- const updatedRecord = { ...retVal.body };
616
- delete updatedRecord.meta;
617
- delete originalPersonRecord.meta;
618
- const p1 = JSON.stringify(updatedRecord);
619
- const p2 = JSON.stringify(originalPersonRecord);
620
- if (p1.localeCompare(p2) !== 0) this.runner.instrumentData.errorCount++;
621
- return retVal.body;
622
- } else {
639
+ try {
640
+ const client = await this.GetClient();
641
+ const originalPersonRecord = await this.GetPersonRecord(`${this.runner.options.personPrefix}`, this.runner.iteration, "2");
642
+ if (originalPersonRecord && originalPersonRecord.text) {
643
+ originalPersonRecord.text.div = `Put record TestCaseFhir05 ${this.runner.iteration}`;
644
+ const retVal = await client.PutResource("Person", originalPersonRecord, `W/"2"`);
645
+ const updatedRecord = { ...retVal.body };
646
+ delete updatedRecord.meta;
647
+ delete originalPersonRecord.meta;
648
+ const p1 = JSON.stringify(updatedRecord);
649
+ const p2 = JSON.stringify(originalPersonRecord);
650
+ if (p1.localeCompare(p2) !== 0) this.runner.instrumentData.errorCount++;
651
+ return retVal.body;
652
+ } else {
653
+ this.runner.instrumentData.errorCount++;
654
+ return null;
655
+ }
656
+ } catch (error) {
623
657
  this.runner.instrumentData.errorCount++;
624
- return null;
658
+ this.Error(`TestCaseFhir05:ExecuteQuery(): Error: [${error}]`);
659
+ throw error;
625
660
  }
626
661
  };
627
662
  };
@@ -648,7 +683,8 @@ var TestCaseFhir06 = class extends TestCaseFhirQueryBase {
648
683
  return retVal.body;
649
684
  } catch (error) {
650
685
  this.runner.instrumentData.errorCount++;
651
- return null;
686
+ this.Error(`TestCaseFhir06:ExecuteQuery(): Error: [${error}]`);
687
+ throw error;
652
688
  }
653
689
  };
654
690
  };
@@ -1312,7 +1348,8 @@ var TestCaseFhir07 = class extends TestCaseFhirQueryBase {
1312
1348
  const patchRecord = fast_json_patch_default.generate(observer);
1313
1349
  return (await client.PatchResource("Person", personRecord.id, patchRecord, `application/json-patch+json`, `W/"3"`)).body;
1314
1350
  } catch (error) {
1315
- console.error(error);
1351
+ this.runner.instrumentData.errorCount++;
1352
+ this.Error(`TestCaseFhir07:ExecuteQuery(): Error: [${error}]`);
1316
1353
  throw error;
1317
1354
  }
1318
1355
  };
@@ -1328,7 +1365,8 @@ var TestCaseFhir08 = class extends TestCaseFhirQueryBase {
1328
1365
  resource.text.div = `Merge Patched record TestCaseFhir08 ${this.runner.iteration}`;
1329
1366
  return (await client.PatchResource("Person", personRecord.id, resource, `application/merge-patch+json`, `W/"4"`)).body;
1330
1367
  } catch (error) {
1331
- console.error(error);
1368
+ this.runner.instrumentData.errorCount++;
1369
+ this.Error(`TestCaseFhir08:ExecuteQuery(): Error: [${error}]`);
1332
1370
  throw error;
1333
1371
  }
1334
1372
  };
@@ -1337,12 +1375,18 @@ var TestCaseFhir08 = class extends TestCaseFhirQueryBase {
1337
1375
  //#region src/libmodule/testCaseFhir09.ts
1338
1376
  var TestCaseFhir09 = class extends TestCaseFhirQueryBase {
1339
1377
  ExecuteQuery = async () => {
1340
- const client = await this.GetClient();
1341
- const personRecord = await this.GetPersonRecord(`${this.runner.options.personPrefix}`, this.runner.iteration, "5");
1342
- if (personRecord.text) return (await client.DeleteResource("Person", personRecord.id, `W/"5"`)).body;
1343
- else {
1378
+ try {
1379
+ const client = await this.GetClient();
1380
+ const personRecord = await this.GetPersonRecord(`${this.runner.options.personPrefix}`, this.runner.iteration, "5");
1381
+ if (personRecord.text) return (await client.DeleteResource("Person", personRecord.id, `W/"5"`)).body;
1382
+ else {
1383
+ this.runner.instrumentData.errorCount++;
1384
+ return null;
1385
+ }
1386
+ } catch (error) {
1344
1387
  this.runner.instrumentData.errorCount++;
1345
- return null;
1388
+ this.Error(`TestCaseFhir09:ExecuteQuery(): Error: [${error}]`);
1389
+ throw error;
1346
1390
  }
1347
1391
  };
1348
1392
  };
@@ -1350,9 +1394,15 @@ var TestCaseFhir09 = class extends TestCaseFhirQueryBase {
1350
1394
  //#region src/libmodule/testCaseFhir10.ts
1351
1395
  var TestCaseFhir10 = class extends TestCaseFhirQueryBase {
1352
1396
  ExecuteQuery = async () => {
1353
- const client = await this.GetClient();
1354
- const personRecord = await this.GetPersonRecord(`${this.runner.options.personPrefix}`, this.runner.iteration, "1");
1355
- return (await client.GetHistoryInstanceFhirResource("Person", personRecord.id, "2")).body;
1397
+ try {
1398
+ const client = await this.GetClient();
1399
+ const personRecord = await this.GetPersonRecord(`${this.runner.options.personPrefix}`, this.runner.iteration, "1");
1400
+ return (await client.GetHistoryInstanceFhirResource("Person", personRecord.id, "2")).body;
1401
+ } catch (error) {
1402
+ this.runner.instrumentData.errorCount++;
1403
+ this.Error(`TestCaseFhir10:ExecuteQuery(): Error: [${error}]`);
1404
+ throw error;
1405
+ }
1356
1406
  };
1357
1407
  };
1358
1408
  //#endregion