@nsshunt/ststestrunner 1.1.103 → 1.1.104

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.
@@ -438,7 +438,7 @@ var TestCaseFhirBase = class {
438
438
  const onRetryAttempt = (attempt, error, delayMs) => {
439
439
  this.#runner.instrumentData.errorCount++;
440
440
  this.#runner.instrumentData.requestCount++;
441
- const message = `TestCaseFhirBase:onRetryAttempt(): Retry #${attempt} after ${delayMs}ms due to ${error.code || error.response?.status}`;
441
+ const message = `TestCaseFhirBase:onRetryAttempt(): [${this._id}] Retry #${attempt} after ${delayMs}ms due to ${error.code || error.response?.status}`;
442
442
  this.Warning(message);
443
443
  this.#runner.instrumentData.message.push(chalk.red(message));
444
444
  };
@@ -474,7 +474,7 @@ var TestCaseFhirBase = class {
474
474
  case "stress-test-extreme-agent-options":
475
475
  agentOptions = { ...this.stressTestExtremeAgentOptions };
476
476
  break;
477
- default: throw new Error(`GetFhirSocketClient(): unknown nodeAgentMode: [${testingAgentOptions.nodeAgentMode}]`);
477
+ default: throw new Error(`TestCaseFhirBase:GetAgentManager(): [${this._id}] unknown nodeAgentMode: [${testingAgentOptions.nodeAgentMode}]`);
478
478
  }
479
479
  if (agentOptions) agentManager = createAgentManager({
480
480
  agentOptions,
@@ -499,17 +499,17 @@ var TestCaseFhirBase = class {
499
499
  let fhirClient = this.runnerExecutionWorker.GetFhirClient();
500
500
  if (fhirClient) return fhirClient;
501
501
  if (this.runnerExecutionWorker.GetOnHold("fhirclient") === true) {
502
- this.Debug(chalk.magenta(`[${this.runnerExecutionWorker.id}] fhir client does not exist - some other client setting up the new client (on hold/lock) - waiting ...`));
502
+ this.Debug(chalk.magenta(`[${this.runnerExecutionWorker.id}] [${this._id}] fhir client does not exist - some other client setting up the new client (on hold/lock) - waiting ...`));
503
503
  try {
504
504
  const start = performance.now();
505
505
  await this.runnerExecutionWorker.WaitOnHold("fhirclient", 6e4);
506
- this.Debug(chalk.yellow(`[${this.runnerExecutionWorker.id}] hold (lock) released after: [${performance.now() - start}ms]`));
506
+ this.Debug(chalk.yellow(`[${this.runnerExecutionWorker.id}] [${this._id}] hold (lock) released after: [${performance.now() - start}ms]`));
507
507
  const fhirClient = this.runnerExecutionWorker.GetFhirClient();
508
508
  if (fhirClient) {
509
- this.Debug(chalk.green(`[${this.runnerExecutionWorker.id}] Getting existing fhir client (post hold release)`));
509
+ this.Debug(chalk.green(`[${this.runnerExecutionWorker.id}] [${this._id}] Getting existing fhir client (post hold release)`));
510
510
  return fhirClient;
511
511
  } else {
512
- this.Error(chalk.red(`[${this.runnerExecutionWorker.id}] Could not get existing fhir client (post hold release)`));
512
+ this.Error(chalk.red(`[${this.runnerExecutionWorker.id}] [${this._id}] Could not get existing fhir client (post hold release)`));
513
513
  this.Error(chalk.red(`continue anyway ...`));
514
514
  }
515
515
  } catch (error) {
@@ -517,8 +517,8 @@ var TestCaseFhirBase = class {
517
517
  }
518
518
  }
519
519
  const start = performance.now();
520
- this.Debug(chalk.yellow(`[${this.runnerExecutionWorker.id}] fhir client does not exist - setting up new client`));
521
- this.Debug(chalk.yellow(`[${this.runnerExecutionWorker.id}] setting hold (lock)`));
520
+ this.Debug(chalk.yellow(`[${this.runnerExecutionWorker.id}] [${this._id}] fhir client does not exist - setting up new client`));
521
+ this.Debug(chalk.yellow(`[${this.runnerExecutionWorker.id}] [${this._id}] setting hold (lock)`));
522
522
  this.runnerExecutionWorker.SetOnHold("fhirclient");
523
523
  const fhirOptions = this.#options.fhirOptions;
524
524
  const options = {
@@ -539,10 +539,10 @@ var TestCaseFhirBase = class {
539
539
  if (this.runner.options.fhirOptions.stsfhirsocketclientmode === "socket-client-all-in-one") fhirClient = new FhirSocketClientAllInOne("FhirSocketClient", options);
540
540
  else fhirClient = new FhirSocketClientIndividual("FhirSocketClient", options);
541
541
  await fhirClient.WaitForSocketConnected();
542
- this.Debug(chalk.yellow(`[${this.runnerExecutionWorker.id}] setting fhir client into object`));
542
+ this.Debug(chalk.yellow(`[${this.runnerExecutionWorker.id}] [${this._id}] setting fhir client into object`));
543
543
  this.runnerExecutionWorker.SetFhirClient(fhirClient);
544
544
  this.runnerExecutionWorker.ReleaseOnHold("fhirclient");
545
- this.Debug(chalk.yellow(`[${this.runnerExecutionWorker.id}] release hold (lock) Time taken for socket connection and set object: [${performance.now() - start}ms]`));
545
+ this.Debug(chalk.yellow(`[${this.runnerExecutionWorker.id}] [${this._id}] release hold (lock) Time taken for socket connection and set object: [${performance.now() - start}ms]`));
546
546
  return fhirClient;
547
547
  } catch (error) {
548
548
  this.Error(error);
@@ -659,7 +659,7 @@ var TestCaseFhirBase = class {
659
659
  onRetryAttempt: (attempt, error, delayMs) => {
660
660
  this.#runner.instrumentData.authenticationErrorCount++;
661
661
  this.#runner.instrumentData.authenticationRetryCount++;
662
- const message = `TestCaseFhirBase:GetAPITokenFromAuthServerUsingScope(): Retry #${attempt} after ${delayMs}ms due to ${error.code || error.response?.status}`;
662
+ const message = `TestCaseFhirBase:GetAPITokenFromAuthServerUsingScope(): [${this._id}] Retry #${attempt} after ${delayMs}ms due to ${error.code || error.response?.status}`;
663
663
  this.Warning(message);
664
664
  this.#runner.instrumentData.message.push(chalk.red(message));
665
665
  }
@@ -667,7 +667,7 @@ var TestCaseFhirBase = class {
667
667
  this.#runner.instrumentData.authenticationCount++;
668
668
  stage = "7";
669
669
  if (retVal.status) {
670
- if (retVal.status !== 200) this.Warning(chalk.magenta(`TestCaseFhirBase:GetAPITokenFromAuthServerUsingScope(): Invalid response from server: [${retVal.status}]`));
670
+ if (retVal.status !== 200) this.Warning(chalk.magenta(`TestCaseFhirBase:GetAPITokenFromAuthServerUsingScope(): [${this._id}] Invalid response from server: [${retVal.status}]`));
671
671
  } else throw new Error(chalk.red(`No retVal.status)`));
672
672
  stage = "8";
673
673
  if (retVal.data) {
@@ -691,13 +691,13 @@ var TestCaseFhirBase = class {
691
691
  } catch (error) {
692
692
  details = `Could not JSON.stringify(error.response.data)`;
693
693
  }
694
- error.message = `TestCaseFhirBase:GetAPITokenFromAuthServerUsingScope(): Error: [${error}], Stage: [${stage}], Details: [${details}]`;
694
+ error.message = `TestCaseFhirBase:GetAPITokenFromAuthServerUsingScope(): [${this._id}] Error: [${error}], Stage: [${stage}], Details: [${details}]`;
695
695
  throw error;
696
696
  }
697
697
  };
698
698
  GetAccessTokenForSocketClientAccess = async () => {
699
699
  const timeout = setTimeout(() => {
700
- this.Warning(`TestCaseFhirBase:GetAccessTokenForSocketClientAccess(): Timeout: [${this._authMaxTimeout}] exceeded for getting access token ...`);
700
+ this.Warning(`TestCaseFhirBase:GetAccessTokenForSocketClientAccess(): [${this._id}] Timeout: [${this._authMaxTimeout}] exceeded for getting access token ...`);
701
701
  }, this._authMaxTimeout);
702
702
  const start = performance.now();
703
703
  try {
@@ -711,43 +711,40 @@ var TestCaseFhirBase = class {
711
711
  });
712
712
  clearTimeout(timeout);
713
713
  const totalTime = performance.now() - start;
714
- if (totalTime > this._authMaxTimeout) this.Warning(chalk.magenta(`TestCaseFhirBase:GetAccessTokenForSocketClientAccess(): The total time for getting the access token: [${totalTime}]`));
714
+ if (totalTime > this._authMaxTimeout) this.Warning(chalk.magenta(`TestCaseFhirBase:GetAccessTokenForSocketClientAccess(): [${this._id}] The total time for getting the access token: [${totalTime}]`));
715
715
  return retVal;
716
716
  } catch (error) {
717
717
  clearTimeout(timeout);
718
- error.message = `TestCaseFhirBase:GetAccessTokenForSocketClientAccess(): Error: [${error}], Duration until error: [${performance.now() - start}]`;
718
+ const totalTime = performance.now() - start;
719
+ error.message = `TestCaseFhirBase:GetAccessTokenForSocketClientAccess(): [${this._id}] Error: [${error}], Duration until error: [${totalTime}]`;
719
720
  this.Error(error);
720
721
  return "";
721
722
  }
722
723
  };
723
724
  ResetAccessToken = () => {
724
- console.log(chalk.magenta(`************************************************************************* start `));
725
- console.log(chalk.magenta(`Old Token: ${this._id} : ${this.#accesssToken}`));
726
725
  this.#accesssToken = null;
727
- console.log(chalk.magenta(`New Token: ${this._id} : ${this.#accesssToken}`));
728
- console.log(chalk.magenta(`************************************************************************* end `));
729
726
  };
730
727
  HandleError = (error) => {
731
- this.Error(chalk.red(`TestCaseFhirBase:HandleError(): Error: [${error}]`));
732
- this.Error(chalk.red(`TestCaseFhirBase:HandleError(): description: [${this.runner.options.description}]`));
733
- this.Error(chalk.red(`TestCaseFhirBase:HandleError(): iteration: [${this.runner.iteration}]`));
734
- this.Error(chalk.red(`TestCaseFhirBase:HandleError(): asyncRunnerContext: [${JSON.stringify(this.runner.asyncRunnerContext)}]`));
728
+ this.Error(chalk.red(`TestCaseFhirBase:HandleError(): [${this._id}] Error: [${error}]`));
729
+ this.Error(chalk.red(`TestCaseFhirBase:HandleError(): [${this._id}] description: [${this.runner.options.description}]`));
730
+ this.Error(chalk.red(`TestCaseFhirBase:HandleError(): [${this._id}] iteration: [${this.runner.iteration}]`));
731
+ this.Error(chalk.red(`TestCaseFhirBase:HandleError(): [${this._id}] asyncRunnerContext: [${JSON.stringify(this.runner.asyncRunnerContext)}]`));
735
732
  if (axios.isAxiosError(error)) {
736
733
  const axiosError = error;
737
734
  if (axiosError.response) {
738
- this.Error(chalk.red(`TestCaseFhirBase:HandleError(): AXIOS Error Response.Status = [${axiosError.response.status}]`));
739
- if (axiosError.response.headers) this.Error(chalk.red(`TestCaseFhirBase:HandleError(): headers: [${JSON.stringify(axiosError.response.headers)}]`));
740
- if (axiosError.response.data) this.Error(chalk.red(`TestCaseFhirBase:HandleError(): data: [${JSON.stringify(axiosError.response.data)}]`));
735
+ this.Error(chalk.red(`TestCaseFhirBase:HandleError(): [${this._id}] AXIOS Error Response.Status = [${axiosError.response.status}]`));
736
+ if (axiosError.response.headers) this.Error(chalk.red(`TestCaseFhirBase:HandleError(): [${this._id}] headers: [${JSON.stringify(axiosError.response.headers)}]`));
737
+ if (axiosError.response.data) this.Error(chalk.red(`TestCaseFhirBase:HandleError(): [${this._id}] data: [${JSON.stringify(axiosError.response.data)}]`));
741
738
  if (axiosError.response.status === StatusCodes.UNAUTHORIZED) {
742
739
  this.runner.instrumentData.authenticationErrorCount++;
743
- this.Error(chalk.red(`TestCaseFhirBase:HandleError(): UNAUTHORIZED - Reset Access Token`));
740
+ this.Error(chalk.red(`TestCaseFhirBase:HandleError(): [${this._id}] UNAUTHORIZED - Reset Access Token`));
744
741
  this.ResetAccessToken();
745
742
  return true;
746
743
  }
747
- } else this.Error(chalk.red(`TestCaseFhirBase:HandleError(): AXIOS Error = [${axiosError}]`));
744
+ } else this.Error(chalk.red(`TestCaseFhirBase:HandleError(): [${this._id}] AXIOS Error = [${axiosError}]`));
748
745
  } else if (error.message === "UNAUTHORIZED") {
749
746
  this.runner.instrumentData.authenticationErrorCount++;
750
- this.Error(chalk.red(`TestCaseFhirBase:HandleError(): UNAUTHORIZED - Reset Access Token`));
747
+ this.Error(chalk.red(`TestCaseFhirBase:HandleError(): [${this._id}] UNAUTHORIZED - Reset Access Token`));
751
748
  this.ResetAccessToken();
752
749
  return true;
753
750
  }
@@ -757,13 +754,9 @@ var TestCaseFhirBase = class {
757
754
  let timeout = void 0;
758
755
  let start = performance.now();
759
756
  try {
760
- if (this.#accesssToken) {
761
- this.Debug(`TestCaseFhirBase:GetAccessToken(): ${this._id} : ${this.#accesssToken}`);
762
- return this.#accesssToken;
763
- }
764
- this.Debug(`TestCaseFhirBase:GetAccessToken(): Getting new access token`);
757
+ if (this.#accesssToken) return this.#accesssToken;
765
758
  timeout = setTimeout(() => {
766
- this.Warning(chalk.magenta(`TestCaseFhirBase:GetAccessToken(): Timeout: [${this._authMaxTimeout}] exceeded for getting access token ...`));
759
+ this.Warning(chalk.magenta(`TestCaseFhirBase:GetAccessToken(): [${this._id}] Timeout: [${this._authMaxTimeout}] exceeded for getting access token ...`));
767
760
  }, this._authMaxTimeout);
768
761
  const scopes = `api://fb6513e4-16fe-4931-bed8-33b82b404a14/_.stsfhir5:All`.split(" ").sort().join(" ");
769
762
  const authendpointUrl = `${this.#options.authOptions.asendpoint}:${this.#options.authOptions.asport}`;
@@ -777,11 +770,12 @@ var TestCaseFhirBase = class {
777
770
  this.#accesssToken = retVal;
778
771
  if (timeout) clearTimeout(timeout);
779
772
  const totalTime = performance.now() - start;
780
- if (totalTime > this._authMaxTimeout) this.Warning(chalk.magenta(`TestCaseFhirBase:GetAccessToken(): The total time for getting the access token: [${totalTime}]`));
773
+ if (totalTime > this._authMaxTimeout) this.Warning(chalk.magenta(`TestCaseFhirBase:GetAccessToken(): [${this._id}] The total time for getting the access token: [${totalTime}]`));
781
774
  return retVal;
782
775
  } catch (error) {
783
776
  if (timeout) clearTimeout(timeout);
784
- error.message = `TestCaseFhirBase:GetAccessToken(): Error: [${error}], Duration until error: [${performance.now() - start}]`;
777
+ const totalTime = performance.now() - start;
778
+ error.message = `TestCaseFhirBase:GetAccessToken(): [${this._id}] Error: [${error}], Duration until error: [${totalTime}]`;
785
779
  this.Error(error);
786
780
  return "";
787
781
  }
@@ -925,9 +919,9 @@ var TestCaseFhirBase = class {
925
919
  _CheckOutputLongDurationError = (snapshotStart, message) => {
926
920
  const snapShotEnd = performance.now();
927
921
  if (snapShotEnd - snapshotStart > 1e3) {
928
- this.Error(chalk.red(`TestCaseFhirQueryBase:ExecuteRunner:_OutputLongDurationError(): *** ==> Long execution: [${snapShotEnd - snapshotStart}] message: [${message}]`));
929
- this.Error(chalk.red(`TestCaseFhirQueryBase:ExecuteRunner:_OutputLongDurationError(): ==> ${this._GetDetail()}`));
930
- this.Error(chalk.red(`TestCaseFhirQueryBase:ExecuteRunner:_OutputLongDurationError(): ==> Note: While not specifically an error, this is logged as an error.`));
922
+ this.Error(chalk.red(`TestCaseFhirBase:_CheckOutputLongDurationError(): [${this._id}] *** ==> Long execution: [${snapShotEnd - snapshotStart}] message: [${message}]`));
923
+ this.Error(chalk.red(`TestCaseFhirBase:_CheckOutputLongDurationError(): [${this._id}] ==> ${this._GetDetail()}`));
924
+ this.Error(chalk.red(`TestCaseFhirBase:_CheckOutputLongDurationError(): [${this._id}] ==> Note: While not specifically an error, this is logged as an error.`));
931
925
  }
932
926
  return snapShotEnd;
933
927
  };
@@ -951,13 +945,13 @@ var TestCaseFhirBase = class {
951
945
  if (this.HandleError(error) === true) if (this.retryCount < this.maxAuthRetryCount) {
952
946
  this.retryCount++;
953
947
  this.runner.instrumentData.authenticationRetryCount++;
954
- const message = `TestCaseFhir02:ExecuteQuery(): Retry auth attempt: retryCount: [${this.retryCount}], maxAuthRetryCount: [${this.maxAuthRetryCount}]`;
948
+ const message = `TestCaseFhirBase:ExecuteQuery(): [${this._id}] Retry auth attempt: retryCount: [${this.retryCount}], maxAuthRetryCount: [${this.maxAuthRetryCount}]`;
955
949
  this.Error(message);
956
950
  if (this.retryCount > this._RetryMap.length) await Sleep(this._RetryMap[this._RetryMap.length - 1]);
957
951
  else await Sleep(this._RetryMap[this.retryCount - 1]);
958
952
  return await this._ExecuteQuery();
959
953
  } else {
960
- const message = `TestCaseFhir02:ExecuteQuery(): Max auth retries exceeded: retryCount: [${this.retryCount}], maxAuthRetryCount: [${this.maxAuthRetryCount}], Error: [${error}]`;
954
+ const message = `TestCaseFhirBase:_ExecuteQuery(): [${this._id}] Max auth retries exceeded: retryCount: [${this.retryCount}], maxAuthRetryCount: [${this.maxAuthRetryCount}], Error: [${error}]`;
961
955
  this.Error(message);
962
956
  error.message = message;
963
957
  throw error;