@nsshunt/stsrunnerframework 1.0.72 → 1.0.74

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, _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 = "/";
@@ -2019,7 +2019,6 @@ function v4(options, buf, offset) {
2019
2019
  chalk.level = 3;
2020
2020
  class STSWorkerManager {
2021
2021
  constructor(options) {
2022
- __privateAdd(this, _STSWorkerManager_instances);
2023
2022
  //#agentSession: string = null;
2024
2023
  __privateAdd(this, _workersEx, {});
2025
2024
  __privateAdd(this, _options2);
@@ -2052,16 +2051,7 @@ class STSWorkerManager {
2052
2051
  await runnerEx.publishInstrumentController.EndPublish();
2053
2052
  await Sleep(250);
2054
2053
  }
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
- };
2054
+ const runner = this.CreateRunnerCopy(runnerEx);
2065
2055
  __privateGet(this, _archiveList).push(runner);
2066
2056
  if (__privateGet(this, _archiveList).length > __privateGet(this, _options2).maxArchiveListLength) {
2067
2057
  __privateGet(this, _archiveList).shift();
@@ -2100,7 +2090,6 @@ class STSWorkerManager {
2100
2090
  id: workerId,
2101
2091
  worker: workerFactory.createWorkerThreadWorker(),
2102
2092
  messagePort: port1,
2103
- state: IWorkerState.starting,
2104
2093
  workerThreadWorkerOptions: workerFactory.workerThreadWorkerOptions,
2105
2094
  runnersEx: {},
2106
2095
  runnersEvents: {},
@@ -2172,17 +2161,11 @@ class STSWorkerManager {
2172
2161
  const publishMessagePayload2 = data;
2173
2162
  switch (publishMessagePayload2.command) {
2174
2163
  case eIWMessageCommands.MessagePortResponse:
2175
- stsWorkerEx.state = IWorkerState.started;
2164
+ __privateGet(this, _debug2).call(this, `AddWorker:processMessage(): eIWMessageCommands.MessagePortResponse`);
2176
2165
  break;
2177
2166
  case eIWMessageCommands.InstrumentTelemetry:
2178
2167
  __privateGet(this, _ProcessTelemetry).call(this, stsWorkerEx, publishMessagePayload2.payload);
2179
2168
  break;
2180
- /*
2181
- case eIWMessageCommands.Completed :
2182
- //this.#debug(`AddWorker::eIWMessageCommands.InstrumentTelemetry`);
2183
- this.#ProcessCompleted(stsWorkerEx, publishMessagePayload.payload as ITestRunnerTelemetryPayload);
2184
- break;
2185
- */
2186
2169
  case eIWMessageCommands.RunnerStateChange:
2187
2170
  __privateGet(this, _RunnerStateChange).call(this, stsWorkerEx, publishMessagePayload2.payload);
2188
2171
  break;
@@ -2222,7 +2205,7 @@ class STSWorkerManager {
2222
2205
  });
2223
2206
  __privateAdd(this, _SetRunnerIntoWorker, (workerEx, runnerEx) => {
2224
2207
  const payload = {
2225
- runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopy_fn).call(this, runnerEx)
2208
+ runner: this.CreateRunnerCopyNoHistory(runnerEx)
2226
2209
  };
2227
2210
  __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.AddRunner, payload);
2228
2211
  });
@@ -2260,6 +2243,9 @@ class STSWorkerManager {
2260
2243
  if (workerEx.runnersEx[runner.id]) {
2261
2244
  const runnerEx = workerEx.runnersEx[runner.id];
2262
2245
  runnerEx.state = runner.state;
2246
+ if (!runnerEx.runnerHistory) {
2247
+ runnerEx.runnerHistory = [];
2248
+ }
2263
2249
  runnerEx.runnerHistory.push({
2264
2250
  eventDate: /* @__PURE__ */ new Date(),
2265
2251
  runner: { ...runner }
@@ -2359,61 +2345,59 @@ class STSWorkerManager {
2359
2345
  });
2360
2346
  __privateAdd(this, _StartRunner2, async (workerEx, runnerEx) => {
2361
2347
  __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.StartRunner, {
2362
- runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopy_fn).call(this, runnerEx)
2348
+ runner: this.CreateRunnerCopyNoHistory(runnerEx)
2363
2349
  });
2364
2350
  return true;
2365
2351
  });
2366
2352
  __privateAdd(this, _ResetRunner2, async (workerEx, runnerEx) => {
2367
2353
  __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.ResetRunner, {
2368
- runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopy_fn).call(this, runnerEx)
2354
+ runner: this.CreateRunnerCopyNoHistory(runnerEx)
2369
2355
  });
2370
2356
  return true;
2371
2357
  });
2372
2358
  __privateAdd(this, _ExecuteRunner2, async (workerEx, runnerEx) => {
2373
2359
  __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.ExecuteRunner, {
2374
- runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopy_fn).call(this, runnerEx)
2360
+ runner: this.CreateRunnerCopyNoHistory(runnerEx)
2375
2361
  });
2376
2362
  return true;
2377
2363
  });
2378
2364
  __privateAdd(this, _StopRunner2, async (workerEx, runnerEx) => {
2379
2365
  __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.StopRunner, {
2380
- runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopy_fn).call(this, runnerEx)
2366
+ runner: this.CreateRunnerCopyNoHistory(runnerEx)
2381
2367
  });
2382
2368
  return true;
2383
2369
  });
2384
2370
  __privateAdd(this, _TerminateRunner2, async (workerEx, runnerEx) => {
2385
2371
  __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.TerminateRunner, {
2386
- runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopy_fn).call(this, runnerEx)
2372
+ runner: this.CreateRunnerCopyNoHistory(runnerEx)
2387
2373
  });
2388
2374
  return true;
2389
2375
  });
2390
2376
  __privateAdd(this, _PauseRunner2, async (workerEx, runnerEx) => {
2391
2377
  __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.PauseRunner, {
2392
- runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopy_fn).call(this, runnerEx)
2378
+ runner: this.CreateRunnerCopyNoHistory(runnerEx)
2393
2379
  });
2394
2380
  return true;
2395
2381
  });
2396
2382
  __privateAdd(this, _ResumeRunner2, async (workerEx, runnerEx) => {
2397
2383
  __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.ResumeRunner, {
2398
- runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopy_fn).call(this, runnerEx)
2384
+ runner: this.CreateRunnerCopyNoHistory(runnerEx)
2399
2385
  });
2400
2386
  return true;
2401
2387
  });
2402
2388
  __privateAdd(this, _BroadcastCommandToAllRunners, async (workerEx, command, options) => {
2403
2389
  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
- }
2390
+ const promArray = [];
2391
+ const ids = Object.keys(workerEx.runnersEx);
2392
+ ids.forEach((id) => {
2393
+ const runnerEx = workerEx.runnersEx[id];
2394
+ if (options) {
2395
+ promArray.push(command(workerEx, runnerEx, options));
2396
+ } else {
2397
+ promArray.push(command(workerEx, runnerEx));
2398
+ }
2399
+ });
2400
+ await Promise.all(promArray);
2417
2401
  return true;
2418
2402
  } catch (error) {
2419
2403
  console.log(`Error in STSTestWorker:WorkerCommand: [${error}]`);
@@ -2440,19 +2424,17 @@ class STSWorkerManager {
2440
2424
  });
2441
2425
  __privateAdd(this, _BroadcastUpdateCommandToAllRunners, async (workerEx, command, executionProfile) => {
2442
2426
  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
- }
2427
+ const promArray = [];
2428
+ const ids = Object.keys(workerEx.runnersEx);
2429
+ ids.forEach((id) => {
2430
+ const runnerEx = workerEx.runnersEx[id];
2431
+ if (executionProfile) {
2432
+ promArray.push(command(workerEx, runnerEx, executionProfile));
2433
+ } else {
2434
+ promArray.push(command(workerEx, runnerEx));
2435
+ }
2436
+ });
2437
+ await Promise.all(promArray);
2456
2438
  return true;
2457
2439
  } catch (error) {
2458
2440
  console.log(`Error in STSTestWorker:WorkerCommand: [${error}]`);
@@ -2465,14 +2447,12 @@ class STSWorkerManager {
2465
2447
  });
2466
2448
  __privateAdd(this, _TerminateWorker, async (workerEx) => {
2467
2449
  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
- }
2450
+ await __privateGet(this, _BroadcastCommandToAllRunners).call(this, workerEx, __privateGet(this, _TerminateRunner2));
2451
+ if (workerEx.worker) {
2452
+ workerEx.worker.terminate();
2453
+ __privateGet(this, _debug2).call(this, `Terminated worker: [${workerEx.id}]`);
2454
+ delete __privateGet(this, _workersEx)[workerEx.id];
2455
+ } else {
2476
2456
  }
2477
2457
  return true;
2478
2458
  } catch (error) {
@@ -2483,7 +2463,7 @@ class STSWorkerManager {
2483
2463
  __privateAdd(this, _UpdateOptions2, async (workerEx, runnerEx, executionProfile) => {
2484
2464
  runnerEx.options.executionProfile = { ...executionProfile };
2485
2465
  __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.UpdateOptions, {
2486
- runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopy_fn).call(this, runnerEx)
2466
+ runner: this.CreateRunnerCopyNoHistory(runnerEx)
2487
2467
  });
2488
2468
  return true;
2489
2469
  });
@@ -2580,6 +2560,43 @@ class STSWorkerManager {
2580
2560
  }
2581
2561
  __privateGet(this, _processLoopExecutor2).call(this);
2582
2562
  }
2563
+ CreateRunnerCopyNoHistory(runnerEx) {
2564
+ return {
2565
+ id: runnerEx.id,
2566
+ asyncRunnerContext: { ...runnerEx.asyncRunnerContext },
2567
+ instrumentData: { ...runnerEx.instrumentData },
2568
+ iteration: runnerEx.iteration,
2569
+ options: { ...runnerEx.options },
2570
+ state: runnerEx.state,
2571
+ workerId: runnerEx.workerId
2572
+ };
2573
+ }
2574
+ CreateRunnerCopy(runnerEx) {
2575
+ const retVal = this.CreateRunnerCopyNoHistory(runnerEx);
2576
+ if (runnerEx.runnerHistory) {
2577
+ retVal.runnerHistory = [...runnerEx.runnerHistory];
2578
+ }
2579
+ return retVal;
2580
+ }
2581
+ CreateWorkerCopy(workerEx) {
2582
+ const { id, workerThreadWorkerOptions, runnersEx } = workerEx;
2583
+ const workerCopy = {
2584
+ id,
2585
+ workerThreadWorkerOptions: { ...workerThreadWorkerOptions },
2586
+ runners: {}
2587
+ };
2588
+ for (const [, runnerEx] of Object.entries(runnersEx)) {
2589
+ workerCopy.runners[runnerEx.id] = this.CreateRunnerCopy(runnerEx);
2590
+ }
2591
+ return workerCopy;
2592
+ }
2593
+ get Workers() {
2594
+ const retVal = {};
2595
+ for (const [, workerEx] of Object.entries(__privateGet(this, _workersEx))) {
2596
+ retVal[workerEx.id] = this.CreateWorkerCopy(workerEx);
2597
+ }
2598
+ return retVal;
2599
+ }
2583
2600
  get WorkersEx() {
2584
2601
  return __privateGet(this, _workersEx);
2585
2602
  }
@@ -2600,17 +2617,6 @@ _telemetryProcessor = new WeakMap();
2600
2617
  _archiveList = new WeakMap();
2601
2618
  _processLoopExecutor2 = new WeakMap();
2602
2619
  _debug2 = new WeakMap();
2603
- _STSWorkerManager_instances = new WeakSet();
2604
- CreateRunnerCopy_fn = function(runnerEx) {
2605
- return {
2606
- id: runnerEx.id,
2607
- asyncRunnerContext: { ...runnerEx.asyncRunnerContext },
2608
- options: { ...runnerEx.options },
2609
- instrumentData: { ...runnerEx.instrumentData },
2610
- iteration: runnerEx.iteration,
2611
- state: runnerEx.state
2612
- };
2613
- };
2614
2620
  _SetRunnerIntoWorker = new WeakMap();
2615
2621
  _ProcessTelemetry = new WeakMap();
2616
2622
  _EmitEvent = new WeakMap();