@nsshunt/stsrunnerframework 1.0.72 → 1.0.73

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.
@@ -9,7 +9,7 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
9
9
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
10
10
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
11
11
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
12
- var _collectorCollectorPort, _runners, _options, _workerId, _debug, _error, _processLoopExecutor, _SetMessagePort, _CreateRunnerEx2RunState, _UpdateRunnerStateById, _GetAllRunners, _CanExecuteNextIterationById, _IsCompletedById, _GetRunnerIterationById, _ResetRunnerIterationById, _IncRunnerIterationById, _GetRunnerInstanceById, _GetRunnerExecutionProfileById, _GetRunnerOptionsById, _SetRunnerOptionsById, _AddRunner, _WorkerInstance_instances, SleepImmediate_fn, _PostMessageToWorkerManagerById, _StartRunner, _StopRunnerByRunnerById, _StopAllRunners, _StopRunner, _TerminateRunner, _PauseRunner, _ResumeRunner, _ResetRunner, _ExecuteRunner, _UpdateOptions, _workersEx, _options2, _STSInstrumentController, _telemetryProcessor, _archiveList, _processLoopExecutor2, _debug2, _STSWorkerManager_instances, CreateRunnerCopy_fn, _SetRunnerIntoWorker, _ProcessTelemetry, _EmitEvent, _RunnerStateChange, _RemoveRunnerFromCollection, _CreateAsyncRunner, _PostMessageToWorkerUsingDefaultChannel, _PostMessageToWorker, _StartRunner2, _ResetRunner2, _ExecuteRunner2, _StopRunner2, _TerminateRunner2, _PauseRunner2, _ResumeRunner2, _BroadcastCommandToAllRunners, _PauseWorker, _ResumeWorker, _StopWorker, _StartWorker, _ResetWorker, _ExecuteWorker, _BroadcastUpdateCommandToAllRunners, _UpdateOptionsWorker, _TerminateWorker, _UpdateOptions2;
12
+ var _collectorCollectorPort, _runners, _options, _workerId, _debug, _error, _processLoopExecutor, _SetMessagePort, _CreateRunnerEx2RunState, _UpdateRunnerStateById, _GetAllRunners, _CanExecuteNextIterationById, _IsCompletedById, _GetRunnerIterationById, _ResetRunnerIterationById, _IncRunnerIterationById, _GetRunnerInstanceById, _GetRunnerExecutionProfileById, _GetRunnerOptionsById, _SetRunnerOptionsById, _AddRunner, _WorkerInstance_instances, SleepImmediate_fn, _PostMessageToWorkerManagerById, _StartRunner, _StopRunnerByRunnerById, _StopAllRunners, _StopRunner, _TerminateRunner, _PauseRunner, _ResumeRunner, _ResetRunner, _ExecuteRunner, _UpdateOptions, _workersEx, _options2, _STSInstrumentController, _telemetryProcessor, _archiveList, _STSWorkerManager_instances, CreateRunnerCopyNoHistory_fn, CreateRunnerCopy_fn, CreateWorkerCopy_fn, _processLoopExecutor2, _debug2, _SetRunnerIntoWorker, _ProcessTelemetry, _EmitEvent, _RunnerStateChange, _RemoveRunnerFromCollection, _CreateAsyncRunner, _PostMessageToWorkerUsingDefaultChannel, _PostMessageToWorker, _StartRunner2, _ResetRunner2, _ExecuteRunner2, _StopRunner2, _TerminateRunner2, _PauseRunner2, _ResumeRunner2, _BroadcastCommandToAllRunners, _PauseWorker, _ResumeWorker, _StopWorker, _StartWorker, _ResetWorker, _ExecuteWorker, _BroadcastUpdateCommandToAllRunners, _UpdateOptionsWorker, _TerminateWorker, _UpdateOptions2;
13
13
  import { defaultLogger, Sleep, ModelDelimeter } from "@nsshunt/stsutils";
14
14
  import { Gauge } from "@nsshunt/stsobservability";
15
15
  const URI_BASE_VUEUTILS = "/";
@@ -2052,16 +2052,7 @@ class STSWorkerManager {
2052
2052
  await runnerEx.publishInstrumentController.EndPublish();
2053
2053
  await Sleep(250);
2054
2054
  }
2055
- const runner = {
2056
- id: runnerEx.id,
2057
- asyncRunnerContext: { ...runnerEx.asyncRunnerContext },
2058
- instrumentData: { ...runnerEx.instrumentData },
2059
- iteration: runnerEx.iteration,
2060
- options: { ...runnerEx.options },
2061
- runnerHistory: [...runnerEx.runnerHistory],
2062
- state: runnerEx.state,
2063
- workerId: runnerEx.workerId
2064
- };
2055
+ const runner = __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopy_fn).call(this, runnerEx);
2065
2056
  __privateGet(this, _archiveList).push(runner);
2066
2057
  if (__privateGet(this, _archiveList).length > __privateGet(this, _options2).maxArchiveListLength) {
2067
2058
  __privateGet(this, _archiveList).shift();
@@ -2100,7 +2091,6 @@ class STSWorkerManager {
2100
2091
  id: workerId,
2101
2092
  worker: workerFactory.createWorkerThreadWorker(),
2102
2093
  messagePort: port1,
2103
- state: IWorkerState.starting,
2104
2094
  workerThreadWorkerOptions: workerFactory.workerThreadWorkerOptions,
2105
2095
  runnersEx: {},
2106
2096
  runnersEvents: {},
@@ -2172,17 +2162,11 @@ class STSWorkerManager {
2172
2162
  const publishMessagePayload2 = data;
2173
2163
  switch (publishMessagePayload2.command) {
2174
2164
  case eIWMessageCommands.MessagePortResponse:
2175
- stsWorkerEx.state = IWorkerState.started;
2165
+ __privateGet(this, _debug2).call(this, `AddWorker:processMessage(): eIWMessageCommands.MessagePortResponse`);
2176
2166
  break;
2177
2167
  case eIWMessageCommands.InstrumentTelemetry:
2178
2168
  __privateGet(this, _ProcessTelemetry).call(this, stsWorkerEx, publishMessagePayload2.payload);
2179
2169
  break;
2180
- /*
2181
- case eIWMessageCommands.Completed :
2182
- //this.#debug(`AddWorker::eIWMessageCommands.InstrumentTelemetry`);
2183
- this.#ProcessCompleted(stsWorkerEx, publishMessagePayload.payload as ITestRunnerTelemetryPayload);
2184
- break;
2185
- */
2186
2170
  case eIWMessageCommands.RunnerStateChange:
2187
2171
  __privateGet(this, _RunnerStateChange).call(this, stsWorkerEx, publishMessagePayload2.payload);
2188
2172
  break;
@@ -2222,7 +2206,7 @@ class STSWorkerManager {
2222
2206
  });
2223
2207
  __privateAdd(this, _SetRunnerIntoWorker, (workerEx, runnerEx) => {
2224
2208
  const payload = {
2225
- runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopy_fn).call(this, runnerEx)
2209
+ runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopyNoHistory_fn).call(this, runnerEx)
2226
2210
  };
2227
2211
  __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.AddRunner, payload);
2228
2212
  });
@@ -2260,6 +2244,9 @@ class STSWorkerManager {
2260
2244
  if (workerEx.runnersEx[runner.id]) {
2261
2245
  const runnerEx = workerEx.runnersEx[runner.id];
2262
2246
  runnerEx.state = runner.state;
2247
+ if (!runnerEx.runnerHistory) {
2248
+ runnerEx.runnerHistory = [];
2249
+ }
2263
2250
  runnerEx.runnerHistory.push({
2264
2251
  eventDate: /* @__PURE__ */ new Date(),
2265
2252
  runner: { ...runner }
@@ -2359,61 +2346,59 @@ class STSWorkerManager {
2359
2346
  });
2360
2347
  __privateAdd(this, _StartRunner2, async (workerEx, runnerEx) => {
2361
2348
  __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.StartRunner, {
2362
- runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopy_fn).call(this, runnerEx)
2349
+ runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopyNoHistory_fn).call(this, runnerEx)
2363
2350
  });
2364
2351
  return true;
2365
2352
  });
2366
2353
  __privateAdd(this, _ResetRunner2, async (workerEx, runnerEx) => {
2367
2354
  __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.ResetRunner, {
2368
- runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopy_fn).call(this, runnerEx)
2355
+ runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopyNoHistory_fn).call(this, runnerEx)
2369
2356
  });
2370
2357
  return true;
2371
2358
  });
2372
2359
  __privateAdd(this, _ExecuteRunner2, async (workerEx, runnerEx) => {
2373
2360
  __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.ExecuteRunner, {
2374
- runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopy_fn).call(this, runnerEx)
2361
+ runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopyNoHistory_fn).call(this, runnerEx)
2375
2362
  });
2376
2363
  return true;
2377
2364
  });
2378
2365
  __privateAdd(this, _StopRunner2, async (workerEx, runnerEx) => {
2379
2366
  __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.StopRunner, {
2380
- runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopy_fn).call(this, runnerEx)
2367
+ runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopyNoHistory_fn).call(this, runnerEx)
2381
2368
  });
2382
2369
  return true;
2383
2370
  });
2384
2371
  __privateAdd(this, _TerminateRunner2, async (workerEx, runnerEx) => {
2385
2372
  __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.TerminateRunner, {
2386
- runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopy_fn).call(this, runnerEx)
2373
+ runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopyNoHistory_fn).call(this, runnerEx)
2387
2374
  });
2388
2375
  return true;
2389
2376
  });
2390
2377
  __privateAdd(this, _PauseRunner2, async (workerEx, runnerEx) => {
2391
2378
  __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.PauseRunner, {
2392
- runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopy_fn).call(this, runnerEx)
2379
+ runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopyNoHistory_fn).call(this, runnerEx)
2393
2380
  });
2394
2381
  return true;
2395
2382
  });
2396
2383
  __privateAdd(this, _ResumeRunner2, async (workerEx, runnerEx) => {
2397
2384
  __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.ResumeRunner, {
2398
- runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopy_fn).call(this, runnerEx)
2385
+ runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopyNoHistory_fn).call(this, runnerEx)
2399
2386
  });
2400
2387
  return true;
2401
2388
  });
2402
2389
  __privateAdd(this, _BroadcastCommandToAllRunners, async (workerEx, command, options) => {
2403
2390
  try {
2404
- if (workerEx.state !== IWorkerState.stopped) {
2405
- const promArray = [];
2406
- const ids = Object.keys(workerEx.runnersEx);
2407
- ids.forEach((id) => {
2408
- const runnerEx = workerEx.runnersEx[id];
2409
- if (options) {
2410
- promArray.push(command(workerEx, runnerEx, options));
2411
- } else {
2412
- promArray.push(command(workerEx, runnerEx));
2413
- }
2414
- });
2415
- await Promise.all(promArray);
2416
- }
2391
+ const promArray = [];
2392
+ const ids = Object.keys(workerEx.runnersEx);
2393
+ ids.forEach((id) => {
2394
+ const runnerEx = workerEx.runnersEx[id];
2395
+ if (options) {
2396
+ promArray.push(command(workerEx, runnerEx, options));
2397
+ } else {
2398
+ promArray.push(command(workerEx, runnerEx));
2399
+ }
2400
+ });
2401
+ await Promise.all(promArray);
2417
2402
  return true;
2418
2403
  } catch (error) {
2419
2404
  console.log(`Error in STSTestWorker:WorkerCommand: [${error}]`);
@@ -2440,19 +2425,17 @@ class STSWorkerManager {
2440
2425
  });
2441
2426
  __privateAdd(this, _BroadcastUpdateCommandToAllRunners, async (workerEx, command, executionProfile) => {
2442
2427
  try {
2443
- if (workerEx.state !== IWorkerState.stopped) {
2444
- const promArray = [];
2445
- const ids = Object.keys(workerEx.runnersEx);
2446
- ids.forEach((id) => {
2447
- const runnerEx = workerEx.runnersEx[id];
2448
- if (executionProfile) {
2449
- promArray.push(command(workerEx, runnerEx, executionProfile));
2450
- } else {
2451
- promArray.push(command(workerEx, runnerEx));
2452
- }
2453
- });
2454
- await Promise.all(promArray);
2455
- }
2428
+ const promArray = [];
2429
+ const ids = Object.keys(workerEx.runnersEx);
2430
+ ids.forEach((id) => {
2431
+ const runnerEx = workerEx.runnersEx[id];
2432
+ if (executionProfile) {
2433
+ promArray.push(command(workerEx, runnerEx, executionProfile));
2434
+ } else {
2435
+ promArray.push(command(workerEx, runnerEx));
2436
+ }
2437
+ });
2438
+ await Promise.all(promArray);
2456
2439
  return true;
2457
2440
  } catch (error) {
2458
2441
  console.log(`Error in STSTestWorker:WorkerCommand: [${error}]`);
@@ -2465,14 +2448,12 @@ class STSWorkerManager {
2465
2448
  });
2466
2449
  __privateAdd(this, _TerminateWorker, async (workerEx) => {
2467
2450
  try {
2468
- if (workerEx.state !== IWorkerState.stopped) {
2469
- await __privateGet(this, _BroadcastCommandToAllRunners).call(this, workerEx, __privateGet(this, _TerminateRunner2));
2470
- if (workerEx.worker) {
2471
- workerEx.worker.terminate();
2472
- __privateGet(this, _debug2).call(this, `Terminated worker: [${workerEx.id}]`);
2473
- delete __privateGet(this, _workersEx)[workerEx.id];
2474
- } else {
2475
- }
2451
+ await __privateGet(this, _BroadcastCommandToAllRunners).call(this, workerEx, __privateGet(this, _TerminateRunner2));
2452
+ if (workerEx.worker) {
2453
+ workerEx.worker.terminate();
2454
+ __privateGet(this, _debug2).call(this, `Terminated worker: [${workerEx.id}]`);
2455
+ delete __privateGet(this, _workersEx)[workerEx.id];
2456
+ } else {
2476
2457
  }
2477
2458
  return true;
2478
2459
  } catch (error) {
@@ -2483,7 +2464,7 @@ class STSWorkerManager {
2483
2464
  __privateAdd(this, _UpdateOptions2, async (workerEx, runnerEx, executionProfile) => {
2484
2465
  runnerEx.options.executionProfile = { ...executionProfile };
2485
2466
  __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.UpdateOptions, {
2486
- runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopy_fn).call(this, runnerEx)
2467
+ runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopyNoHistory_fn).call(this, runnerEx)
2487
2468
  });
2488
2469
  return true;
2489
2470
  });
@@ -2580,6 +2561,13 @@ class STSWorkerManager {
2580
2561
  }
2581
2562
  __privateGet(this, _processLoopExecutor2).call(this);
2582
2563
  }
2564
+ get Workers() {
2565
+ const retVal = {};
2566
+ for (const [, workerEx] of Object.entries(__privateGet(this, _workersEx))) {
2567
+ retVal[workerEx.id] = __privateMethod(this, _STSWorkerManager_instances, CreateWorkerCopy_fn).call(this, workerEx);
2568
+ }
2569
+ return retVal;
2570
+ }
2583
2571
  get WorkersEx() {
2584
2572
  return __privateGet(this, _workersEx);
2585
2573
  }
@@ -2598,19 +2586,39 @@ _options2 = new WeakMap();
2598
2586
  _STSInstrumentController = new WeakMap();
2599
2587
  _telemetryProcessor = new WeakMap();
2600
2588
  _archiveList = new WeakMap();
2601
- _processLoopExecutor2 = new WeakMap();
2602
- _debug2 = new WeakMap();
2603
2589
  _STSWorkerManager_instances = new WeakSet();
2604
- CreateRunnerCopy_fn = function(runnerEx) {
2590
+ CreateRunnerCopyNoHistory_fn = function(runnerEx) {
2605
2591
  return {
2606
2592
  id: runnerEx.id,
2607
2593
  asyncRunnerContext: { ...runnerEx.asyncRunnerContext },
2608
- options: { ...runnerEx.options },
2609
2594
  instrumentData: { ...runnerEx.instrumentData },
2610
2595
  iteration: runnerEx.iteration,
2611
- state: runnerEx.state
2596
+ options: { ...runnerEx.options },
2597
+ state: runnerEx.state,
2598
+ workerId: runnerEx.workerId
2612
2599
  };
2613
2600
  };
2601
+ CreateRunnerCopy_fn = function(runnerEx) {
2602
+ const retVal = __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopyNoHistory_fn).call(this, runnerEx);
2603
+ if (runnerEx.runnerHistory) {
2604
+ retVal.runnerHistory = [...runnerEx.runnerHistory];
2605
+ }
2606
+ return retVal;
2607
+ };
2608
+ CreateWorkerCopy_fn = function(workerEx) {
2609
+ const { id, workerThreadWorkerOptions, runnersEx } = workerEx;
2610
+ const workerCopy = {
2611
+ id,
2612
+ workerThreadWorkerOptions: { ...workerThreadWorkerOptions },
2613
+ runners: {}
2614
+ };
2615
+ for (const [, runnerEx] of Object.entries(runnersEx)) {
2616
+ workerCopy.runners[runnerEx.id] = __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopy_fn).call(this, runnerEx);
2617
+ }
2618
+ return workerCopy;
2619
+ };
2620
+ _processLoopExecutor2 = new WeakMap();
2621
+ _debug2 = new WeakMap();
2614
2622
  _SetRunnerIntoWorker = new WeakMap();
2615
2623
  _ProcessTelemetry = new WeakMap();
2616
2624
  _EmitEvent = new WeakMap();