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