@nsshunt/stsrunnerframework 1.0.70 → 1.0.72

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.
@@ -13,7 +13,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
13
13
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
14
14
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
15
15
 
16
- var _collectorCollectorPort, _runners, _options, _workerId, _debug, _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, _debug2, _STSWorkerManager_instances, CreateRunnerCopy_fn, _SetRunnerIntoWorker, _ProcessTelemetry, _EmitEvent, _RunnerStateChange, _ProcessCompleted, _CreateAsyncRunner, _PostMessageToWorkerUsingDefaultChannel, _PostMessageToWorker, _StartRunner2, _ResetRunner2, _ExecuteRunner2, _StopRunner2, _TerminateRunner2, _PauseRunner2, _ResumeRunner2, _BroadcastCommandToAllRunners, _PauseWorker, _ResumeWorker, _StopWorker, _StartWorker, _ResetWorker, _ExecuteWorker, _BroadcastUpdateCommandToAllRunners, _UpdateOptionsWorker, _TerminateWorker, _UpdateOptions2;
16
+ 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;
17
17
  const URI_BASE_VUEUTILS = "/";
18
18
  const STS_RF_RES_PREFIX = "STS_R_RF_";
19
19
  const STS_RF_RES_ENT_PREFIX = "STS_RE_RF_";
@@ -29,10 +29,11 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
29
29
  eIWMessageCommands2["ResumeRunner"] = "__STS__ResumeRunner";
30
30
  eIWMessageCommands2["ResetRunner"] = "__STS__ResetRunner";
31
31
  eIWMessageCommands2["ExecuteRunner"] = "__STS__ExecuteRunner";
32
- eIWMessageCommands2["Completed"] = "__STS__Completed";
32
+ eIWMessageCommands2["CompletedZZ"] = "__STS__Completed";
33
33
  eIWMessageCommands2["UpdateOptions"] = "__STS__UpdateOptions";
34
34
  eIWMessageCommands2["TerminateRunner"] = "__STS__TerminateRunner";
35
35
  eIWMessageCommands2["RunnerStateChange"] = "__STS__RunnerStateChange";
36
+ eIWMessageCommands2["RemoveRunnerFromCollection"] = "__STS__RemoveRunnerFromCollection";
36
37
  return eIWMessageCommands2;
37
38
  })(eIWMessageCommands || {});
38
39
  var IRunnerState = /* @__PURE__ */ ((IRunnerState2) => {
@@ -1526,9 +1527,39 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
1526
1527
  __privateAdd(this, _workerId, null);
1527
1528
  __privateAdd(this, _debug, (message) => {
1528
1529
  if (__privateGet(this, _options)) {
1529
- console.log(chalk.green(`pid: [${process.pid}] ${__privateGet(this, _workerId)} WorkerInstance::${message}`));
1530
+ stsutils.defaultLogger.debug(chalk.green(`pid: [${process.pid}] ${__privateGet(this, _workerId)} WorkerInstance:${message}`));
1530
1531
  } else {
1531
- console.log(chalk.green(`pid: [${process.pid}] WorkerInstance::${message}`));
1532
+ stsutils.defaultLogger.debug(chalk.green(`pid: [${process.pid}] WorkerInstance:${message}`));
1533
+ }
1534
+ });
1535
+ __privateAdd(this, _error, (error) => {
1536
+ if (__privateGet(this, _options)) {
1537
+ stsutils.defaultLogger.error(chalk.red(`pid: [${process.pid}] ${__privateGet(this, _workerId)} WorkerInstance:${error}`));
1538
+ } else {
1539
+ stsutils.defaultLogger.error(chalk.red(`pid: [${process.pid}] WorkerInstance:${error}`));
1540
+ }
1541
+ });
1542
+ __privateAdd(this, _processLoopExecutor, async () => {
1543
+ const removeList = [];
1544
+ const promArray = [];
1545
+ for (const [, runner] of Object.entries(__privateGet(this, _runners))) {
1546
+ if (runner.runner.state === IRunnerState.completed || runner.runner.state === IRunnerState.error || runner.runner.state === IRunnerState.stopped || runner.runner.state === IRunnerState.terminated) {
1547
+ promArray.push(__privateGet(this, _PostMessageToWorkerManagerById).call(this, eIWMessageCommands.RemoveRunnerFromCollection, runner.runner.id));
1548
+ removeList.push(runner.runner.id);
1549
+ }
1550
+ }
1551
+ if (promArray.length > 0) {
1552
+ await Promise.all(promArray);
1553
+ setTimeout(() => {
1554
+ __privateGet(this, _debug).call(this, chalk.grey(`WorkerInstance:#processLoopExecutor(): Removing runners from collection: [${removeList}]`));
1555
+ for (let i = 0; i < removeList.length; i++) {
1556
+ delete __privateGet(this, _runners)[removeList[i]];
1557
+ }
1558
+ __privateGet(this, _debug).call(this, chalk.grey(`WorkerInstance:#processLoopExecutor(): Remaining Runner Count: [${Object.keys(__privateGet(this, _runners)).length}]`));
1559
+ setTimeout(__privateGet(this, _processLoopExecutor), 1e3);
1560
+ }, 100);
1561
+ } else {
1562
+ setTimeout(__privateGet(this, _processLoopExecutor), 1e3);
1532
1563
  }
1533
1564
  });
1534
1565
  __publicField(this, "GetRandomInt", (max) => {
@@ -1551,7 +1582,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
1551
1582
  });
1552
1583
  } else {
1553
1584
  __privateGet(this, _collectorCollectorPort).onmessage = function(data) {
1554
- console.log(`collectorCollectorPort onmessage: ${JSON.stringify(data.data)}`);
1585
+ __privateGet(this, _debug).call(this, `collectorCollectorPort onmessage: ${JSON.stringify(data.data)}`);
1555
1586
  };
1556
1587
  }
1557
1588
  const response = {
@@ -1563,13 +1594,13 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
1563
1594
  __publicField(this, "CreateAsyncRunner", (testRunnerTelemetryPayload) => {
1564
1595
  return null;
1565
1596
  });
1566
- __privateAdd(this, _CreateRunnerEx2RunState, (runner, runnerInstance) => {
1597
+ __privateAdd(this, _CreateRunnerEx2RunState, async (runner, runnerInstance) => {
1567
1598
  __privateGet(this, _runners)[runner.id] = {
1568
1599
  runner,
1569
1600
  runnerInstance
1570
1601
  };
1571
- __privateGet(this, _runners)[runner.id].runner.state = IRunnerState.created;
1572
1602
  __privateGet(this, _runners)[runner.id].runner.iteration = 0;
1603
+ __privateGet(this, _UpdateRunnerStateById).call(this, runner.id, IRunnerState.created);
1573
1604
  });
1574
1605
  __privateAdd(this, _UpdateRunnerStateById, (id, state) => {
1575
1606
  __privateGet(this, _runners)[id].runner.state = state;
@@ -1625,15 +1656,18 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
1625
1656
  }
1626
1657
  return runner;
1627
1658
  });
1628
- __privateAdd(this, _PostMessageToWorkerManagerById, (command, id) => {
1659
+ __privateAdd(this, _PostMessageToWorkerManagerById, async (command, id) => {
1629
1660
  if (__privateGet(this, _collectorCollectorPort)) {
1630
- const message = {
1631
- command,
1632
- payload: {
1633
- runner: __privateGet(this, _runners)[id].runner
1634
- }
1635
- };
1636
- __privateGet(this, _collectorCollectorPort).postMessage(message);
1661
+ if (__privateGet(this, _runners)[id]) {
1662
+ const message = {
1663
+ command,
1664
+ payload: {
1665
+ runner: __privateGet(this, _runners)[id].runner
1666
+ }
1667
+ };
1668
+ __privateGet(this, _collectorCollectorPort).postMessage(message);
1669
+ await stsutils.Sleep(0);
1670
+ }
1637
1671
  }
1638
1672
  });
1639
1673
  __privateAdd(this, _StartRunner, async (testRunnerTelemetryPayload) => {
@@ -1641,15 +1675,23 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
1641
1675
  __privateGet(this, _debug).call(this, `${chalk.magenta(`runner: [${runnerId}]`)} StartRunner`);
1642
1676
  await __privateGet(this, _GetRunnerInstanceById).call(this, runnerId).StartRunner();
1643
1677
  __privateGet(this, _UpdateRunnerStateById).call(this, runnerId, IRunnerState.running);
1678
+ const startLoop = /* @__PURE__ */ new Date();
1644
1679
  const ExecuteLoop = async () => {
1645
- if (__privateGet(this, _GetRunnerIterationById).call(this, runnerId) < __privateGet(this, _GetRunnerExecutionProfileById).call(this, runnerId).iterations) {
1680
+ let cont = true;
1681
+ const { iterations, duration, delayBetweenIterations } = __privateGet(this, _GetRunnerExecutionProfileById).call(this, runnerId);
1682
+ if (iterations > 0) {
1683
+ cont = __privateGet(this, _GetRunnerIterationById).call(this, runnerId) < iterations;
1684
+ } else if (duration > 0) {
1685
+ cont = ((/* @__PURE__ */ new Date()).getTime() - startLoop.getTime()) / 1e3 < duration;
1686
+ }
1687
+ if (cont) {
1646
1688
  if (__privateGet(this, _CanExecuteNextIterationById).call(this, runnerId)) {
1647
1689
  await __privateGet(this, _GetRunnerInstanceById).call(this, runnerId).Execute(__privateGet(this, _GetRunnerIterationById).call(this, runnerId));
1648
1690
  __privateGet(this, _IncRunnerIterationById).call(this, runnerId);
1649
1691
  }
1650
1692
  if (__privateGet(this, _CanExecuteNextIterationById).call(this, runnerId)) {
1651
- if (__privateGet(this, _GetRunnerExecutionProfileById).call(this, runnerId).delayBetweenIterations > 0) {
1652
- await stsutils.Sleep(__privateGet(this, _GetRunnerExecutionProfileById).call(this, runnerId).delayBetweenIterations);
1693
+ if (delayBetweenIterations > 0) {
1694
+ await stsutils.Sleep(delayBetweenIterations);
1653
1695
  } else {
1654
1696
  await __privateMethod(this, _WorkerInstance_instances, SleepImmediate_fn).call(this);
1655
1697
  }
@@ -1663,7 +1705,6 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
1663
1705
  } else {
1664
1706
  await __privateGet(this, _GetRunnerInstanceById).call(this, runnerId).Completed();
1665
1707
  __privateGet(this, _UpdateRunnerStateById).call(this, runnerId, IRunnerState.completed);
1666
- __privateGet(this, _PostMessageToWorkerManagerById).call(this, eIWMessageCommands.Completed, runnerId);
1667
1708
  }
1668
1709
  };
1669
1710
  ExecuteLoop();
@@ -1671,8 +1712,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
1671
1712
  __privateAdd(this, _StopRunnerByRunnerById, async (id) => {
1672
1713
  __privateGet(this, _debug).call(this, `${chalk.magenta(`runner: [${id}]`)} StopRunner`);
1673
1714
  await __privateGet(this, _GetRunnerInstanceById).call(this, id).StopRunner();
1674
- __privateGet(this, _UpdateRunnerStateById).call(this, id, IRunnerState.stopped);
1675
- await stsutils.Sleep(0);
1715
+ await __privateGet(this, _UpdateRunnerStateById).call(this, id, IRunnerState.stopped);
1676
1716
  });
1677
1717
  __privateAdd(this, _StopAllRunners, async (testRunnerTelemetryPayload) => {
1678
1718
  __privateGet(this, _debug).call(this, `StopAllRunners`);
@@ -1690,31 +1730,27 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
1690
1730
  const runnerId = testRunnerTelemetryPayload.runner.id;
1691
1731
  __privateGet(this, _debug).call(this, `${chalk.magenta(`runner: [${runnerId}]`)} TerminateRunner`);
1692
1732
  const retVal = await __privateGet(this, _GetRunnerInstanceById).call(this, runnerId).TerminateRunner();
1693
- __privateGet(this, _UpdateRunnerStateById).call(this, runnerId, IRunnerState.terminated);
1733
+ await __privateGet(this, _UpdateRunnerStateById).call(this, runnerId, IRunnerState.terminated);
1694
1734
  __privateGet(this, _debug).call(this, `${chalk.magenta(`runner: [${runnerId}]`)} TerminateRunner Result = [${retVal}]`);
1695
- await stsutils.Sleep(0);
1696
1735
  });
1697
1736
  __privateAdd(this, _PauseRunner, async (testRunnerTelemetryPayload) => {
1698
1737
  const runnerId = testRunnerTelemetryPayload.runner.id;
1699
1738
  __privateGet(this, _debug).call(this, `${chalk.magenta(`runner: [${runnerId}]`)} PauseRunner`);
1700
1739
  await __privateGet(this, _GetRunnerInstanceById).call(this, runnerId).PauseRunner();
1701
- __privateGet(this, _UpdateRunnerStateById).call(this, runnerId, IRunnerState.paused);
1702
- await stsutils.Sleep(0);
1740
+ await __privateGet(this, _UpdateRunnerStateById).call(this, runnerId, IRunnerState.paused);
1703
1741
  });
1704
1742
  __privateAdd(this, _ResumeRunner, async (testRunnerTelemetryPayload) => {
1705
1743
  const runnerId = testRunnerTelemetryPayload.runner.id;
1706
1744
  __privateGet(this, _debug).call(this, `${chalk.magenta(`runner: [${runnerId}]`)} ResumeRunner`);
1707
1745
  await __privateGet(this, _GetRunnerInstanceById).call(this, runnerId).ResumeRunner();
1708
- __privateGet(this, _UpdateRunnerStateById).call(this, runnerId, IRunnerState.running);
1709
- await stsutils.Sleep(0);
1746
+ await __privateGet(this, _UpdateRunnerStateById).call(this, runnerId, IRunnerState.running);
1710
1747
  });
1711
1748
  __privateAdd(this, _ResetRunner, async (testRunnerTelemetryPayload) => {
1712
1749
  const runnerId = testRunnerTelemetryPayload.runner.id;
1713
1750
  __privateGet(this, _debug).call(this, `${chalk.magenta(`runner: [${runnerId}]`)} ResetRunner`);
1714
1751
  __privateGet(this, _ResetRunnerIterationById).call(this, runnerId);
1715
1752
  await __privateGet(this, _GetRunnerInstanceById).call(this, runnerId).ResetRunner();
1716
- __privateGet(this, _UpdateRunnerStateById).call(this, runnerId, IRunnerState.paused);
1717
- await stsutils.Sleep(0);
1753
+ await __privateGet(this, _UpdateRunnerStateById).call(this, runnerId, IRunnerState.paused);
1718
1754
  });
1719
1755
  // Execute a single iteration of this runners work item
1720
1756
  __privateAdd(this, _ExecuteRunner, async (testRunnerTelemetryPayload) => {
@@ -1722,15 +1758,14 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
1722
1758
  __privateGet(this, _debug).call(this, `${chalk.magenta(`runner: [${runnerId}]`)} ExecuteRunner`);
1723
1759
  await __privateGet(this, _GetRunnerInstanceById).call(this, runnerId).Execute(__privateGet(this, _GetRunnerIterationById).call(this, runnerId));
1724
1760
  __privateGet(this, _IncRunnerIterationById).call(this, runnerId);
1725
- __privateGet(this, _UpdateRunnerStateById).call(this, runnerId, IRunnerState.paused);
1726
- await stsutils.Sleep(0);
1761
+ await __privateGet(this, _UpdateRunnerStateById).call(this, runnerId, IRunnerState.paused);
1727
1762
  });
1728
1763
  __privateAdd(this, _UpdateOptions, async (testRunnerTelemetryPayload) => {
1729
1764
  const runnerId = testRunnerTelemetryPayload.runner.id;
1730
1765
  __privateGet(this, _debug).call(this, `${chalk.magenta(`runner: [${runnerId}]`)} UpdateOptions`);
1731
- console.log(chalk.cyan(`before: [${JSON.stringify(__privateGet(this, _GetRunnerOptionsById).call(this, runnerId))}]`));
1766
+ __privateGet(this, _debug).call(this, chalk.cyan(`before: [${JSON.stringify(__privateGet(this, _GetRunnerOptionsById).call(this, runnerId))}]`));
1732
1767
  __privateGet(this, _SetRunnerOptionsById).call(this, runnerId, testRunnerTelemetryPayload.runner.options);
1733
- console.log(chalk.cyan(`after: [${JSON.stringify(__privateGet(this, _GetRunnerOptionsById).call(this, runnerId))}]`));
1768
+ __privateGet(this, _debug).call(this, chalk.cyan(`after: [${JSON.stringify(__privateGet(this, _GetRunnerOptionsById).call(this, runnerId))}]`));
1734
1769
  await __privateGet(this, _GetRunnerInstanceById).call(this, runnerId).UpdateOptions();
1735
1770
  await stsutils.Sleep(0);
1736
1771
  });
@@ -1791,10 +1826,11 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
1791
1826
  __privateGet(this, _debug).call(this, `Invalid payloadMessage.command: [${payloadMessage.command}] - Ignoring`);
1792
1827
  }
1793
1828
  } catch (error) {
1794
- console.log(error);
1829
+ __privateGet(this, _error).call(this, error);
1795
1830
  }
1796
1831
  });
1797
1832
  __privateGet(this, _debug).call(this, `constructor`);
1833
+ __privateGet(this, _processLoopExecutor).call(this);
1798
1834
  }
1799
1835
  get CollectorCollectorPort() {
1800
1836
  return __privateGet(this, _collectorCollectorPort);
@@ -1808,6 +1844,8 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
1808
1844
  _options = new WeakMap();
1809
1845
  _workerId = new WeakMap();
1810
1846
  _debug = new WeakMap();
1847
+ _error = new WeakMap();
1848
+ _processLoopExecutor = new WeakMap();
1811
1849
  _SetMessagePort = new WeakMap();
1812
1850
  _CreateRunnerEx2RunState = new WeakMap();
1813
1851
  _UpdateRunnerStateById = new WeakMap();
@@ -1989,6 +2027,60 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
1989
2027
  __privateAdd(this, _options2);
1990
2028
  __privateAdd(this, _STSInstrumentController, null);
1991
2029
  __privateAdd(this, _telemetryProcessor, null);
2030
+ __privateAdd(this, _archiveList, []);
2031
+ __privateAdd(this, _processLoopExecutor2, async () => {
2032
+ const removeList = [];
2033
+ for (const [, workerEx] of Object.entries(__privateGet(this, _workersEx))) {
2034
+ for (const [, runnerEx] of Object.entries(workerEx.runnersEx)) {
2035
+ const runnerState = runnerEx.state;
2036
+ if (runnerState === IRunnerState.completed || runnerState === IRunnerState.error || runnerState === IRunnerState.stopped || runnerState === IRunnerState.terminated) {
2037
+ removeList.push({
2038
+ workerId: workerEx.id,
2039
+ runnerId: runnerEx.id
2040
+ });
2041
+ }
2042
+ }
2043
+ }
2044
+ if (removeList.length > 0) {
2045
+ setTimeout(async () => {
2046
+ __privateGet(this, _debug2).call(this, chalk.grey(`STSWorkerManager:#processLoopExecutor(): Removing runners from collection: [${JSON.stringify(removeList)}]`));
2047
+ for (let i = 0; i < removeList.length; i++) {
2048
+ const workerEx = __privateGet(this, _workersEx)[removeList[i].workerId];
2049
+ if (workerEx) {
2050
+ const runnerEx = workerEx.runnersEx[removeList[i].runnerId];
2051
+ if (runnerEx) {
2052
+ if (runnerEx.publishInstrumentController) {
2053
+ __privateGet(this, _debug2).call(this, chalk.grey(`Ending publish for runner: [${JSON.stringify(runnerEx.asyncRunnerContext)}]`));
2054
+ await runnerEx.publishInstrumentController.EndPublish();
2055
+ await stsutils.Sleep(250);
2056
+ }
2057
+ const runner = {
2058
+ id: runnerEx.id,
2059
+ asyncRunnerContext: { ...runnerEx.asyncRunnerContext },
2060
+ instrumentData: { ...runnerEx.instrumentData },
2061
+ iteration: runnerEx.iteration,
2062
+ options: { ...runnerEx.options },
2063
+ runnerHistory: [...runnerEx.runnerHistory],
2064
+ state: runnerEx.state,
2065
+ workerId: runnerEx.workerId
2066
+ };
2067
+ __privateGet(this, _archiveList).push(runner);
2068
+ if (__privateGet(this, _archiveList).length > __privateGet(this, _options2).maxArchiveListLength) {
2069
+ __privateGet(this, _archiveList).shift();
2070
+ }
2071
+ delete workerEx.runnersEx[removeList[i].runnerId];
2072
+ }
2073
+ }
2074
+ }
2075
+ for (const [, workerEx] of Object.entries(__privateGet(this, _workersEx))) {
2076
+ __privateGet(this, _debug2).call(this, chalk.grey(`STSWorkerManager:#processLoopExecutor(): Remaining runners from worker: [${workerEx.id}]: [${Object.keys(workerEx.runnersEx).length}]`));
2077
+ }
2078
+ setTimeout(__privateGet(this, _processLoopExecutor2), 1e3);
2079
+ }, 100);
2080
+ } else {
2081
+ setTimeout(__privateGet(this, _processLoopExecutor2), 1e3);
2082
+ }
2083
+ });
1992
2084
  __privateAdd(this, _debug2, (message) => {
1993
2085
  console.log(chalk.cyan(`pid: [${process.pid}] STSWorkerManager::${message}`));
1994
2086
  });
@@ -2087,14 +2179,22 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
2087
2179
  case eIWMessageCommands.InstrumentTelemetry:
2088
2180
  __privateGet(this, _ProcessTelemetry).call(this, stsWorkerEx, publishMessagePayload2.payload);
2089
2181
  break;
2090
- case eIWMessageCommands.Completed:
2091
- __privateGet(this, _ProcessCompleted).call(this, stsWorkerEx, publishMessagePayload2.payload);
2092
- break;
2182
+ /*
2183
+ case eIWMessageCommands.Completed :
2184
+ //this.#debug(`AddWorker::eIWMessageCommands.InstrumentTelemetry`);
2185
+ this.#ProcessCompleted(stsWorkerEx, publishMessagePayload.payload as ITestRunnerTelemetryPayload);
2186
+ break;
2187
+ */
2093
2188
  case eIWMessageCommands.RunnerStateChange:
2094
2189
  __privateGet(this, _RunnerStateChange).call(this, stsWorkerEx, publishMessagePayload2.payload);
2095
2190
  break;
2191
+ case eIWMessageCommands.RemoveRunnerFromCollection:
2192
+ __privateGet(this, _debug2).call(this, `AddWorker:processMessage():eIWMessageCommands.RemoveRunnerFromCollection`);
2193
+ __privateGet(this, _debug2).call(this, `${JSON.stringify(publishMessagePayload2.payload)}`);
2194
+ __privateGet(this, _RemoveRunnerFromCollection).call(this, stsWorkerEx, publishMessagePayload2.payload);
2195
+ break;
2096
2196
  default:
2097
- __privateGet(this, _debug2).call(this, `AddWorker::default`);
2197
+ __privateGet(this, _debug2).call(this, `processMessage::default`);
2098
2198
  }
2099
2199
  };
2100
2200
  let publishMessagePayload;
@@ -2162,14 +2262,23 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
2162
2262
  if (workerEx.runnersEx[runner.id]) {
2163
2263
  const runnerEx = workerEx.runnersEx[runner.id];
2164
2264
  runnerEx.state = runner.state;
2265
+ runnerEx.runnerHistory.push({
2266
+ eventDate: /* @__PURE__ */ new Date(),
2267
+ runner: { ...runner }
2268
+ });
2165
2269
  __privateGet(this, _EmitEvent).call(this, "StateChange", workerEx, runner.id);
2166
2270
  }
2167
2271
  });
2168
- __privateAdd(this, _ProcessCompleted, (workerEx, payloadContents) => {
2169
- const { runner } = payloadContents;
2170
- __privateGet(this, _EmitEvent).call(this, "Completed", workerEx, runner.id);
2171
- console.log(chalk.green(`ProcessCompleted: [${JSON.stringify(runner)}]`));
2272
+ __privateAdd(this, _RemoveRunnerFromCollection, (workerEx, payloadContents) => {
2273
+ __privateGet(this, _debug2).call(this, `STSWorkerManager:#RemoveRunnerFromCollection(): Worker: [${workerEx.id}] Runner to archive: [${JSON.stringify(payloadContents)}]`);
2172
2274
  });
2275
+ /*
2276
+ #ProcessCompleted = (workerEx: IWorkerEx, payloadContents: ITestRunnerTelemetryPayload): void => {
2277
+ const { runner } = payloadContents;
2278
+ this.#EmitEvent('Completed', workerEx, runner.id);
2279
+ console.log(chalk.green(`ProcessCompleted: [${JSON.stringify(runner)}]`));
2280
+ }
2281
+ */
2173
2282
  __privateAdd(this, _CreateAsyncRunner, (workerEx, runnerOptions) => {
2174
2283
  const runnerId = v4();
2175
2284
  if (__privateGet(this, _STSInstrumentController)) {
@@ -2196,6 +2305,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
2196
2305
  publishInstrumentController: __privateGet(this, _STSInstrumentController) ? __privateGet(this, _STSInstrumentController).AddPublishInstrumentController(asyncRunnerContext) : void 0,
2197
2306
  asyncRunnerContext,
2198
2307
  options: runnerOptions,
2308
+ runnerHistory: [],
2199
2309
  instrumentData: {
2200
2310
  requestCount: 0,
2201
2311
  errorCount: 0,
@@ -2253,63 +2363,31 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
2253
2363
  __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.StartRunner, {
2254
2364
  runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopy_fn).call(this, runnerEx)
2255
2365
  });
2256
- runnerEx.state = IRunnerState.running;
2257
2366
  return true;
2258
2367
  });
2259
2368
  __privateAdd(this, _ResetRunner2, async (workerEx, runnerEx) => {
2260
2369
  __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.ResetRunner, {
2261
2370
  runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopy_fn).call(this, runnerEx)
2262
2371
  });
2263
- runnerEx.state = IRunnerState.paused;
2264
2372
  return true;
2265
2373
  });
2266
2374
  __privateAdd(this, _ExecuteRunner2, async (workerEx, runnerEx) => {
2267
2375
  __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.ExecuteRunner, {
2268
2376
  runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopy_fn).call(this, runnerEx)
2269
2377
  });
2270
- runnerEx.state = IRunnerState.paused;
2271
2378
  return true;
2272
2379
  });
2273
2380
  __privateAdd(this, _StopRunner2, async (workerEx, runnerEx) => {
2274
2381
  __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.StopRunner, {
2275
2382
  runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopy_fn).call(this, runnerEx)
2276
2383
  });
2277
- runnerEx.state = IRunnerState.terminated;
2278
2384
  return true;
2279
2385
  });
2280
- __privateAdd(this, _TerminateRunner2, async (workerEx, runnerEx = null) => {
2281
- return new Promise((resolve, reject) => {
2282
- if (runnerEx === null) {
2283
- const ids = Object.keys(workerEx.runnersEx);
2284
- if (ids.length > 0) {
2285
- const id = ids[0];
2286
- runnerEx = workerEx.runnersEx[id];
2287
- }
2288
- }
2289
- if (runnerEx !== null) {
2290
- (async () => {
2291
- console.log(chalk.magenta(`Sending message to terminate runner: [${JSON.stringify(runnerEx.asyncRunnerContext)}]`));
2292
- __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.TerminateRunner, {
2293
- runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopy_fn).call(this, runnerEx)
2294
- });
2295
- if (runnerEx.publishInstrumentController) {
2296
- runnerEx.publishInstrumentController.LogEx(`Terminating runner: [${runnerEx.id}]`);
2297
- }
2298
- await stsutils.Sleep(250);
2299
- console.log(chalk.magenta(`Ending publish for runner: [${JSON.stringify(runnerEx.asyncRunnerContext)}]`));
2300
- if (runnerEx.publishInstrumentController) {
2301
- await runnerEx.publishInstrumentController.EndPublish();
2302
- await stsutils.Sleep(250);
2303
- }
2304
- delete workerEx.runnersEx[runnerEx.id];
2305
- console.log(chalk.magenta(`Completed Terminate for runner: [${JSON.stringify(runnerEx.asyncRunnerContext)}]`));
2306
- resolve(true);
2307
- })();
2308
- } else {
2309
- console.log(chalk.magenta(`No runner to terminate.`));
2310
- resolve(false);
2311
- }
2386
+ __privateAdd(this, _TerminateRunner2, async (workerEx, runnerEx) => {
2387
+ __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.TerminateRunner, {
2388
+ runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopy_fn).call(this, runnerEx)
2312
2389
  });
2390
+ return true;
2313
2391
  });
2314
2392
  __privateAdd(this, _PauseRunner2, async (workerEx, runnerEx) => {
2315
2393
  __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.PauseRunner, {
@@ -2502,10 +2580,14 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
2502
2580
  __privateSet(this, _STSInstrumentController, __privateGet(this, _options2).publishInstrumentController);
2503
2581
  __privateSet(this, _telemetryProcessor, new TelemetryProcessor());
2504
2582
  }
2583
+ __privateGet(this, _processLoopExecutor2).call(this);
2505
2584
  }
2506
2585
  get WorkersEx() {
2507
2586
  return __privateGet(this, _workersEx);
2508
2587
  }
2588
+ get archiveList() {
2589
+ return __privateGet(this, _archiveList);
2590
+ }
2509
2591
  get Options() {
2510
2592
  return __privateGet(this, _options2);
2511
2593
  }
@@ -2517,6 +2599,8 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
2517
2599
  _options2 = new WeakMap();
2518
2600
  _STSInstrumentController = new WeakMap();
2519
2601
  _telemetryProcessor = new WeakMap();
2602
+ _archiveList = new WeakMap();
2603
+ _processLoopExecutor2 = new WeakMap();
2520
2604
  _debug2 = new WeakMap();
2521
2605
  _STSWorkerManager_instances = new WeakSet();
2522
2606
  CreateRunnerCopy_fn = function(runnerEx) {
@@ -2533,7 +2617,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
2533
2617
  _ProcessTelemetry = new WeakMap();
2534
2618
  _EmitEvent = new WeakMap();
2535
2619
  _RunnerStateChange = new WeakMap();
2536
- _ProcessCompleted = new WeakMap();
2620
+ _RemoveRunnerFromCollection = new WeakMap();
2537
2621
  _CreateAsyncRunner = new WeakMap();
2538
2622
  _PostMessageToWorkerUsingDefaultChannel = new WeakMap();
2539
2623
  _PostMessageToWorker = new WeakMap();