@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.
@@ -462,7 +462,7 @@ var TestCaseFhirBase = class {
462
462
  const onRetryAttempt = (attempt, error, delayMs) => {
463
463
  this.#runner.instrumentData.errorCount++;
464
464
  this.#runner.instrumentData.requestCount++;
465
- const message = `TestCaseFhirBase:onRetryAttempt(): Retry #${attempt} after ${delayMs}ms due to ${error.code || error.response?.status}`;
465
+ const message = `TestCaseFhirBase:onRetryAttempt(): [${this._id}] Retry #${attempt} after ${delayMs}ms due to ${error.code || error.response?.status}`;
466
466
  this.Warning(message);
467
467
  this.#runner.instrumentData.message.push(chalk.default.red(message));
468
468
  };
@@ -498,7 +498,7 @@ var TestCaseFhirBase = class {
498
498
  case "stress-test-extreme-agent-options":
499
499
  agentOptions = { ...this.stressTestExtremeAgentOptions };
500
500
  break;
501
- default: throw new Error(`GetFhirSocketClient(): unknown nodeAgentMode: [${testingAgentOptions.nodeAgentMode}]`);
501
+ default: throw new Error(`TestCaseFhirBase:GetAgentManager(): [${this._id}] unknown nodeAgentMode: [${testingAgentOptions.nodeAgentMode}]`);
502
502
  }
503
503
  if (agentOptions) agentManager = (0, _nsshunt_stsutils.createAgentManager)({
504
504
  agentOptions,
@@ -523,17 +523,17 @@ var TestCaseFhirBase = class {
523
523
  let fhirClient = this.runnerExecutionWorker.GetFhirClient();
524
524
  if (fhirClient) return fhirClient;
525
525
  if (this.runnerExecutionWorker.GetOnHold("fhirclient") === true) {
526
- this.Debug(chalk.default.magenta(`[${this.runnerExecutionWorker.id}] fhir client does not exist - some other client setting up the new client (on hold/lock) - waiting ...`));
526
+ this.Debug(chalk.default.magenta(`[${this.runnerExecutionWorker.id}] [${this._id}] fhir client does not exist - some other client setting up the new client (on hold/lock) - waiting ...`));
527
527
  try {
528
528
  const start = performance.now();
529
529
  await this.runnerExecutionWorker.WaitOnHold("fhirclient", 6e4);
530
- this.Debug(chalk.default.yellow(`[${this.runnerExecutionWorker.id}] hold (lock) released after: [${performance.now() - start}ms]`));
530
+ this.Debug(chalk.default.yellow(`[${this.runnerExecutionWorker.id}] [${this._id}] hold (lock) released after: [${performance.now() - start}ms]`));
531
531
  const fhirClient = this.runnerExecutionWorker.GetFhirClient();
532
532
  if (fhirClient) {
533
- this.Debug(chalk.default.green(`[${this.runnerExecutionWorker.id}] Getting existing fhir client (post hold release)`));
533
+ this.Debug(chalk.default.green(`[${this.runnerExecutionWorker.id}] [${this._id}] Getting existing fhir client (post hold release)`));
534
534
  return fhirClient;
535
535
  } else {
536
- this.Error(chalk.default.red(`[${this.runnerExecutionWorker.id}] Could not get existing fhir client (post hold release)`));
536
+ this.Error(chalk.default.red(`[${this.runnerExecutionWorker.id}] [${this._id}] Could not get existing fhir client (post hold release)`));
537
537
  this.Error(chalk.default.red(`continue anyway ...`));
538
538
  }
539
539
  } catch (error) {
@@ -541,8 +541,8 @@ var TestCaseFhirBase = class {
541
541
  }
542
542
  }
543
543
  const start = performance.now();
544
- this.Debug(chalk.default.yellow(`[${this.runnerExecutionWorker.id}] fhir client does not exist - setting up new client`));
545
- this.Debug(chalk.default.yellow(`[${this.runnerExecutionWorker.id}] setting hold (lock)`));
544
+ this.Debug(chalk.default.yellow(`[${this.runnerExecutionWorker.id}] [${this._id}] fhir client does not exist - setting up new client`));
545
+ this.Debug(chalk.default.yellow(`[${this.runnerExecutionWorker.id}] [${this._id}] setting hold (lock)`));
546
546
  this.runnerExecutionWorker.SetOnHold("fhirclient");
547
547
  const fhirOptions = this.#options.fhirOptions;
548
548
  const options = {
@@ -563,10 +563,10 @@ var TestCaseFhirBase = class {
563
563
  if (this.runner.options.fhirOptions.stsfhirsocketclientmode === "socket-client-all-in-one") fhirClient = new _nsshunt_stsfhirclient.FhirSocketClientAllInOne("FhirSocketClient", options);
564
564
  else fhirClient = new _nsshunt_stsfhirclient.FhirSocketClientIndividual("FhirSocketClient", options);
565
565
  await fhirClient.WaitForSocketConnected();
566
- this.Debug(chalk.default.yellow(`[${this.runnerExecutionWorker.id}] setting fhir client into object`));
566
+ this.Debug(chalk.default.yellow(`[${this.runnerExecutionWorker.id}] [${this._id}] setting fhir client into object`));
567
567
  this.runnerExecutionWorker.SetFhirClient(fhirClient);
568
568
  this.runnerExecutionWorker.ReleaseOnHold("fhirclient");
569
- this.Debug(chalk.default.yellow(`[${this.runnerExecutionWorker.id}] release hold (lock) Time taken for socket connection and set object: [${performance.now() - start}ms]`));
569
+ this.Debug(chalk.default.yellow(`[${this.runnerExecutionWorker.id}] [${this._id}] release hold (lock) Time taken for socket connection and set object: [${performance.now() - start}ms]`));
570
570
  return fhirClient;
571
571
  } catch (error) {
572
572
  this.Error(error);
@@ -683,7 +683,7 @@ var TestCaseFhirBase = class {
683
683
  onRetryAttempt: (attempt, error, delayMs) => {
684
684
  this.#runner.instrumentData.authenticationErrorCount++;
685
685
  this.#runner.instrumentData.authenticationRetryCount++;
686
- const message = `TestCaseFhirBase:GetAPITokenFromAuthServerUsingScope(): Retry #${attempt} after ${delayMs}ms due to ${error.code || error.response?.status}`;
686
+ const message = `TestCaseFhirBase:GetAPITokenFromAuthServerUsingScope(): [${this._id}] Retry #${attempt} after ${delayMs}ms due to ${error.code || error.response?.status}`;
687
687
  this.Warning(message);
688
688
  this.#runner.instrumentData.message.push(chalk.default.red(message));
689
689
  }
@@ -691,7 +691,7 @@ var TestCaseFhirBase = class {
691
691
  this.#runner.instrumentData.authenticationCount++;
692
692
  stage = "7";
693
693
  if (retVal.status) {
694
- if (retVal.status !== 200) this.Warning(chalk.default.magenta(`TestCaseFhirBase:GetAPITokenFromAuthServerUsingScope(): Invalid response from server: [${retVal.status}]`));
694
+ if (retVal.status !== 200) this.Warning(chalk.default.magenta(`TestCaseFhirBase:GetAPITokenFromAuthServerUsingScope(): [${this._id}] Invalid response from server: [${retVal.status}]`));
695
695
  } else throw new Error(chalk.default.red(`No retVal.status)`));
696
696
  stage = "8";
697
697
  if (retVal.data) {
@@ -715,13 +715,13 @@ var TestCaseFhirBase = class {
715
715
  } catch (error) {
716
716
  details = `Could not JSON.stringify(error.response.data)`;
717
717
  }
718
- error.message = `TestCaseFhirBase:GetAPITokenFromAuthServerUsingScope(): Error: [${error}], Stage: [${stage}], Details: [${details}]`;
718
+ error.message = `TestCaseFhirBase:GetAPITokenFromAuthServerUsingScope(): [${this._id}] Error: [${error}], Stage: [${stage}], Details: [${details}]`;
719
719
  throw error;
720
720
  }
721
721
  };
722
722
  GetAccessTokenForSocketClientAccess = async () => {
723
723
  const timeout = setTimeout(() => {
724
- this.Warning(`TestCaseFhirBase:GetAccessTokenForSocketClientAccess(): Timeout: [${this._authMaxTimeout}] exceeded for getting access token ...`);
724
+ this.Warning(`TestCaseFhirBase:GetAccessTokenForSocketClientAccess(): [${this._id}] Timeout: [${this._authMaxTimeout}] exceeded for getting access token ...`);
725
725
  }, this._authMaxTimeout);
726
726
  const start = performance.now();
727
727
  try {
@@ -735,43 +735,40 @@ var TestCaseFhirBase = class {
735
735
  });
736
736
  clearTimeout(timeout);
737
737
  const totalTime = performance.now() - start;
738
- if (totalTime > this._authMaxTimeout) this.Warning(chalk.default.magenta(`TestCaseFhirBase:GetAccessTokenForSocketClientAccess(): The total time for getting the access token: [${totalTime}]`));
738
+ if (totalTime > this._authMaxTimeout) this.Warning(chalk.default.magenta(`TestCaseFhirBase:GetAccessTokenForSocketClientAccess(): [${this._id}] The total time for getting the access token: [${totalTime}]`));
739
739
  return retVal;
740
740
  } catch (error) {
741
741
  clearTimeout(timeout);
742
- error.message = `TestCaseFhirBase:GetAccessTokenForSocketClientAccess(): Error: [${error}], Duration until error: [${performance.now() - start}]`;
742
+ const totalTime = performance.now() - start;
743
+ error.message = `TestCaseFhirBase:GetAccessTokenForSocketClientAccess(): [${this._id}] Error: [${error}], Duration until error: [${totalTime}]`;
743
744
  this.Error(error);
744
745
  return "";
745
746
  }
746
747
  };
747
748
  ResetAccessToken = () => {
748
- console.log(chalk.default.magenta(`************************************************************************* start `));
749
- console.log(chalk.default.magenta(`Old Token: ${this._id} : ${this.#accesssToken}`));
750
749
  this.#accesssToken = null;
751
- console.log(chalk.default.magenta(`New Token: ${this._id} : ${this.#accesssToken}`));
752
- console.log(chalk.default.magenta(`************************************************************************* end `));
753
750
  };
754
751
  HandleError = (error) => {
755
- this.Error(chalk.default.red(`TestCaseFhirBase:HandleError(): Error: [${error}]`));
756
- this.Error(chalk.default.red(`TestCaseFhirBase:HandleError(): description: [${this.runner.options.description}]`));
757
- this.Error(chalk.default.red(`TestCaseFhirBase:HandleError(): iteration: [${this.runner.iteration}]`));
758
- this.Error(chalk.default.red(`TestCaseFhirBase:HandleError(): asyncRunnerContext: [${JSON.stringify(this.runner.asyncRunnerContext)}]`));
752
+ this.Error(chalk.default.red(`TestCaseFhirBase:HandleError(): [${this._id}] Error: [${error}]`));
753
+ this.Error(chalk.default.red(`TestCaseFhirBase:HandleError(): [${this._id}] description: [${this.runner.options.description}]`));
754
+ this.Error(chalk.default.red(`TestCaseFhirBase:HandleError(): [${this._id}] iteration: [${this.runner.iteration}]`));
755
+ this.Error(chalk.default.red(`TestCaseFhirBase:HandleError(): [${this._id}] asyncRunnerContext: [${JSON.stringify(this.runner.asyncRunnerContext)}]`));
759
756
  if (axios.default.isAxiosError(error)) {
760
757
  const axiosError = error;
761
758
  if (axiosError.response) {
762
- this.Error(chalk.default.red(`TestCaseFhirBase:HandleError(): AXIOS Error Response.Status = [${axiosError.response.status}]`));
763
- if (axiosError.response.headers) this.Error(chalk.default.red(`TestCaseFhirBase:HandleError(): headers: [${JSON.stringify(axiosError.response.headers)}]`));
764
- if (axiosError.response.data) this.Error(chalk.default.red(`TestCaseFhirBase:HandleError(): data: [${JSON.stringify(axiosError.response.data)}]`));
759
+ this.Error(chalk.default.red(`TestCaseFhirBase:HandleError(): [${this._id}] AXIOS Error Response.Status = [${axiosError.response.status}]`));
760
+ if (axiosError.response.headers) this.Error(chalk.default.red(`TestCaseFhirBase:HandleError(): [${this._id}] headers: [${JSON.stringify(axiosError.response.headers)}]`));
761
+ if (axiosError.response.data) this.Error(chalk.default.red(`TestCaseFhirBase:HandleError(): [${this._id}] data: [${JSON.stringify(axiosError.response.data)}]`));
765
762
  if (axiosError.response.status === StatusCodes.UNAUTHORIZED) {
766
763
  this.runner.instrumentData.authenticationErrorCount++;
767
- this.Error(chalk.default.red(`TestCaseFhirBase:HandleError(): UNAUTHORIZED - Reset Access Token`));
764
+ this.Error(chalk.default.red(`TestCaseFhirBase:HandleError(): [${this._id}] UNAUTHORIZED - Reset Access Token`));
768
765
  this.ResetAccessToken();
769
766
  return true;
770
767
  }
771
- } else this.Error(chalk.default.red(`TestCaseFhirBase:HandleError(): AXIOS Error = [${axiosError}]`));
768
+ } else this.Error(chalk.default.red(`TestCaseFhirBase:HandleError(): [${this._id}] AXIOS Error = [${axiosError}]`));
772
769
  } else if (error.message === "UNAUTHORIZED") {
773
770
  this.runner.instrumentData.authenticationErrorCount++;
774
- this.Error(chalk.default.red(`TestCaseFhirBase:HandleError(): UNAUTHORIZED - Reset Access Token`));
771
+ this.Error(chalk.default.red(`TestCaseFhirBase:HandleError(): [${this._id}] UNAUTHORIZED - Reset Access Token`));
775
772
  this.ResetAccessToken();
776
773
  return true;
777
774
  }
@@ -781,13 +778,9 @@ var TestCaseFhirBase = class {
781
778
  let timeout = void 0;
782
779
  let start = performance.now();
783
780
  try {
784
- if (this.#accesssToken) {
785
- this.Debug(`TestCaseFhirBase:GetAccessToken(): ${this._id} : ${this.#accesssToken}`);
786
- return this.#accesssToken;
787
- }
788
- this.Debug(`TestCaseFhirBase:GetAccessToken(): Getting new access token`);
781
+ if (this.#accesssToken) return this.#accesssToken;
789
782
  timeout = setTimeout(() => {
790
- this.Warning(chalk.default.magenta(`TestCaseFhirBase:GetAccessToken(): Timeout: [${this._authMaxTimeout}] exceeded for getting access token ...`));
783
+ this.Warning(chalk.default.magenta(`TestCaseFhirBase:GetAccessToken(): [${this._id}] Timeout: [${this._authMaxTimeout}] exceeded for getting access token ...`));
791
784
  }, this._authMaxTimeout);
792
785
  const scopes = `api://fb6513e4-16fe-4931-bed8-33b82b404a14/_.stsfhir5:All`.split(" ").sort().join(" ");
793
786
  const authendpointUrl = `${this.#options.authOptions.asendpoint}:${this.#options.authOptions.asport}`;
@@ -801,11 +794,12 @@ var TestCaseFhirBase = class {
801
794
  this.#accesssToken = retVal;
802
795
  if (timeout) clearTimeout(timeout);
803
796
  const totalTime = performance.now() - start;
804
- if (totalTime > this._authMaxTimeout) this.Warning(chalk.default.magenta(`TestCaseFhirBase:GetAccessToken(): The total time for getting the access token: [${totalTime}]`));
797
+ if (totalTime > this._authMaxTimeout) this.Warning(chalk.default.magenta(`TestCaseFhirBase:GetAccessToken(): [${this._id}] The total time for getting the access token: [${totalTime}]`));
805
798
  return retVal;
806
799
  } catch (error) {
807
800
  if (timeout) clearTimeout(timeout);
808
- error.message = `TestCaseFhirBase:GetAccessToken(): Error: [${error}], Duration until error: [${performance.now() - start}]`;
801
+ const totalTime = performance.now() - start;
802
+ error.message = `TestCaseFhirBase:GetAccessToken(): [${this._id}] Error: [${error}], Duration until error: [${totalTime}]`;
809
803
  this.Error(error);
810
804
  return "";
811
805
  }
@@ -949,9 +943,9 @@ var TestCaseFhirBase = class {
949
943
  _CheckOutputLongDurationError = (snapshotStart, message) => {
950
944
  const snapShotEnd = performance.now();
951
945
  if (snapShotEnd - snapshotStart > 1e3) {
952
- this.Error(chalk.default.red(`TestCaseFhirQueryBase:ExecuteRunner:_OutputLongDurationError(): *** ==> Long execution: [${snapShotEnd - snapshotStart}] message: [${message}]`));
953
- this.Error(chalk.default.red(`TestCaseFhirQueryBase:ExecuteRunner:_OutputLongDurationError(): ==> ${this._GetDetail()}`));
954
- this.Error(chalk.default.red(`TestCaseFhirQueryBase:ExecuteRunner:_OutputLongDurationError(): ==> Note: While not specifically an error, this is logged as an error.`));
946
+ this.Error(chalk.default.red(`TestCaseFhirBase:_CheckOutputLongDurationError(): [${this._id}] *** ==> Long execution: [${snapShotEnd - snapshotStart}] message: [${message}]`));
947
+ this.Error(chalk.default.red(`TestCaseFhirBase:_CheckOutputLongDurationError(): [${this._id}] ==> ${this._GetDetail()}`));
948
+ this.Error(chalk.default.red(`TestCaseFhirBase:_CheckOutputLongDurationError(): [${this._id}] ==> Note: While not specifically an error, this is logged as an error.`));
955
949
  }
956
950
  return snapShotEnd;
957
951
  };
@@ -975,13 +969,13 @@ var TestCaseFhirBase = class {
975
969
  if (this.HandleError(error) === true) if (this.retryCount < this.maxAuthRetryCount) {
976
970
  this.retryCount++;
977
971
  this.runner.instrumentData.authenticationRetryCount++;
978
- const message = `TestCaseFhir02:ExecuteQuery(): Retry auth attempt: retryCount: [${this.retryCount}], maxAuthRetryCount: [${this.maxAuthRetryCount}]`;
972
+ const message = `TestCaseFhirBase:ExecuteQuery(): [${this._id}] Retry auth attempt: retryCount: [${this.retryCount}], maxAuthRetryCount: [${this.maxAuthRetryCount}]`;
979
973
  this.Error(message);
980
974
  if (this.retryCount > this._RetryMap.length) await (0, _nsshunt_stsutils.Sleep)(this._RetryMap[this._RetryMap.length - 1]);
981
975
  else await (0, _nsshunt_stsutils.Sleep)(this._RetryMap[this.retryCount - 1]);
982
976
  return await this._ExecuteQuery();
983
977
  } else {
984
- const message = `TestCaseFhir02:ExecuteQuery(): Max auth retries exceeded: retryCount: [${this.retryCount}], maxAuthRetryCount: [${this.maxAuthRetryCount}], Error: [${error}]`;
978
+ const message = `TestCaseFhirBase:_ExecuteQuery(): [${this._id}] Max auth retries exceeded: retryCount: [${this.retryCount}], maxAuthRetryCount: [${this.maxAuthRetryCount}], Error: [${error}]`;
985
979
  this.Error(message);
986
980
  error.message = message;
987
981
  throw error;