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