@nsshunt/stsrunnerframework 1.0.198 → 1.0.199

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.
@@ -1598,7 +1598,7 @@ class WorkerInstance {
1598
1598
  return Math.floor(Math.random() * Math.floor(max));
1599
1599
  };
1600
1600
  PostTelemetryById = (id) => {
1601
- this.#PostMessageToWorkerManagerById(eIWMessageCommands.InstrumentTelemetry, id, false);
1601
+ this.#PostMessageToWorkerManagerByRunnerId(eIWMessageCommands.InstrumentTelemetry, id, false);
1602
1602
  };
1603
1603
  get CollectorCollectorPort() {
1604
1604
  return this.#collectorCollectorPort;
@@ -1638,145 +1638,145 @@ class WorkerInstance {
1638
1638
  archived: false
1639
1639
  };
1640
1640
  this.#runners[runner.id].runner.iteration = 0;
1641
- this.#UpdateRunnerStateById("#CreateRunnerEx2RunState", runner.id, IRunnerState.created);
1641
+ this.#UpdateRunnerStateByRunnerId("#CreateRunnerEx2RunState", runner.id, IRunnerState.created);
1642
1642
  } catch (error) {
1643
1643
  this.#error(`#CreateRunnerEx2RunState(): [${error}]`);
1644
1644
  }
1645
1645
  };
1646
- #UpdateRunnerStateById = (fromContext, id, state) => {
1646
+ #UpdateRunnerStateByRunnerId = (fromContext, runnerId, state) => {
1647
1647
  try {
1648
- if (this.#runners[id]) {
1649
- const previousState = this.#runners[id].runner.state;
1650
- this.#runners[id].runner.state = state;
1651
- this.#debug(`#UpdateRunnerStateById(): Context: [${fromContext}] Previous State: [${previousState}] New State: [${state}]`);
1652
- this.#PostMessageToWorkerManagerById(eIWMessageCommands.RunnerStateChange, id, false);
1648
+ if (this.#runners[runnerId]) {
1649
+ const previousState = this.#runners[runnerId].runner.state;
1650
+ this.#runners[runnerId].runner.state = state;
1651
+ this.#debug(`#UpdateRunnerStateByRunnerId(): Context: [${fromContext}] Previous State: [${previousState}] New State: [${state}]`);
1652
+ this.#PostMessageToWorkerManagerByRunnerId(eIWMessageCommands.RunnerStateChange, runnerId, false);
1653
1653
  } else {
1654
- this.#warn(`#UpdateRunnerStateById(): Runner ID: [${id}] not found`);
1654
+ this.#warn(`#UpdateRunnerStateByRunnerId(): Runner ID: [${runnerId}] not found`);
1655
1655
  }
1656
1656
  } catch (error) {
1657
- this.#error(`#UpdateRunnerStateById(): [${error}]`);
1657
+ this.#error(`#UpdateRunnerStateByRunnerId(): [${error}]`);
1658
1658
  }
1659
1659
  };
1660
1660
  // If an error occurs or the runner does not exist, treat as cannot execute next iteration
1661
- #CanExecuteNextIterationById = (id) => {
1661
+ #CanExecuteNextIterationByRunnerId = (runnerId) => {
1662
1662
  try {
1663
- if (this.#runners[id]) {
1664
- const state = this.#runners[id].runner.state;
1663
+ if (this.#runners[runnerId]) {
1664
+ const state = this.#runners[runnerId].runner.state;
1665
1665
  if (state === IRunnerState.running) {
1666
1666
  return true;
1667
1667
  }
1668
1668
  return false;
1669
1669
  } else {
1670
- this.#warn(`#CanExecuteNextIterationById(): Runner ID: [${id}] not found`);
1670
+ this.#warn(`#CanExecuteNextIterationByRunnerId(): Runner ID: [${runnerId}] not found`);
1671
1671
  return false;
1672
1672
  }
1673
1673
  } catch (error) {
1674
- this.#error(`#CanExecuteNextIterationById(): [${error}]`);
1674
+ this.#error(`#CanExecuteNextIterationByRunnerId(): [${error}]`);
1675
1675
  return false;
1676
1676
  }
1677
1677
  };
1678
1678
  // If an error occurs or the runner does not exist, treat as completed.
1679
- #IsCompletedById = (id) => {
1679
+ #IsCompletedByRunnerId = (runnerId) => {
1680
1680
  try {
1681
- if (this.#runners[id]) {
1682
- const state = this.#runners[id].runner.state;
1681
+ if (this.#runners[runnerId]) {
1682
+ const state = this.#runners[runnerId].runner.state;
1683
1683
  if (state === IRunnerState.error || state === IRunnerState.completed || state === IRunnerState.stopped || state === IRunnerState.terminated) {
1684
1684
  return true;
1685
1685
  }
1686
1686
  return false;
1687
1687
  } else {
1688
- this.#warn(`#IsCompletedById(): Runner ID: [${id}] not found`);
1688
+ this.#warn(`#IsCompletedByRunnerId(): Runner ID: [${runnerId}] not found`);
1689
1689
  return true;
1690
1690
  }
1691
1691
  } catch (error) {
1692
- this.#error(`#IsCompletedById(): [${error}]`);
1692
+ this.#error(`#IsCompletedByRunnerId(): [${error}]`);
1693
1693
  return true;
1694
1694
  }
1695
1695
  };
1696
- #GetRunnerIterationById = (id) => {
1696
+ #GetRunnerIterationByRunnerId = (runnerId) => {
1697
1697
  try {
1698
- if (this.#runners[id]) {
1699
- return this.#runners[id].runner.iteration;
1698
+ if (this.#runners[runnerId]) {
1699
+ return this.#runners[runnerId].runner.iteration;
1700
1700
  } else {
1701
- this.#warn(`#GetRunnerIterationById(): Runner ID: [${id}] not found`);
1701
+ this.#warn(`#GetRunnerIterationByRunnerId(): Runner ID: [${runnerId}] not found`);
1702
1702
  return 0;
1703
1703
  }
1704
1704
  } catch (error) {
1705
- this.#error(`#GetRunnerIterationById(): [${error}]`);
1705
+ this.#error(`#GetRunnerIterationByRunnerId(): [${error}]`);
1706
1706
  return 0;
1707
1707
  }
1708
1708
  };
1709
- #ResetRunnerIterationById = (id) => {
1709
+ #ResetRunnerIterationByRunnerId = (runnerId) => {
1710
1710
  try {
1711
- if (this.#runners[id]) {
1712
- this.#runners[id].runner.iteration = 0;
1711
+ if (this.#runners[runnerId]) {
1712
+ this.#runners[runnerId].runner.iteration = 0;
1713
1713
  return 0;
1714
1714
  } else {
1715
- this.#warn(`#ResetRunnerIterationById(): Runner ID: [${id}] not found`);
1715
+ this.#warn(`#ResetRunnerIterationByRunnerId(): Runner ID: [${runnerId}] not found`);
1716
1716
  return 0;
1717
1717
  }
1718
1718
  } catch (error) {
1719
- this.#error(`#ResetRunnerIterationById(): [${error}]`);
1719
+ this.#error(`#ResetRunnerIterationByRunnerId(): [${error}]`);
1720
1720
  return 0;
1721
1721
  }
1722
1722
  };
1723
- #IncRunnerIterationById = (id) => {
1723
+ #IncRunnerIterationByRunnerId = (runnerId) => {
1724
1724
  try {
1725
- if (this.#runners[id]) {
1726
- this.#runners[id].runner.iteration++;
1727
- return this.#runners[id].runner.iteration;
1725
+ if (this.#runners[runnerId]) {
1726
+ this.#runners[runnerId].runner.iteration++;
1727
+ return this.#runners[runnerId].runner.iteration;
1728
1728
  } else {
1729
- this.#warn(`#IncRunnerIterationById(): Runner ID: [${id}] not found`);
1729
+ this.#warn(`#IncRunnerIterationByRunnerId(): Runner ID: [${runnerId}] not found`);
1730
1730
  return 0;
1731
1731
  }
1732
1732
  } catch (error) {
1733
- this.#error(`#IncRunnerIterationById(): [${error}]`);
1733
+ this.#error(`#IncRunnerIterationByRunnerId(): [${error}]`);
1734
1734
  return 0;
1735
1735
  }
1736
1736
  };
1737
- #GetRunnerInstanceById = (id) => {
1737
+ #GetRunnerInstanceByRunnerId = (runnerId) => {
1738
1738
  try {
1739
- if (this.#runners[id]) {
1740
- return this.#runners[id].runnerInstance;
1739
+ if (this.#runners[runnerId]) {
1740
+ return this.#runners[runnerId].runnerInstance;
1741
1741
  } else {
1742
- this.#warn(`#GetRunnerInstanceById(): Runner ID: [${id}] not found`);
1742
+ this.#warn(`#GetRunnerInstanceByRunnerId(): Runner ID: [${runnerId}] not found`);
1743
1743
  }
1744
1744
  } catch (error) {
1745
- this.#error(`#GetRunnerInstanceById(): [${error}]`);
1745
+ this.#error(`#GetRunnerInstanceByRunnerId(): [${error}]`);
1746
1746
  }
1747
1747
  };
1748
- #GetRunnerExecutionProfileById = (id) => {
1748
+ #GetRunnerExecutionProfileByRunnerId = (runnerId) => {
1749
1749
  try {
1750
- if (this.#runners[id]) {
1751
- return this.#runners[id].runner.options.executionProfile;
1750
+ if (this.#runners[runnerId]) {
1751
+ return this.#runners[runnerId].runner.options.executionProfile;
1752
1752
  } else {
1753
- this.#warn(`#GetRunnerExecutionProfileById(): Runner ID: [${id}] not found`);
1753
+ this.#warn(`#GetRunnerExecutionProfileByRunnerId(): Runner ID: [${runnerId}] not found`);
1754
1754
  }
1755
1755
  } catch (error) {
1756
- this.#error(`#GetRunnerExecutionProfileById(): [${error}]`);
1756
+ this.#error(`#GetRunnerExecutionProfileByRunnerId(): [${error}]`);
1757
1757
  }
1758
1758
  };
1759
- #GetRunnerOptionsById = (id) => {
1759
+ #GetRunnerOptionsByRunnerId = (runnerId) => {
1760
1760
  try {
1761
- if (this.#runners[id]) {
1762
- return this.#runners[id].runner.options;
1761
+ if (this.#runners[runnerId]) {
1762
+ return this.#runners[runnerId].runner.options;
1763
1763
  } else {
1764
- this.#warn(`#GetRunnerOptionsById(): Runner ID: [${id}] not found`);
1764
+ this.#warn(`#GetRunnerOptionsByRunnerId(): Runner ID: [${runnerId}] not found`);
1765
1765
  }
1766
1766
  } catch (error) {
1767
- this.#error(`#GetRunnerOptionsById(): [${error}]`);
1767
+ this.#error(`#GetRunnerOptionsByRunnerId(): [${error}]`);
1768
1768
  }
1769
1769
  };
1770
- #SetRunnerOptionsById = (id, options) => {
1770
+ #SetRunnerOptionsByRunnerId = (runnerId, options) => {
1771
1771
  try {
1772
- if (this.#runners[id]) {
1773
- this.#runners[id].runner.options = { ...options };
1774
- return this.#runners[id].runner.options;
1772
+ if (this.#runners[runnerId]) {
1773
+ this.#runners[runnerId].runner.options = { ...options };
1774
+ return this.#runners[runnerId].runner.options;
1775
1775
  } else {
1776
- this.#warn(`#SetRunnerOptionsById(): Runner ID: [${id}] not found`);
1776
+ this.#warn(`#SetRunnerOptionsByRunnerId(): Runner ID: [${runnerId}] not found`);
1777
1777
  }
1778
1778
  } catch (error) {
1779
- this.#error(`#SetRunnerOptionsById(): [${error}]`);
1779
+ this.#error(`#SetRunnerOptionsByRunnerId(): [${error}]`);
1780
1780
  }
1781
1781
  };
1782
1782
  #AddRunner = async (testRunnerTelemetryPayload) => {
@@ -1802,7 +1802,7 @@ class WorkerInstance {
1802
1802
  resolve();
1803
1803
  });
1804
1804
  }
1805
- #PostMessageToWorkerManagerById = async (command, runnerId, response) => {
1805
+ #PostMessageToWorkerManagerByRunnerId = async (command, runnerId, response) => {
1806
1806
  try {
1807
1807
  if (this.#collectorCollectorPort) {
1808
1808
  if (this.#runners[runnerId]) {
@@ -1815,11 +1815,11 @@ class WorkerInstance {
1815
1815
  this.#collectorCollectorPort.postMessage(message);
1816
1816
  await Sleep(0);
1817
1817
  } else {
1818
- this.#warn(`#PostMessageToWorkerManagerById(): Runner: [${runnerId}] not found`);
1818
+ this.#warn(`#PostMessageToWorkerManagerByRunnerId(): Runner: [${runnerId}] not found`);
1819
1819
  }
1820
1820
  }
1821
1821
  } catch (error) {
1822
- this.#error(`#PostMessageToWorkerManagerById(): [${error}]`);
1822
+ this.#error(`#PostMessageToWorkerManagerByRunnerId(): [${error}]`);
1823
1823
  }
1824
1824
  };
1825
1825
  #PostRunnersToWorkerManager = async (command, messagePayload) => {
@@ -1847,18 +1847,18 @@ class WorkerInstance {
1847
1847
  if (this.#runners[runnerId]) {
1848
1848
  const { state } = this.#runners[runnerId].runner;
1849
1849
  if (state === IRunnerState.created) {
1850
- result = await this.#GetRunnerInstanceById(runnerId)?.StartRunner();
1851
- this.#UpdateRunnerStateById("#StartRunner-1", runnerId, IRunnerState.running);
1850
+ result = await this.#GetRunnerInstanceByRunnerId(runnerId)?.StartRunner();
1851
+ this.#UpdateRunnerStateByRunnerId("#StartRunner-1", runnerId, IRunnerState.running);
1852
1852
  await Sleep(0);
1853
1853
  const startLoop = /* @__PURE__ */ new Date();
1854
1854
  const ExecuteLoop = async () => {
1855
1855
  try {
1856
1856
  let cont = true;
1857
- const executionProfile = this.#GetRunnerExecutionProfileById(runnerId);
1857
+ const executionProfile = this.#GetRunnerExecutionProfileByRunnerId(runnerId);
1858
1858
  if (executionProfile) {
1859
1859
  const { iterations, duration, delayBetweenIterations, pauseOnComplete } = executionProfile;
1860
1860
  if (iterations > 0) {
1861
- cont = this.#GetRunnerIterationById(runnerId) < iterations;
1861
+ cont = this.#GetRunnerIterationByRunnerId(runnerId) < iterations;
1862
1862
  if (cont === false && pauseOnComplete === true && this.#runners[runnerId].runner.state === IRunnerState.paused) {
1863
1863
  cont = true;
1864
1864
  }
@@ -1866,13 +1866,13 @@ class WorkerInstance {
1866
1866
  cont = ((/* @__PURE__ */ new Date()).getTime() - startLoop.getTime()) / 1e3 < duration;
1867
1867
  }
1868
1868
  if (cont) {
1869
- if (this.#CanExecuteNextIterationById(runnerId)) {
1870
- await this.#GetRunnerInstanceById(runnerId)?.ExecuteRunner();
1871
- if (!this.#IsCompletedById(runnerId)) {
1872
- this.#IncRunnerIterationById(runnerId);
1869
+ if (this.#CanExecuteNextIterationByRunnerId(runnerId)) {
1870
+ await this.#GetRunnerInstanceByRunnerId(runnerId)?.ExecuteRunner();
1871
+ if (!this.#IsCompletedByRunnerId(runnerId)) {
1872
+ this.#IncRunnerIterationByRunnerId(runnerId);
1873
1873
  }
1874
1874
  }
1875
- if (this.#CanExecuteNextIterationById(runnerId)) {
1875
+ if (this.#CanExecuteNextIterationByRunnerId(runnerId)) {
1876
1876
  if (delayBetweenIterations > 0) {
1877
1877
  await Sleep(delayBetweenIterations);
1878
1878
  } else {
@@ -1880,19 +1880,19 @@ class WorkerInstance {
1880
1880
  }
1881
1881
  ExecuteLoop();
1882
1882
  } else {
1883
- if (!this.#IsCompletedById(runnerId)) {
1883
+ if (!this.#IsCompletedByRunnerId(runnerId)) {
1884
1884
  await Sleep(50);
1885
1885
  ExecuteLoop();
1886
1886
  }
1887
1887
  }
1888
1888
  } else {
1889
1889
  if (pauseOnComplete === true) {
1890
- await this.#GetRunnerInstanceById(runnerId)?.PauseRunner();
1891
- this.#UpdateRunnerStateById("#StartRunner-2", runnerId, IRunnerState.paused);
1890
+ await this.#GetRunnerInstanceByRunnerId(runnerId)?.PauseRunner();
1891
+ this.#UpdateRunnerStateByRunnerId("#StartRunner-2", runnerId, IRunnerState.paused);
1892
1892
  ExecuteLoop();
1893
1893
  } else {
1894
- await this.#GetRunnerInstanceById(runnerId)?.Completed();
1895
- this.#UpdateRunnerStateById("#StartRunner-3", runnerId, IRunnerState.completed);
1894
+ await this.#GetRunnerInstanceByRunnerId(runnerId)?.Completed();
1895
+ this.#UpdateRunnerStateByRunnerId("#StartRunner-3", runnerId, IRunnerState.completed);
1896
1896
  }
1897
1897
  }
1898
1898
  } else {
@@ -1912,17 +1912,17 @@ class WorkerInstance {
1912
1912
  }
1913
1913
  this.#SendRunnerCommandResponse(eIWMessageCommands.StartRunnerResponse, testRunnerTelemetryPayload, result);
1914
1914
  };
1915
- #StopRunnerByRunnerId = async (id) => {
1915
+ #StopRunnerByRunnerId = async (runnerId) => {
1916
1916
  let retVal;
1917
1917
  try {
1918
- if (this.#runners[id]) {
1919
- const { state } = this.#runners[id].runner;
1918
+ if (this.#runners[runnerId]) {
1919
+ const { state } = this.#runners[runnerId].runner;
1920
1920
  if (state === IRunnerState.paused || state === IRunnerState.running) {
1921
- retVal = await this.#GetRunnerInstanceById(id)?.StopRunner();
1922
- this.#UpdateRunnerStateById("#StopRunnerByRunnerId", id, IRunnerState.stopped);
1921
+ retVal = await this.#GetRunnerInstanceByRunnerId(runnerId)?.StopRunner();
1922
+ this.#UpdateRunnerStateByRunnerId("#StopRunnerByRunnerId", runnerId, IRunnerState.stopped);
1923
1923
  }
1924
1924
  } else {
1925
- this.#warn(`#StopRunnerByRunnerId(): Runner: [${id}] not found`);
1925
+ this.#warn(`#StopRunnerByRunnerId(): Runner: [${runnerId}] not found`);
1926
1926
  }
1927
1927
  } catch (error) {
1928
1928
  this.#error(`#StopRunnerByRunnerId(): Error: [${error}]`);
@@ -1945,8 +1945,8 @@ class WorkerInstance {
1945
1945
  if (this.#runners[runnerId]) {
1946
1946
  const { state } = this.#runners[runnerId].runner;
1947
1947
  if (state === IRunnerState.created || state === IRunnerState.paused || state === IRunnerState.running) {
1948
- result = await this.#GetRunnerInstanceById(runnerId)?.TerminateRunner();
1949
- this.#UpdateRunnerStateById("#TerminateRunner", runnerId, IRunnerState.terminated);
1948
+ result = await this.#GetRunnerInstanceByRunnerId(runnerId)?.TerminateRunner();
1949
+ this.#UpdateRunnerStateByRunnerId("#TerminateRunner", runnerId, IRunnerState.terminated);
1950
1950
  }
1951
1951
  } else {
1952
1952
  this.#warn(`#TerminateRunner(): Runner: [${runnerId}] not found`);
@@ -1990,8 +1990,8 @@ class WorkerInstance {
1990
1990
  if (this.#runners[runnerId]) {
1991
1991
  const { state } = this.#runners[runnerId].runner;
1992
1992
  if (state === IRunnerState.running) {
1993
- result = await this.#GetRunnerInstanceById(runnerId)?.PauseRunner();
1994
- this.#UpdateRunnerStateById("#PauseRunner", runnerId, IRunnerState.paused);
1993
+ result = await this.#GetRunnerInstanceByRunnerId(runnerId)?.PauseRunner();
1994
+ this.#UpdateRunnerStateByRunnerId("#PauseRunner", runnerId, IRunnerState.paused);
1995
1995
  }
1996
1996
  } else {
1997
1997
  this.#warn(`#PauseRunner(): Runner: [${runnerId}] not found`);
@@ -2008,8 +2008,8 @@ class WorkerInstance {
2008
2008
  if (this.#runners[runnerId]) {
2009
2009
  const { state } = this.#runners[runnerId].runner;
2010
2010
  if (state === IRunnerState.paused) {
2011
- result = await this.#GetRunnerInstanceById(runnerId)?.ResumeRunner();
2012
- this.#UpdateRunnerStateById("#ResumeRunner", runnerId, IRunnerState.running);
2011
+ result = await this.#GetRunnerInstanceByRunnerId(runnerId)?.ResumeRunner();
2012
+ this.#UpdateRunnerStateByRunnerId("#ResumeRunner", runnerId, IRunnerState.running);
2013
2013
  }
2014
2014
  } else {
2015
2015
  this.#warn(`#ResumeRunner(): Runner: [${runnerId}] not found`);
@@ -2026,9 +2026,9 @@ class WorkerInstance {
2026
2026
  if (this.#runners[runnerId]) {
2027
2027
  const { state } = this.#runners[runnerId].runner;
2028
2028
  if (state === IRunnerState.paused || state === IRunnerState.running) {
2029
- this.#UpdateRunnerStateById("#ResetRunner", runnerId, IRunnerState.paused);
2030
- this.#ResetRunnerIterationById(runnerId);
2031
- result = await this.#GetRunnerInstanceById(runnerId)?.ResetRunner();
2029
+ this.#UpdateRunnerStateByRunnerId("#ResetRunner", runnerId, IRunnerState.paused);
2030
+ this.#ResetRunnerIterationByRunnerId(runnerId);
2031
+ result = await this.#GetRunnerInstanceByRunnerId(runnerId)?.ResetRunner();
2032
2032
  }
2033
2033
  } else {
2034
2034
  this.#warn(`#ResetRunner(): Runner: [${runnerId}] not found`);
@@ -2046,12 +2046,12 @@ class WorkerInstance {
2046
2046
  if (this.#runners[runnerId]) {
2047
2047
  const { state } = this.#runners[runnerId].runner;
2048
2048
  if (state === IRunnerState.paused || state === IRunnerState.created) {
2049
- const currentIteration = this.#GetRunnerIterationById(runnerId);
2049
+ const currentIteration = this.#GetRunnerIterationByRunnerId(runnerId);
2050
2050
  this.#debug(`${chalk.magenta(`runner: [${runnerId}]`)} ExecuteRunner(${currentIteration})`);
2051
- result = await this.#GetRunnerInstanceById(runnerId)?.ExecuteRunner();
2052
- const newIteration = this.#IncRunnerIterationById(runnerId);
2051
+ result = await this.#GetRunnerInstanceByRunnerId(runnerId)?.ExecuteRunner();
2052
+ const newIteration = this.#IncRunnerIterationByRunnerId(runnerId);
2053
2053
  this.#debug(`${chalk.magenta(` --> runner: [${runnerId}]`)} Next iteration number: [${newIteration}] for next Execute or Resume.`);
2054
- this.#UpdateRunnerStateById("#ExecuteRunner", runnerId, IRunnerState.paused);
2054
+ this.#UpdateRunnerStateByRunnerId("#ExecuteRunner", runnerId, IRunnerState.paused);
2055
2055
  }
2056
2056
  } else {
2057
2057
  this.#warn(`#ExecuteRunner(): Runner: [${runnerId}] not found`);
@@ -2068,10 +2068,10 @@ class WorkerInstance {
2068
2068
  if (this.#runners[runnerId]) {
2069
2069
  const { state } = this.#runners[runnerId].runner;
2070
2070
  if (state === IRunnerState.paused || state === IRunnerState.created || state === IRunnerState.running) {
2071
- this.#debug(chalk.cyan(`before: [${JSON.stringify(this.#GetRunnerOptionsById(runnerId))}]`));
2072
- this.#SetRunnerOptionsById(runnerId, testRunnerTelemetryPayload.runner.options);
2073
- this.#debug(chalk.cyan(`after: [${JSON.stringify(this.#GetRunnerOptionsById(runnerId))}]`));
2074
- result = await this.#GetRunnerInstanceById(runnerId)?.UpdateRunner(testRunnerTelemetryPayload.runner.options);
2071
+ this.#debug(chalk.cyan(`before: [${JSON.stringify(this.#GetRunnerOptionsByRunnerId(runnerId))}]`));
2072
+ this.#SetRunnerOptionsByRunnerId(runnerId, testRunnerTelemetryPayload.runner.options);
2073
+ this.#debug(chalk.cyan(`after: [${JSON.stringify(this.#GetRunnerOptionsByRunnerId(runnerId))}]`));
2074
+ result = await this.#GetRunnerInstanceByRunnerId(runnerId)?.UpdateRunner(testRunnerTelemetryPayload.runner.options);
2075
2075
  }
2076
2076
  } else {
2077
2077
  this.#warn(`#UpdateRunner(): Runner: [${runnerId}] not found`);
@@ -3023,7 +3023,7 @@ class STSWorkerManager {
3023
3023
  this.#logMessage(this.#options.logger.error, error);
3024
3024
  }
3025
3025
  };
3026
- CreateRunnerCopyNoHistory(runnerEx) {
3026
+ GetRunnerMetadataCopyNoHistory(runnerEx) {
3027
3027
  try {
3028
3028
  return {
3029
3029
  id: runnerEx.id,
@@ -3036,23 +3036,23 @@ class STSWorkerManager {
3036
3036
  workerManagerId: this.#id
3037
3037
  };
3038
3038
  } catch (error) {
3039
- this.#error(`CreateRunnerCopyNoHistory(): Error: [${error}]`);
3039
+ this.#error(`GetRunnerMetadataCopyNoHistory(): Error: [${error}]`);
3040
3040
  throw error;
3041
3041
  }
3042
3042
  }
3043
- CreateRunnerCopy(runnerEx) {
3043
+ GetRunnerMetadataCopy(runnerEx) {
3044
3044
  try {
3045
- const retVal = this.CreateRunnerCopyNoHistory(runnerEx);
3045
+ const retVal = this.GetRunnerMetadataCopyNoHistory(runnerEx);
3046
3046
  if (runnerEx.runnerHistory) {
3047
3047
  retVal.runnerHistory = [...runnerEx.runnerHistory];
3048
3048
  }
3049
3049
  return retVal;
3050
3050
  } catch (error) {
3051
- this.#error(`CreateRunnerCopy(): Error: [${error}]`);
3051
+ this.#error(`GetRunnerMetadataCopy(): Error: [${error}]`);
3052
3052
  throw error;
3053
3053
  }
3054
3054
  }
3055
- CreateRunnerCopySmall(runnerEx) {
3055
+ GetRunnerMetadataPartialCopy(runnerEx) {
3056
3056
  try {
3057
3057
  const retVal = {
3058
3058
  id: runnerEx.id,
@@ -3066,11 +3066,11 @@ class STSWorkerManager {
3066
3066
  }
3067
3067
  return retVal;
3068
3068
  } catch (error) {
3069
- this.#error(`CreateRunnerCopy(): Error: [${error}]`);
3069
+ this.#error(`GetRunnerMetadataPartialCopy(): Error: [${error}]`);
3070
3070
  throw error;
3071
3071
  }
3072
3072
  }
3073
- CreateWorkerCopy(workerEx) {
3073
+ GetWorkerMetadataCopy(workerEx) {
3074
3074
  try {
3075
3075
  const { id, options, runnersEx, workerManagerId } = workerEx;
3076
3076
  const workerCopy = {
@@ -3080,26 +3080,26 @@ class STSWorkerManager {
3080
3080
  workerManagerId
3081
3081
  };
3082
3082
  for (const [, runnerEx] of Object.entries(runnersEx)) {
3083
- workerCopy.runners[runnerEx.id] = this.CreateRunnerCopy(runnerEx);
3083
+ workerCopy.runners[runnerEx.id] = this.GetRunnerMetadataCopy(runnerEx);
3084
3084
  }
3085
3085
  return workerCopy;
3086
3086
  } catch (error) {
3087
- this.#error(`#CreateWorkerCopy(): Error: [${error}]`);
3087
+ this.#error(`#GetWorkerMetadataCopy(): Error: [${error}]`);
3088
3088
  throw error;
3089
3089
  }
3090
3090
  }
3091
- CreateWorkerCopySmall(workerEx, states) {
3091
+ GetWorkerMetadataPartialCopyByRunnerState(workerEx, states) {
3092
3092
  try {
3093
3093
  const workerCopy = {
3094
3094
  id: workerEx.id,
3095
3095
  runners: {}
3096
3096
  };
3097
3097
  Object.values(workerEx.runnersEx).filter((runnerEx) => states.length === 0 ? true : states.includes(runnerEx.state)).forEach((runnerEx) => {
3098
- workerCopy.runners[runnerEx.id] = this.CreateRunnerCopySmall(runnerEx);
3098
+ workerCopy.runners[runnerEx.id] = this.GetRunnerMetadataPartialCopy(runnerEx);
3099
3099
  });
3100
3100
  return workerCopy;
3101
3101
  } catch (error) {
3102
- this.#error(`CreateWorkerCopySmall(): Error: [${error}]`);
3102
+ this.#error(`GetWorkerMetadataPartialCopyByRunnerState(): Error: [${error}]`);
3103
3103
  throw error;
3104
3104
  }
3105
3105
  }
@@ -3131,7 +3131,7 @@ class STSWorkerManager {
3131
3131
  }
3132
3132
  if (runnerEx.state !== IRunnerState.terminated) {
3133
3133
  this.#debug(chalk.grey(`Archive runner: [${JSON.stringify(runnerEx.asyncRunnerContext)}]`));
3134
- const runner = this.CreateRunnerCopy(runnerEx);
3134
+ const runner = this.GetRunnerMetadataCopy(runnerEx);
3135
3135
  this.#archiveList.push(runner);
3136
3136
  if (this.#archiveList.length > this.#options.maxArchiveListLength) {
3137
3137
  this.#archiveList.shift();
@@ -3163,16 +3163,19 @@ class STSWorkerManager {
3163
3163
  throw error;
3164
3164
  }
3165
3165
  };
3166
+ /**
3167
+ * @returns Return the WorkerManager Id, i.e. this Id.
3168
+ */
3166
3169
  get id() {
3167
3170
  return this.#id;
3168
3171
  }
3169
- GetWorkers = async () => {
3172
+ GetWorkersMetadataCopyPostSync = async () => {
3170
3173
  this.#debug(`GetWorkers()`);
3171
3174
  try {
3172
3175
  await this.#SyncWorkerDataFromWorkers();
3173
3176
  const retVal = {};
3174
3177
  for (const [, workerEx] of Object.entries(this.#workersEx)) {
3175
- retVal[workerEx.id] = this.CreateWorkerCopy(workerEx);
3178
+ retVal[workerEx.id] = this.GetWorkerMetadataCopy(workerEx);
3176
3179
  }
3177
3180
  return retVal;
3178
3181
  } catch (error) {
@@ -3182,24 +3185,33 @@ class STSWorkerManager {
3182
3185
  };
3183
3186
  // only include runners that are in the specified states.
3184
3187
  // Use [] to include all runners irrespective of state.
3185
- GetWorkersSmall = async (states) => {
3186
- this.#debug(`GetWorkersSmall()`);
3188
+ /**
3189
+ * Only include runners that are in the specified states.
3190
+ * @param states Use [] to include all runners irrespective of state.
3191
+ * @returns IWorkers (partial copy)
3192
+ */
3193
+ GetWorkersMetadataPartialCopyByRunnerStatePostSync = async (states) => {
3194
+ this.#debug(`GetWorkersMetadataPartialCopyByRunnerState()`);
3187
3195
  try {
3188
3196
  await this.#SyncWorkerDataFromWorkers();
3189
3197
  const retVal = {};
3190
3198
  for (const [, workerEx] of Object.entries(this.#workersEx)) {
3191
- retVal[workerEx.id] = this.CreateWorkerCopySmall(workerEx, states);
3199
+ retVal[workerEx.id] = this.GetWorkerMetadataPartialCopyByRunnerState(workerEx, states);
3192
3200
  }
3193
3201
  return retVal;
3194
3202
  } catch (error) {
3195
- this.#error(`GetWorkers(): Error: [${error}]`);
3203
+ this.#error(`GetWorkersMetadataPartialCopyByRunnerState(): Error: [${error}]`);
3196
3204
  throw error;
3197
3205
  }
3198
3206
  };
3199
3207
  get WorkersEx() {
3200
3208
  return this.#workersEx;
3201
3209
  }
3202
- // Filter by plan and/or tag. Leave blank to not use in filter.
3210
+ /**
3211
+ * Filter by plan and/or tag. Leave blank to not use in filter.
3212
+ * @param runnerSearchFilters
3213
+ * @returns
3214
+ */
3203
3215
  GetArchiveList = async (runnerSearchFilters) => {
3204
3216
  this.#debug(`GetArchiveList()`);
3205
3217
  try {
@@ -3209,21 +3221,21 @@ class STSWorkerManager {
3209
3221
  return [];
3210
3222
  }
3211
3223
  };
3212
- GetWorker = async (workerId) => {
3213
- this.#debug(`GetWorker()`);
3224
+ GetWorkerMetadataCopyPosySync = async (workerId) => {
3225
+ this.#debug(`GetWorkerMetadataCopyPosySync()`);
3214
3226
  try {
3215
3227
  await this.#SyncWorkerDataFromWorker(this.#workersEx[workerId]);
3216
- return this.CreateWorkerCopy(this.#workersEx[workerId]);
3228
+ return this.GetWorkerMetadataCopy(this.#workersEx[workerId]);
3217
3229
  } catch (error) {
3218
- this.#error(`GetWorker(): Error: [${error}]`);
3230
+ this.#error(`GetWorkerMetadataCopyPosySync(): Error: [${error}]`);
3219
3231
  throw error;
3220
3232
  }
3221
3233
  };
3222
- GetRunner = async (workerId, runnerId) => {
3234
+ GetRunnerMetadataCopyPostSync = async (workerId, runnerId) => {
3223
3235
  this.#debug(`GetRunner()`);
3224
3236
  try {
3225
3237
  await this.#SyncWorkerDataFromWorker(this.#workersEx[workerId]);
3226
- return this.CreateRunnerCopy(this.#workersEx[workerId].runnersEx[runnerId]);
3238
+ return this.GetRunnerMetadataCopy(this.#workersEx[workerId].runnersEx[runnerId]);
3227
3239
  } catch (error) {
3228
3240
  this.#error(`GetRunner(): Error: [${error}]`);
3229
3241
  throw error;
@@ -3407,7 +3419,7 @@ class STSWorkerManager {
3407
3419
  this.#workersEx[stsWorkerEx.id] = stsWorkerEx;
3408
3420
  this.#debug(`Added worker: [${stsWorkerEx.id}]`);
3409
3421
  await Sleep(10);
3410
- const worker = await this.GetWorker(stsWorkerEx.id);
3422
+ const worker = await this.GetWorkerMetadataCopyPosySync(stsWorkerEx.id);
3411
3423
  if (worker.id.localeCompare(stsWorkerEx.id) === 0) {
3412
3424
  return stsWorkerEx;
3413
3425
  } else {
@@ -3443,7 +3455,7 @@ class STSWorkerManager {
3443
3455
  const messageId = this.#SetupCallbackMessage(resolve, reject, command);
3444
3456
  const payload = {
3445
3457
  messageId,
3446
- runner: this.CreateRunnerCopyNoHistory(runnerEx)
3458
+ runner: this.GetRunnerMetadataCopyNoHistory(runnerEx)
3447
3459
  };
3448
3460
  workerEx.messagePort.postMessage({ command, payload });
3449
3461
  } catch (error) {
@@ -3611,7 +3623,7 @@ class STSWorkerManager {
3611
3623
  const messageId = this.#SetupCallbackMessage(resolve, reject, command);
3612
3624
  const payload = {
3613
3625
  messageId,
3614
- runner: this.CreateRunnerCopyNoHistory(runnerEx)
3626
+ runner: this.GetRunnerMetadataCopyNoHistory(runnerEx)
3615
3627
  };
3616
3628
  workerEx.messagePort.postMessage({ command, payload });
3617
3629
  } catch (error) {
@@ -3627,7 +3639,7 @@ class STSWorkerManager {
3627
3639
  const messageId = this.#SetupCallbackMessage(resolve, reject, command);
3628
3640
  const payload = {
3629
3641
  messageId,
3630
- runner: this.CreateRunnerCopyNoHistory(runnerEx)
3642
+ runner: this.GetRunnerMetadataCopyNoHistory(runnerEx)
3631
3643
  };
3632
3644
  workerEx.messagePort.postMessage({ command, payload });
3633
3645
  } catch (error) {
@@ -3643,7 +3655,7 @@ class STSWorkerManager {
3643
3655
  const messageId = this.#SetupCallbackMessage(resolve, reject, command);
3644
3656
  const payload = {
3645
3657
  messageId,
3646
- runner: this.CreateRunnerCopyNoHistory(runnerEx)
3658
+ runner: this.GetRunnerMetadataCopyNoHistory(runnerEx)
3647
3659
  };
3648
3660
  workerEx.messagePort.postMessage({ command, payload });
3649
3661
  } catch (error) {
@@ -3659,7 +3671,7 @@ class STSWorkerManager {
3659
3671
  const messageId = this.#SetupCallbackMessage(resolve, reject, command);
3660
3672
  const payload = {
3661
3673
  messageId,
3662
- runner: this.CreateRunnerCopyNoHistory(runnerEx)
3674
+ runner: this.GetRunnerMetadataCopyNoHistory(runnerEx)
3663
3675
  };
3664
3676
  workerEx.messagePort.postMessage({ command, payload });
3665
3677
  } catch (error) {
@@ -3675,7 +3687,7 @@ class STSWorkerManager {
3675
3687
  const messageId = this.#SetupCallbackMessage(resolve, reject, command);
3676
3688
  const payload = {
3677
3689
  messageId,
3678
- runner: this.CreateRunnerCopyNoHistory(runnerEx)
3690
+ runner: this.GetRunnerMetadataCopyNoHistory(runnerEx)
3679
3691
  };
3680
3692
  workerEx.messagePort.postMessage({ command, payload });
3681
3693
  } catch (error) {
@@ -3691,7 +3703,7 @@ class STSWorkerManager {
3691
3703
  const messageId = this.#SetupCallbackMessage(resolve, reject, command);
3692
3704
  const payload = {
3693
3705
  messageId,
3694
- runner: this.CreateRunnerCopyNoHistory(runnerEx)
3706
+ runner: this.GetRunnerMetadataCopyNoHistory(runnerEx)
3695
3707
  };
3696
3708
  workerEx.messagePort.postMessage({ command, payload });
3697
3709
  } catch (error) {
@@ -3707,7 +3719,7 @@ class STSWorkerManager {
3707
3719
  const messageId = this.#SetupCallbackMessage(resolve, reject, command);
3708
3720
  const payload = {
3709
3721
  messageId,
3710
- runner: this.CreateRunnerCopyNoHistory(runnerEx)
3722
+ runner: this.GetRunnerMetadataCopyNoHistory(runnerEx)
3711
3723
  };
3712
3724
  workerEx.messagePort.postMessage({ command, payload });
3713
3725
  } catch (error) {
@@ -3724,7 +3736,7 @@ class STSWorkerManager {
3724
3736
  const messageId = this.#SetupCallbackMessage(resolve, reject, command);
3725
3737
  const payload = {
3726
3738
  messageId,
3727
- runner: this.CreateRunnerCopyNoHistory(runnerEx)
3739
+ runner: this.GetRunnerMetadataCopyNoHistory(runnerEx)
3728
3740
  };
3729
3741
  workerEx.messagePort.postMessage({ command, payload });
3730
3742
  } catch (error) {
@@ -3833,8 +3845,8 @@ class STSWorkerManager {
3833
3845
  return null;
3834
3846
  }
3835
3847
  };
3836
- GetBusyWorker = () => {
3837
- this.#debug(`GetBusyWorker()`);
3848
+ GetBusiestWorker = () => {
3849
+ this.#debug(`GetBusiestWorker()`);
3838
3850
  try {
3839
3851
  let busyWorker = null;
3840
3852
  for (const [, stsWorker] of Object.entries(this.WorkersEx)) {
@@ -3848,7 +3860,7 @@ class STSWorkerManager {
3848
3860
  }
3849
3861
  return busyWorker;
3850
3862
  } catch (error) {
3851
- this.#error(`GetBusyWorker(): Error: [${error}]`);
3863
+ this.#error(`GetBusiestWorker(): Error: [${error}]`);
3852
3864
  return null;
3853
3865
  }
3854
3866
  };