@nsshunt/stsrunnerframework 1.0.198 → 1.0.200

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