@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.
@@ -29,6 +29,8 @@ var TestCaseFhirBase = class {
29
29
  #publishTelemetryTimeout = null;
30
30
  #publishTelemetryTimeoutVal = 1e3;
31
31
  #originRegex = /^(api:\/\/\w+)/;
32
+ #resetSocketClientTrigger = 100;
33
+ #clientSocketFetchCount = 0;
32
34
  #authAgentManager;
33
35
  accessTokenTime = performance.now();
34
36
  newTokenLimitTime = 30;
@@ -130,7 +132,15 @@ var TestCaseFhirBase = class {
130
132
  };
131
133
  GetFhirSocketClient = async () => {
132
134
  try {
133
- if (this.fhirClient) return this.fhirClient;
135
+ this.#clientSocketFetchCount++;
136
+ if (this.fhirClient) {
137
+ if (this.#clientSocketFetchCount % this.#resetSocketClientTrigger === 0) {
138
+ this.fhirClient.ResetSocket();
139
+ await Sleep(250);
140
+ this.fhirClient = null;
141
+ return this.GetFhirSocketClient();
142
+ }
143
+ }
134
144
  const fhirOptions = this.#options.fhirOptions;
135
145
  const options = {
136
146
  fhirServerEndpoint: fhirOptions.stsfhirserverendpoint,
@@ -143,7 +153,7 @@ var TestCaseFhirBase = class {
143
153
  agentManager: this.GetFhirAgentManager(),
144
154
  joinRooms: [],
145
155
  logger: this.#runnerExecutionWorker.logger,
146
- authToken: await this.GetAccessTokenForSocketClientAccess(),
156
+ GetConnectionAccessToken: this.GetAccessTokenForSocketClientAccess,
147
157
  GetAccessToken: this.GetAccessToken
148
158
  };
149
159
  if (this.runner.options.fhirOptions.stsfhirsocketclientmode === "socket-client-all-in-one") this.fhirClient = new FhirSocketClientAllInOne("FhirSocketClient", options);
@@ -483,7 +493,7 @@ var TestCaseFhirQueryBase = class extends TestCaseFhirBase {
483
493
  }
484
494
  };
485
495
  ExecuteRunner = async () => {
486
- if (this.runner.iteration % 100 === 0) this.Debug(`${this.runner.options.testType}:${this.runner.workerManagerId} -->> Iteration: ${this.runner.options.description} ${this.runner.iteration}`);
496
+ 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}`);
487
497
  const start = performance.now();
488
498
  this.runner.instrumentData.activeRequestCount++;
489
499
  this.#CheckResetClient();
@@ -501,7 +511,7 @@ var TestCaseFhirQueryBase = class extends TestCaseFhirBase {
501
511
  this.runner.instrumentData.activeRequestCount--;
502
512
  const diff = performance.now() - start;
503
513
  this.runner.instrumentData.duration = diff;
504
- if (diff > 150) console.debug(chalk.magenta(`*** ==> Long execution: [${diff}]`));
514
+ if (diff > 150) this.Debug(chalk.magenta(`TestCaseFhirQueryBase:ExecuteRunner(): *** ==> Long execution: [${diff}]`));
505
515
  await this.PublishTelemetry();
506
516
  return true;
507
517
  };
@@ -510,9 +520,15 @@ var TestCaseFhirQueryBase = class extends TestCaseFhirBase {
510
520
  //#region src/libmodule/testCaseFhir01.ts
511
521
  var TestCaseFhir01 = class extends TestCaseFhirQueryBase {
512
522
  ExecuteQuery = async () => {
513
- await this.GetAccessToken();
514
- this.accesssToken = null;
515
- return null;
523
+ try {
524
+ await this.GetAccessToken();
525
+ this.accesssToken = null;
526
+ return null;
527
+ } catch (error) {
528
+ this.runner.instrumentData.errorCount++;
529
+ this.Error(`TestCaseFhir01:ExecuteQuery(): Error: [${error}]`);
530
+ throw error;
531
+ }
516
532
  };
517
533
  };
518
534
  //#endregion
@@ -525,8 +541,9 @@ var TestCaseFhir02 = class extends TestCaseFhirQueryBase {
525
541
  const personRecord = await this.GetPersonRecord(prefix, this.runner.iteration, "1");
526
542
  return (await client.PostResource("Person", personRecord)).body;
527
543
  } catch (error) {
528
- console.error(error);
529
- return null;
544
+ this.runner.instrumentData.errorCount++;
545
+ this.Error(`TestCaseFhir02:ExecuteQuery(): Error: [${error}]`);
546
+ throw error;
530
547
  }
531
548
  };
532
549
  };
@@ -534,49 +551,61 @@ var TestCaseFhir02 = class extends TestCaseFhirQueryBase {
534
551
  //#region src/libmodule/testCaseFhir03.ts
535
552
  var TestCaseFhir03 = class extends TestCaseFhirQueryBase {
536
553
  ExecuteQuery = async () => {
537
- const client = await this.GetClient();
538
- const personRecord = await this.GetPersonRecord(`${this.runner.options.personPrefix}`, this.runner.iteration, "1");
539
- const retVal = await client.GetResource("Person", personRecord.id);
540
- delete personRecord.meta;
541
- delete retVal.body.meta;
542
- const p1 = JSON.stringify(personRecord);
543
- const p2 = JSON.stringify(retVal.body);
544
- if (p1.localeCompare(p2) !== 0) this.runner.instrumentData.errorCount++;
545
- return retVal.body;
554
+ try {
555
+ const client = await this.GetClient();
556
+ const personRecord = await this.GetPersonRecord(`${this.runner.options.personPrefix}`, this.runner.iteration, "1");
557
+ const retVal = await client.GetResource("Person", personRecord.id);
558
+ delete personRecord.meta;
559
+ delete retVal.body.meta;
560
+ const p1 = JSON.stringify(personRecord);
561
+ const p2 = JSON.stringify(retVal.body);
562
+ if (p1.localeCompare(p2) !== 0) this.runner.instrumentData.errorCount++;
563
+ return retVal.body;
564
+ } catch (error) {
565
+ this.runner.instrumentData.errorCount++;
566
+ this.Error(`TestCaseFhir03:ExecuteQuery(): Error: [${error}]`);
567
+ throw error;
568
+ }
546
569
  };
547
570
  };
548
571
  //#endregion
549
572
  //#region src/libmodule/testCaseFhir04.ts
550
573
  var TestCaseFhir04 = class extends TestCaseFhirQueryBase {
551
574
  ExecuteQuery = async () => {
552
- const client = await this.GetClient();
553
- const personRecord = await this.GetPersonRecord(`${this.runner.options.personPrefix}`, this.runner.iteration, "1");
554
- const retVal = await client.GetResource("Person", personRecord.id);
555
- this.runner.instrumentData.requestCount++;
556
- const compPersonRecord = { ...personRecord };
557
- const loadedPersonRecorded = { ...retVal.body };
558
- delete compPersonRecord.meta;
559
- delete loadedPersonRecorded.meta;
560
- const p1 = JSON.stringify(compPersonRecord);
561
- const p2 = JSON.stringify(loadedPersonRecorded);
562
- if (p1.localeCompare(p2) !== 0) {
563
- this.runner.instrumentData.errorCount++;
564
- return retVal.body;
565
- }
566
- const originalPersonRecord = retVal.body;
567
- if (originalPersonRecord && originalPersonRecord.text) {
568
- originalPersonRecord.text.div = `Put record TestCaseFhir04 ${this.runner.iteration}`;
569
- const retVal = await client.PutResource("Person", originalPersonRecord, `W/"1"`);
570
- const updatedRecord = { ...retVal.body };
571
- delete updatedRecord.meta;
572
- delete originalPersonRecord.meta;
573
- const p1 = JSON.stringify(updatedRecord);
574
- const p2 = JSON.stringify(originalPersonRecord);
575
- if (p1.localeCompare(p2) !== 0) this.runner.instrumentData.errorCount++;
576
- return retVal.body;
577
- } else {
575
+ try {
576
+ const client = await this.GetClient();
577
+ const personRecord = await this.GetPersonRecord(`${this.runner.options.personPrefix}`, this.runner.iteration, "1");
578
+ const retVal = await client.GetResource("Person", personRecord.id);
579
+ this.runner.instrumentData.requestCount++;
580
+ const compPersonRecord = { ...personRecord };
581
+ const loadedPersonRecorded = { ...retVal.body };
582
+ delete compPersonRecord.meta;
583
+ delete loadedPersonRecorded.meta;
584
+ const p1 = JSON.stringify(compPersonRecord);
585
+ const p2 = JSON.stringify(loadedPersonRecorded);
586
+ if (p1.localeCompare(p2) !== 0) {
587
+ this.runner.instrumentData.errorCount++;
588
+ return retVal.body;
589
+ }
590
+ const originalPersonRecord = retVal.body;
591
+ if (originalPersonRecord && originalPersonRecord.text) {
592
+ originalPersonRecord.text.div = `Put record TestCaseFhir04 ${this.runner.iteration}`;
593
+ const retVal = await client.PutResource("Person", originalPersonRecord, `W/"1"`);
594
+ const updatedRecord = { ...retVal.body };
595
+ delete updatedRecord.meta;
596
+ delete originalPersonRecord.meta;
597
+ const p1 = JSON.stringify(updatedRecord);
598
+ const p2 = JSON.stringify(originalPersonRecord);
599
+ if (p1.localeCompare(p2) !== 0) this.runner.instrumentData.errorCount++;
600
+ return retVal.body;
601
+ } else {
602
+ this.runner.instrumentData.errorCount++;
603
+ return null;
604
+ }
605
+ } catch (error) {
578
606
  this.runner.instrumentData.errorCount++;
579
- return null;
607
+ this.Error(`TestCaseFhir04:ExecuteQuery(): Error: [${error}]`);
608
+ throw error;
580
609
  }
581
610
  };
582
611
  };
@@ -584,21 +613,27 @@ var TestCaseFhir04 = class extends TestCaseFhirQueryBase {
584
613
  //#region src/libmodule/testCaseFhir05.ts
585
614
  var TestCaseFhir05 = class extends TestCaseFhirQueryBase {
586
615
  ExecuteQuery = async () => {
587
- const client = await this.GetClient();
588
- const originalPersonRecord = await this.GetPersonRecord(`${this.runner.options.personPrefix}`, this.runner.iteration, "2");
589
- if (originalPersonRecord && originalPersonRecord.text) {
590
- originalPersonRecord.text.div = `Put record TestCaseFhir05 ${this.runner.iteration}`;
591
- const retVal = await client.PutResource("Person", originalPersonRecord, `W/"2"`);
592
- const updatedRecord = { ...retVal.body };
593
- delete updatedRecord.meta;
594
- delete originalPersonRecord.meta;
595
- const p1 = JSON.stringify(updatedRecord);
596
- const p2 = JSON.stringify(originalPersonRecord);
597
- if (p1.localeCompare(p2) !== 0) this.runner.instrumentData.errorCount++;
598
- return retVal.body;
599
- } else {
616
+ try {
617
+ const client = await this.GetClient();
618
+ const originalPersonRecord = await this.GetPersonRecord(`${this.runner.options.personPrefix}`, this.runner.iteration, "2");
619
+ if (originalPersonRecord && originalPersonRecord.text) {
620
+ originalPersonRecord.text.div = `Put record TestCaseFhir05 ${this.runner.iteration}`;
621
+ const retVal = await client.PutResource("Person", originalPersonRecord, `W/"2"`);
622
+ const updatedRecord = { ...retVal.body };
623
+ delete updatedRecord.meta;
624
+ delete originalPersonRecord.meta;
625
+ const p1 = JSON.stringify(updatedRecord);
626
+ const p2 = JSON.stringify(originalPersonRecord);
627
+ if (p1.localeCompare(p2) !== 0) this.runner.instrumentData.errorCount++;
628
+ return retVal.body;
629
+ } else {
630
+ this.runner.instrumentData.errorCount++;
631
+ return null;
632
+ }
633
+ } catch (error) {
600
634
  this.runner.instrumentData.errorCount++;
601
- return null;
635
+ this.Error(`TestCaseFhir05:ExecuteQuery(): Error: [${error}]`);
636
+ throw error;
602
637
  }
603
638
  };
604
639
  };
@@ -625,7 +660,8 @@ var TestCaseFhir06 = class extends TestCaseFhirQueryBase {
625
660
  return retVal.body;
626
661
  } catch (error) {
627
662
  this.runner.instrumentData.errorCount++;
628
- return null;
663
+ this.Error(`TestCaseFhir06:ExecuteQuery(): Error: [${error}]`);
664
+ throw error;
629
665
  }
630
666
  };
631
667
  };
@@ -1289,7 +1325,8 @@ var TestCaseFhir07 = class extends TestCaseFhirQueryBase {
1289
1325
  const patchRecord = fast_json_patch_default.generate(observer);
1290
1326
  return (await client.PatchResource("Person", personRecord.id, patchRecord, `application/json-patch+json`, `W/"3"`)).body;
1291
1327
  } catch (error) {
1292
- console.error(error);
1328
+ this.runner.instrumentData.errorCount++;
1329
+ this.Error(`TestCaseFhir07:ExecuteQuery(): Error: [${error}]`);
1293
1330
  throw error;
1294
1331
  }
1295
1332
  };
@@ -1305,7 +1342,8 @@ var TestCaseFhir08 = class extends TestCaseFhirQueryBase {
1305
1342
  resource.text.div = `Merge Patched record TestCaseFhir08 ${this.runner.iteration}`;
1306
1343
  return (await client.PatchResource("Person", personRecord.id, resource, `application/merge-patch+json`, `W/"4"`)).body;
1307
1344
  } catch (error) {
1308
- console.error(error);
1345
+ this.runner.instrumentData.errorCount++;
1346
+ this.Error(`TestCaseFhir08:ExecuteQuery(): Error: [${error}]`);
1309
1347
  throw error;
1310
1348
  }
1311
1349
  };
@@ -1314,12 +1352,18 @@ var TestCaseFhir08 = class extends TestCaseFhirQueryBase {
1314
1352
  //#region src/libmodule/testCaseFhir09.ts
1315
1353
  var TestCaseFhir09 = class extends TestCaseFhirQueryBase {
1316
1354
  ExecuteQuery = async () => {
1317
- const client = await this.GetClient();
1318
- const personRecord = await this.GetPersonRecord(`${this.runner.options.personPrefix}`, this.runner.iteration, "5");
1319
- if (personRecord.text) return (await client.DeleteResource("Person", personRecord.id, `W/"5"`)).body;
1320
- else {
1355
+ try {
1356
+ const client = await this.GetClient();
1357
+ const personRecord = await this.GetPersonRecord(`${this.runner.options.personPrefix}`, this.runner.iteration, "5");
1358
+ if (personRecord.text) return (await client.DeleteResource("Person", personRecord.id, `W/"5"`)).body;
1359
+ else {
1360
+ this.runner.instrumentData.errorCount++;
1361
+ return null;
1362
+ }
1363
+ } catch (error) {
1321
1364
  this.runner.instrumentData.errorCount++;
1322
- return null;
1365
+ this.Error(`TestCaseFhir09:ExecuteQuery(): Error: [${error}]`);
1366
+ throw error;
1323
1367
  }
1324
1368
  };
1325
1369
  };
@@ -1327,9 +1371,15 @@ var TestCaseFhir09 = class extends TestCaseFhirQueryBase {
1327
1371
  //#region src/libmodule/testCaseFhir10.ts
1328
1372
  var TestCaseFhir10 = class extends TestCaseFhirQueryBase {
1329
1373
  ExecuteQuery = async () => {
1330
- const client = await this.GetClient();
1331
- const personRecord = await this.GetPersonRecord(`${this.runner.options.personPrefix}`, this.runner.iteration, "1");
1332
- return (await client.GetHistoryInstanceFhirResource("Person", personRecord.id, "2")).body;
1374
+ try {
1375
+ const client = await this.GetClient();
1376
+ const personRecord = await this.GetPersonRecord(`${this.runner.options.personPrefix}`, this.runner.iteration, "1");
1377
+ return (await client.GetHistoryInstanceFhirResource("Person", personRecord.id, "2")).body;
1378
+ } catch (error) {
1379
+ this.runner.instrumentData.errorCount++;
1380
+ this.Error(`TestCaseFhir10:ExecuteQuery(): Error: [${error}]`);
1381
+ throw error;
1382
+ }
1333
1383
  };
1334
1384
  };
1335
1385
  //#endregion