@nsshunt/ststestrunner 1.1.69 → 1.1.70

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.
@@ -149,7 +149,24 @@ var TestCaseFhirBase = class {
149
149
  console.log(chalk.green(`[${this.runnerExecutionWorker.id}] Getting existing fhir client`));
150
150
  return fhirClient;
151
151
  }
152
+ if (this.runnerExecutionWorker.GetOnHold("fhirclient") === true) {
153
+ console.log(chalk.magenta(`[${this.runnerExecutionWorker.id}] fhir client does not exist - some other client setting up the new client - waiting ...`));
154
+ try {
155
+ await this.runnerExecutionWorker.WaitOnHold("fhirclient", 6e4);
156
+ const fhirClient = this.runnerExecutionWorker.GetFhirClient();
157
+ if (fhirClient) {
158
+ console.log(chalk.green(`[${this.runnerExecutionWorker.id}] Getting existing fhir client (post hold release)`));
159
+ return fhirClient;
160
+ } else {
161
+ console.log(chalk.red(`[${this.runnerExecutionWorker.id}] Could not get existing fhir client (post hold release)`));
162
+ console.log(chalk.red(`continue anyway ...`));
163
+ }
164
+ } catch (error) {
165
+ console.error(chalk.red(`GetFhirSocketClient(): Error: [${error}]`));
166
+ }
167
+ }
152
168
  console.log(chalk.red(`[${this.runnerExecutionWorker.id}] fhir client does not exist - setting up new client`));
169
+ this.runnerExecutionWorker.SetOnHold("fhirclient");
153
170
  const fhirOptions = this.#options.fhirOptions;
154
171
  const options = {
155
172
  fhirServerEndpoint: fhirOptions.stsfhirserverendpoint,
@@ -171,6 +188,7 @@ var TestCaseFhirBase = class {
171
188
  await fhirClient.WaitForSocketConnected();
172
189
  console.log(chalk.red(`[${this.runnerExecutionWorker.id}] setting fhir client into object`));
173
190
  this.runnerExecutionWorker.SetFhirClient(fhirClient);
191
+ this.runnerExecutionWorker.ReleaseOnHold("fhirclient");
174
192
  return fhirClient;
175
193
  } catch (error) {
176
194
  this.LogErrorMessage(error);
@@ -35801,6 +35819,7 @@ var WorkerFhirTestCases = class extends AbstractRunnerExecutionWorker {
35801
35819
  _resourceDataGenerator;
35802
35820
  fhirClient = void 0;
35803
35821
  _id = crypto.randomUUID();
35822
+ _onHoldKeys = {};
35804
35823
  constructor(options) {
35805
35824
  super();
35806
35825
  this._options = options;
@@ -35837,6 +35856,25 @@ var WorkerFhirTestCases = class extends AbstractRunnerExecutionWorker {
35837
35856
  myresponsepreterminate: `I got: [${JSON.stringify(messagePayload.payload.data)}]`
35838
35857
  };
35839
35858
  }
35859
+ GetOnHold = (holdKey) => {
35860
+ if (this._onHoldKeys[holdKey]) return true;
35861
+ return false;
35862
+ };
35863
+ WaitOnHold = async (holdKey, timeout) => {
35864
+ const start = performance.now();
35865
+ for (;;) {
35866
+ if (this._onHoldKeys[holdKey]) await Sleep(100);
35867
+ else break;
35868
+ if (performance.now() - start > timeout) throw new Error(`WaitOnHold timeout: [${timeout}] reached.`);
35869
+ }
35870
+ return true;
35871
+ };
35872
+ SetOnHold = (holdKey) => {
35873
+ this._onHoldKeys[holdKey] = true;
35874
+ };
35875
+ ReleaseOnHold = (holdKey) => {
35876
+ delete this._onHoldKeys[holdKey];
35877
+ };
35840
35878
  };
35841
35879
  //#endregion
35842
35880
  export { WorkerFhirTestCases };