@nsshunt/stsrunnerframework 1.0.58 → 1.0.60
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 +237 -119
- package/dist/stsrunnerframework.mjs.map +1 -1
- package/dist/stsrunnerframework.umd.js +237 -119
- package/dist/stsrunnerframework.umd.js.map +1 -1
- package/package.json +1 -1
- package/types/commonTypes.d.ts +29 -8
- package/types/commonTypes.d.ts.map +1 -1
- package/types/mockedWorkerTestRunner01.d.ts +10 -0
- package/types/mockedWorkerTestRunner01.d.ts.map +1 -0
- package/types/testCase01.d.ts +1 -0
- package/types/testCase01.d.ts.map +1 -1
- package/types/wmwokerProcess.test.d.ts +2 -0
- package/types/wmwokerProcess.test.d.ts.map +1 -0
- package/types/wmworkerProcess.d.ts +28 -0
- package/types/wmworkerProcess.d.ts.map +1 -0
- package/types/workerInstance.d.ts +1 -4
- package/types/workerInstance.d.ts.map +1 -1
- package/types/workerManager.d.ts.map +1 -1
- package/types/workerWorkerTestRunner01.d.ts.map +1 -1
|
@@ -9,7 +9,7 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
|
|
|
9
9
|
var __privateAdd = (obj, member, value2) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value2);
|
|
10
10
|
var __privateSet = (obj, member, value2, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value2) : member.set(obj, value2), value2);
|
|
11
11
|
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
12
|
-
var _collectorCollectorPort, _runners, _options3, _workerId, _debug, _SetMessagePort, _AddRunner, _WorkerInstance_instances, SleepImmediate_fn, _StartRunner, _StopAllRunners, _StopRunner, _TerminateRunner, _PauseRunner, _ResumeRunner, _ResetRunner, _ExecuteRunner, _UpdateOptions, _workersEx, _options4, _STSInstrumentController, _telemetryProcessor, _debug2, _STSWorkerManager_instances, CreateRunnerCopy_fn, _SetRunnerIntoWorker, _ProcessTelemetry, _ProcessCompleted, _CreateAsyncRunner, _PostMessageToWorker, _StartRunner2, _ResetRunner2, _ExecuteRunner2, _StopRunner2, _TerminateRunner2, _PauseRunner2, _ResumeRunner2, _BroadcastCommandToAllRunners, _PauseWorker, _ResumeWorker, _StopWorker, _StartWorker, _ResetWorker, _ExecuteWorker, _BroadcastUpdateCommandToAllRunners, _UpdateOptionsWorker, _TerminateWorker, _UpdateOptions2, _options5, _rest01Client, _accessToken2, _agentManager, _authUtilsNode, _GetAccessToken;
|
|
12
|
+
var _collectorCollectorPort, _runners, _options3, _workerId, _debug, _SetMessagePort, _CreateRunnerEx2RunState, _UpdateRunnerStateById, _GetAllRunners, _CanExecuteNextIterationById, _GetRunnerIterationById, _ResetRunnerIterationById, _IncRunnerIterationById, _GetRunnerInstanceById, _GetRunnerExecutionProfileById, _GetRunnerOptionsById, _SetRunnerOptionsById, _AddRunner, _WorkerInstance_instances, SleepImmediate_fn, _PostMessageToWorkerManagerById, _StartRunner, _StopRunnerByRunnerById, _StopAllRunners, _StopRunner, _TerminateRunner, _PauseRunner, _ResumeRunner, _ResetRunner, _ExecuteRunner, _UpdateOptions, _workersEx, _options4, _STSInstrumentController, _telemetryProcessor, _debug2, _STSWorkerManager_instances, CreateRunnerCopy_fn, _SetRunnerIntoWorker, _ProcessTelemetry, _RunnerStateChange, _ProcessCompleted, _CreateAsyncRunner, _PostMessageToWorkerUsingDefaultChannel, _PostMessageToWorker, _StartRunner2, _ResetRunner2, _ExecuteRunner2, _StopRunner2, _TerminateRunner2, _PauseRunner2, _ResumeRunner2, _BroadcastCommandToAllRunners, _PauseWorker, _ResumeWorker, _StopWorker, _StartWorker, _ResetWorker, _ExecuteWorker, _BroadcastUpdateCommandToAllRunners, _UpdateOptionsWorker, _TerminateWorker, _UpdateOptions2, _options5, _rest01Client, _accessToken2, _agentManager, _authUtilsNode, _GetAccessToken;
|
|
13
13
|
import { Sleep, ModelDelimeter, STSAxiosConfig, GetErrorPayload, AgentManager, defaultLogger } from "@nsshunt/stsutils";
|
|
14
14
|
import { Gauge } from "@nsshunt/stsobservability";
|
|
15
15
|
import { accessSync, constants as constants$2, readFileSync } from "node:fs";
|
|
@@ -43,20 +43,36 @@ var eIWMessageCommands = /* @__PURE__ */ ((eIWMessageCommands2) => {
|
|
|
43
43
|
eIWMessageCommands2["Completed"] = "__STS__Completed";
|
|
44
44
|
eIWMessageCommands2["UpdateOptions"] = "__STS__UpdateOptions";
|
|
45
45
|
eIWMessageCommands2["TerminateRunner"] = "__STS__TerminateRunner";
|
|
46
|
+
eIWMessageCommands2["RunnerStateChange"] = "__STS__RunnerStateChange";
|
|
46
47
|
return eIWMessageCommands2;
|
|
47
48
|
})(eIWMessageCommands || {});
|
|
48
49
|
var IRunnerState = /* @__PURE__ */ ((IRunnerState2) => {
|
|
49
|
-
IRunnerState2["
|
|
50
|
-
IRunnerState2["
|
|
50
|
+
IRunnerState2["starting"] = "starting";
|
|
51
|
+
IRunnerState2["started"] = "started";
|
|
52
|
+
IRunnerState2["stopping"] = "stopping";
|
|
51
53
|
IRunnerState2["stopped"] = "stopped";
|
|
54
|
+
IRunnerState2["terminating"] = "terminating";
|
|
55
|
+
IRunnerState2["terminated"] = "terminated";
|
|
56
|
+
IRunnerState2["resuming"] = "resuming";
|
|
57
|
+
IRunnerState2["resumed"] = "resumed";
|
|
58
|
+
IRunnerState2["pausing"] = "pausing";
|
|
52
59
|
IRunnerState2["paused"] = "paused";
|
|
60
|
+
IRunnerState2["executing"] = "executing";
|
|
61
|
+
IRunnerState2["executed"] = "executed";
|
|
62
|
+
IRunnerState2["resetting"] = "resetting";
|
|
63
|
+
IRunnerState2["reset"] = "reset";
|
|
53
64
|
IRunnerState2["error"] = "error";
|
|
65
|
+
IRunnerState2["completed"] = "completed";
|
|
66
|
+
IRunnerState2["created"] = "created";
|
|
67
|
+
IRunnerState2["running"] = "running";
|
|
54
68
|
return IRunnerState2;
|
|
55
69
|
})(IRunnerState || {});
|
|
56
70
|
var IWorkerState = /* @__PURE__ */ ((IWorkerState2) => {
|
|
57
71
|
IWorkerState2["starting"] = "starting";
|
|
58
72
|
IWorkerState2["started"] = "started";
|
|
59
73
|
IWorkerState2["stopped"] = "stopped";
|
|
74
|
+
IWorkerState2["paused"] = "paused";
|
|
75
|
+
IWorkerState2["error"] = "error";
|
|
60
76
|
return IWorkerState2;
|
|
61
77
|
})(IWorkerState || {});
|
|
62
78
|
const PublishMessageCommandsTestRunner = {
|
|
@@ -1571,27 +1587,19 @@ class WorkerInstance {
|
|
|
1571
1587
|
__privateGet(this, _debug).call(this, `StartWork`);
|
|
1572
1588
|
return;
|
|
1573
1589
|
});
|
|
1574
|
-
__publicField(this, "
|
|
1575
|
-
|
|
1576
|
-
const message2 = {
|
|
1577
|
-
command: eIWMessageCommands.InstrumentTelemetry,
|
|
1578
|
-
payload: {
|
|
1579
|
-
runner
|
|
1580
|
-
}
|
|
1581
|
-
};
|
|
1582
|
-
__privateGet(this, _collectorCollectorPort).postMessage(message2);
|
|
1583
|
-
}
|
|
1590
|
+
__publicField(this, "PostTelemetryById", (id) => {
|
|
1591
|
+
__privateGet(this, _PostMessageToWorkerManagerById).call(this, eIWMessageCommands.InstrumentTelemetry, id);
|
|
1584
1592
|
});
|
|
1585
1593
|
__privateAdd(this, _SetMessagePort, (workerMessagePort) => {
|
|
1586
1594
|
__privateGet(this, _debug).call(this, `SetMessagePort`);
|
|
1587
1595
|
__privateSet(this, _collectorCollectorPort, workerMessagePort.port);
|
|
1588
1596
|
if (isNode$1) {
|
|
1589
1597
|
__privateGet(this, _collectorCollectorPort).on("message", (data) => {
|
|
1590
|
-
__privateGet(this, _debug).call(this, `collectorCollectorPort onmessage: ${
|
|
1598
|
+
__privateGet(this, _debug).call(this, `collectorCollectorPort onmessage: ${JSON.stringify(data)}`);
|
|
1591
1599
|
});
|
|
1592
1600
|
} else {
|
|
1593
1601
|
__privateGet(this, _collectorCollectorPort).onmessage = function(data) {
|
|
1594
|
-
console.log(`collectorCollectorPort onmessage: ${data.data}`);
|
|
1602
|
+
console.log(`collectorCollectorPort onmessage: ${JSON.stringify(data.data)}`);
|
|
1595
1603
|
};
|
|
1596
1604
|
}
|
|
1597
1605
|
const response = {
|
|
@@ -1603,122 +1611,180 @@ class WorkerInstance {
|
|
|
1603
1611
|
__publicField(this, "CreateAsyncRunner", (testRunnerTelemetryPayload) => {
|
|
1604
1612
|
return null;
|
|
1605
1613
|
});
|
|
1614
|
+
__privateAdd(this, _CreateRunnerEx2RunState, (runner, runnerInstance) => {
|
|
1615
|
+
__privateGet(this, _runners)[runner.id] = {
|
|
1616
|
+
runner,
|
|
1617
|
+
runnerInstance
|
|
1618
|
+
};
|
|
1619
|
+
__privateGet(this, _runners)[runner.id].runner.state = IRunnerState.created;
|
|
1620
|
+
__privateGet(this, _runners)[runner.id].runner.iteration = 0;
|
|
1621
|
+
});
|
|
1622
|
+
__privateAdd(this, _UpdateRunnerStateById, (id, state) => {
|
|
1623
|
+
__privateGet(this, _runners)[id].runner.state = state;
|
|
1624
|
+
__privateGet(this, _PostMessageToWorkerManagerById).call(this, eIWMessageCommands.RunnerStateChange, id);
|
|
1625
|
+
});
|
|
1626
|
+
__privateAdd(this, _GetAllRunners, () => {
|
|
1627
|
+
return __privateGet(this, _runners);
|
|
1628
|
+
});
|
|
1629
|
+
__privateAdd(this, _CanExecuteNextIterationById, (id) => {
|
|
1630
|
+
const state = __privateGet(this, _runners)[id].runner.state;
|
|
1631
|
+
if (state === IRunnerState.running || state === IRunnerState.executed || state === IRunnerState.resumed || state === IRunnerState.reset || state === IRunnerState.started) {
|
|
1632
|
+
return true;
|
|
1633
|
+
}
|
|
1634
|
+
return false;
|
|
1635
|
+
});
|
|
1636
|
+
__privateAdd(this, _GetRunnerIterationById, (id) => {
|
|
1637
|
+
return __privateGet(this, _runners)[id].runner.iteration;
|
|
1638
|
+
});
|
|
1639
|
+
__privateAdd(this, _ResetRunnerIterationById, (id) => {
|
|
1640
|
+
__privateGet(this, _runners)[id].runner.iteration = 0;
|
|
1641
|
+
return 0;
|
|
1642
|
+
});
|
|
1643
|
+
__privateAdd(this, _IncRunnerIterationById, (id) => {
|
|
1644
|
+
__privateGet(this, _runners)[id].runner.iteration++;
|
|
1645
|
+
return __privateGet(this, _runners)[id].runner.iteration;
|
|
1646
|
+
});
|
|
1647
|
+
__privateAdd(this, _GetRunnerInstanceById, (id) => {
|
|
1648
|
+
return __privateGet(this, _runners)[id].runnerInstance;
|
|
1649
|
+
});
|
|
1650
|
+
__privateAdd(this, _GetRunnerExecutionProfileById, (id) => {
|
|
1651
|
+
return __privateGet(this, _runners)[id].runner.options.executionProfile;
|
|
1652
|
+
});
|
|
1653
|
+
__privateAdd(this, _GetRunnerOptionsById, (id) => {
|
|
1654
|
+
return __privateGet(this, _runners)[id].runner.options;
|
|
1655
|
+
});
|
|
1656
|
+
__privateAdd(this, _SetRunnerOptionsById, (id, options) => {
|
|
1657
|
+
__privateGet(this, _runners)[id].runner.options = { ...options };
|
|
1658
|
+
return __privateGet(this, _runners)[id].runner.options;
|
|
1659
|
+
});
|
|
1606
1660
|
__privateAdd(this, _AddRunner, (testRunnerTelemetryPayload) => {
|
|
1607
1661
|
__privateGet(this, _debug).call(this, `AddRunner`);
|
|
1608
1662
|
const { runner } = testRunnerTelemetryPayload;
|
|
1609
1663
|
const asyncRunnerInstance = this.CreateAsyncRunner(testRunnerTelemetryPayload);
|
|
1610
1664
|
if (asyncRunnerInstance) {
|
|
1611
|
-
__privateGet(this,
|
|
1612
|
-
runnerInstance: asyncRunnerInstance,
|
|
1613
|
-
runner: testRunnerTelemetryPayload.runner,
|
|
1614
|
-
iteration: 0,
|
|
1615
|
-
terminate: false,
|
|
1616
|
-
paused: false
|
|
1617
|
-
};
|
|
1665
|
+
__privateGet(this, _CreateRunnerEx2RunState).call(this, runner, asyncRunnerInstance);
|
|
1618
1666
|
}
|
|
1619
1667
|
return runner;
|
|
1620
1668
|
});
|
|
1669
|
+
__privateAdd(this, _PostMessageToWorkerManagerById, (command, id) => {
|
|
1670
|
+
if (__privateGet(this, _collectorCollectorPort)) {
|
|
1671
|
+
const message2 = {
|
|
1672
|
+
command,
|
|
1673
|
+
payload: {
|
|
1674
|
+
runner: __privateGet(this, _runners)[id].runner
|
|
1675
|
+
}
|
|
1676
|
+
};
|
|
1677
|
+
__privateGet(this, _collectorCollectorPort).postMessage(message2);
|
|
1678
|
+
}
|
|
1679
|
+
});
|
|
1621
1680
|
__privateAdd(this, _StartRunner, async (testRunnerTelemetryPayload) => {
|
|
1622
|
-
const
|
|
1623
|
-
__privateGet(this, _debug).call(this, `${chalk$1.magenta(`runner: [${
|
|
1624
|
-
__privateGet(this,
|
|
1625
|
-
|
|
1626
|
-
await __privateGet(this,
|
|
1681
|
+
const runnerId = testRunnerTelemetryPayload.runner.id;
|
|
1682
|
+
__privateGet(this, _debug).call(this, `${chalk$1.magenta(`runner: [${runnerId}]`)} StartRunner`);
|
|
1683
|
+
__privateGet(this, _UpdateRunnerStateById).call(this, runnerId, IRunnerState.starting);
|
|
1684
|
+
await Sleep(0);
|
|
1685
|
+
await __privateGet(this, _GetRunnerInstanceById).call(this, runnerId).StartRunner();
|
|
1686
|
+
__privateGet(this, _UpdateRunnerStateById).call(this, runnerId, IRunnerState.started);
|
|
1627
1687
|
const ExecuteLoop = async () => {
|
|
1628
|
-
if (__privateGet(this,
|
|
1629
|
-
if (
|
|
1630
|
-
await __privateGet(this,
|
|
1631
|
-
__privateGet(this,
|
|
1688
|
+
if (__privateGet(this, _GetRunnerIterationById).call(this, runnerId) < __privateGet(this, _GetRunnerExecutionProfileById).call(this, runnerId).iterations) {
|
|
1689
|
+
if (__privateGet(this, _CanExecuteNextIterationById).call(this, runnerId)) {
|
|
1690
|
+
await __privateGet(this, _GetRunnerInstanceById).call(this, runnerId).Execute(__privateGet(this, _GetRunnerIterationById).call(this, runnerId));
|
|
1691
|
+
__privateGet(this, _IncRunnerIterationById).call(this, runnerId);
|
|
1632
1692
|
}
|
|
1633
|
-
if (
|
|
1634
|
-
if (
|
|
1635
|
-
|
|
1636
|
-
await Sleep(__privateGet(this, _runners)[runner.id].runner.options.executionProfile.delayBetweenIterations);
|
|
1637
|
-
} else {
|
|
1638
|
-
await __privateMethod(this, _WorkerInstance_instances, SleepImmediate_fn).call(this);
|
|
1639
|
-
}
|
|
1640
|
-
ExecuteLoop();
|
|
1693
|
+
if (__privateGet(this, _CanExecuteNextIterationById).call(this, runnerId)) {
|
|
1694
|
+
if (__privateGet(this, _GetRunnerExecutionProfileById).call(this, runnerId).delayBetweenIterations > 0) {
|
|
1695
|
+
await Sleep(__privateGet(this, _GetRunnerExecutionProfileById).call(this, runnerId).delayBetweenIterations);
|
|
1641
1696
|
} else {
|
|
1642
|
-
await
|
|
1643
|
-
ExecuteLoop();
|
|
1697
|
+
await __privateMethod(this, _WorkerInstance_instances, SleepImmediate_fn).call(this);
|
|
1644
1698
|
}
|
|
1699
|
+
ExecuteLoop();
|
|
1700
|
+
} else {
|
|
1701
|
+
await Sleep(50);
|
|
1702
|
+
ExecuteLoop();
|
|
1645
1703
|
}
|
|
1646
1704
|
} else {
|
|
1647
|
-
await __privateGet(this,
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
command: eIWMessageCommands.Completed,
|
|
1651
|
-
payload: {
|
|
1652
|
-
runner
|
|
1653
|
-
}
|
|
1654
|
-
};
|
|
1655
|
-
__privateGet(this, _collectorCollectorPort).postMessage(message2);
|
|
1656
|
-
}
|
|
1705
|
+
await __privateGet(this, _GetRunnerInstanceById).call(this, runnerId).Completed();
|
|
1706
|
+
__privateGet(this, _UpdateRunnerStateById).call(this, runnerId, IRunnerState.completed);
|
|
1707
|
+
__privateGet(this, _PostMessageToWorkerManagerById).call(this, eIWMessageCommands.Completed, runnerId);
|
|
1657
1708
|
}
|
|
1658
1709
|
};
|
|
1659
1710
|
ExecuteLoop();
|
|
1660
1711
|
});
|
|
1712
|
+
__privateAdd(this, _StopRunnerByRunnerById, async (id) => {
|
|
1713
|
+
__privateGet(this, _debug).call(this, `${chalk$1.magenta(`runner: [${id}]`)} StopRunner`);
|
|
1714
|
+
__privateGet(this, _UpdateRunnerStateById).call(this, id, IRunnerState.stopping);
|
|
1715
|
+
await Sleep(0);
|
|
1716
|
+
await __privateGet(this, _GetRunnerInstanceById).call(this, id).StopRunner();
|
|
1717
|
+
__privateGet(this, _UpdateRunnerStateById).call(this, id, IRunnerState.stopped);
|
|
1718
|
+
await Sleep(0);
|
|
1719
|
+
});
|
|
1661
1720
|
__privateAdd(this, _StopAllRunners, async (testRunnerTelemetryPayload) => {
|
|
1662
1721
|
__privateGet(this, _debug).call(this, `StopAllRunners`);
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
await runner.runnerInstance.StopRunner();
|
|
1722
|
+
const promArray = [];
|
|
1723
|
+
for (const [, runner] of Object.entries(__privateGet(this, _GetAllRunners))) {
|
|
1724
|
+
promArray.push(__privateGet(this, _StopRunnerByRunnerById).call(this, runner.id));
|
|
1667
1725
|
}
|
|
1726
|
+
await Promise.all(promArray);
|
|
1668
1727
|
await Sleep(0);
|
|
1669
1728
|
});
|
|
1670
1729
|
__privateAdd(this, _StopRunner, async (testRunnerTelemetryPayload) => {
|
|
1671
|
-
|
|
1672
|
-
__privateGet(this, _debug).call(this, `${chalk$1.magenta(`runner: [${runner.id}]`)} StopRunner`);
|
|
1673
|
-
__privateGet(this, _runners)[runner.id].terminate = true;
|
|
1674
|
-
await __privateGet(this, _runners)[runner.id].runnerInstance.StopRunner();
|
|
1675
|
-
await Sleep(0);
|
|
1730
|
+
await __privateGet(this, _StopRunnerByRunnerById).call(this, testRunnerTelemetryPayload.runner.id);
|
|
1676
1731
|
});
|
|
1677
1732
|
__privateAdd(this, _TerminateRunner, async (testRunnerTelemetryPayload) => {
|
|
1678
|
-
const
|
|
1679
|
-
__privateGet(this, _debug).call(this, `${chalk$1.magenta(`runner: [${
|
|
1680
|
-
__privateGet(this,
|
|
1681
|
-
|
|
1682
|
-
__privateGet(this,
|
|
1733
|
+
const runnerId = testRunnerTelemetryPayload.runner.id;
|
|
1734
|
+
__privateGet(this, _debug).call(this, `${chalk$1.magenta(`runner: [${runnerId}]`)} TerminateRunner`);
|
|
1735
|
+
__privateGet(this, _UpdateRunnerStateById).call(this, runnerId, IRunnerState.terminating);
|
|
1736
|
+
await Sleep(0);
|
|
1737
|
+
const retVal = await __privateGet(this, _GetRunnerInstanceById).call(this, runnerId).TerminateRunner();
|
|
1738
|
+
__privateGet(this, _UpdateRunnerStateById).call(this, runnerId, IRunnerState.terminated);
|
|
1739
|
+
__privateGet(this, _debug).call(this, `${chalk$1.magenta(`runner: [${runnerId}]`)} TerminateRunner Result = [${retVal}]`);
|
|
1683
1740
|
await Sleep(0);
|
|
1684
1741
|
});
|
|
1685
1742
|
__privateAdd(this, _PauseRunner, async (testRunnerTelemetryPayload) => {
|
|
1686
|
-
const
|
|
1687
|
-
__privateGet(this, _debug).call(this, `${chalk$1.magenta(`runner: [${
|
|
1688
|
-
__privateGet(this,
|
|
1689
|
-
await
|
|
1743
|
+
const runnerId = testRunnerTelemetryPayload.runner.id;
|
|
1744
|
+
__privateGet(this, _debug).call(this, `${chalk$1.magenta(`runner: [${runnerId}]`)} PauseRunner`);
|
|
1745
|
+
__privateGet(this, _UpdateRunnerStateById).call(this, runnerId, IRunnerState.pausing);
|
|
1746
|
+
await Sleep(0);
|
|
1747
|
+
await __privateGet(this, _GetRunnerInstanceById).call(this, runnerId).PauseRunner();
|
|
1748
|
+
__privateGet(this, _UpdateRunnerStateById).call(this, runnerId, IRunnerState.paused);
|
|
1690
1749
|
await Sleep(0);
|
|
1691
1750
|
});
|
|
1692
1751
|
__privateAdd(this, _ResumeRunner, async (testRunnerTelemetryPayload) => {
|
|
1693
|
-
const
|
|
1694
|
-
__privateGet(this, _debug).call(this, `${chalk$1.magenta(`runner: [${
|
|
1695
|
-
__privateGet(this,
|
|
1696
|
-
await
|
|
1752
|
+
const runnerId = testRunnerTelemetryPayload.runner.id;
|
|
1753
|
+
__privateGet(this, _debug).call(this, `${chalk$1.magenta(`runner: [${runnerId}]`)} ResumeRunner`);
|
|
1754
|
+
__privateGet(this, _UpdateRunnerStateById).call(this, runnerId, IRunnerState.resuming);
|
|
1755
|
+
await Sleep(0);
|
|
1756
|
+
await __privateGet(this, _GetRunnerInstanceById).call(this, runnerId).ResumeRunner();
|
|
1757
|
+
__privateGet(this, _UpdateRunnerStateById).call(this, runnerId, IRunnerState.resumed);
|
|
1697
1758
|
await Sleep(0);
|
|
1698
1759
|
});
|
|
1699
1760
|
__privateAdd(this, _ResetRunner, async (testRunnerTelemetryPayload) => {
|
|
1700
|
-
const
|
|
1701
|
-
__privateGet(this, _debug).call(this, `${chalk$1.magenta(`runner: [${
|
|
1702
|
-
__privateGet(this,
|
|
1703
|
-
__privateGet(this,
|
|
1704
|
-
await
|
|
1761
|
+
const runnerId = testRunnerTelemetryPayload.runner.id;
|
|
1762
|
+
__privateGet(this, _debug).call(this, `${chalk$1.magenta(`runner: [${runnerId}]`)} ResetRunner`);
|
|
1763
|
+
__privateGet(this, _ResetRunnerIterationById).call(this, runnerId);
|
|
1764
|
+
__privateGet(this, _UpdateRunnerStateById).call(this, runnerId, IRunnerState.resetting);
|
|
1765
|
+
await Sleep(0);
|
|
1766
|
+
await __privateGet(this, _GetRunnerInstanceById).call(this, runnerId).ResetRunner();
|
|
1767
|
+
__privateGet(this, _UpdateRunnerStateById).call(this, runnerId, IRunnerState.reset);
|
|
1705
1768
|
await Sleep(0);
|
|
1706
1769
|
});
|
|
1707
1770
|
// Execute a single iteration of this runners work item
|
|
1708
1771
|
__privateAdd(this, _ExecuteRunner, async (testRunnerTelemetryPayload) => {
|
|
1709
|
-
const
|
|
1710
|
-
__privateGet(this, _debug).call(this, `${chalk$1.magenta(`runner: [${
|
|
1711
|
-
|
|
1712
|
-
|
|
1772
|
+
const runnerId = testRunnerTelemetryPayload.runner.id;
|
|
1773
|
+
__privateGet(this, _debug).call(this, `${chalk$1.magenta(`runner: [${runnerId}]`)} ExecuteRunner`);
|
|
1774
|
+
__privateGet(this, _UpdateRunnerStateById).call(this, runnerId, IRunnerState.executing);
|
|
1775
|
+
await Sleep(0);
|
|
1776
|
+
await __privateGet(this, _GetRunnerInstanceById).call(this, runnerId).Execute(__privateGet(this, _GetRunnerIterationById).call(this, runnerId));
|
|
1777
|
+
__privateGet(this, _IncRunnerIterationById).call(this, runnerId);
|
|
1778
|
+
__privateGet(this, _UpdateRunnerStateById).call(this, runnerId, IRunnerState.executed);
|
|
1713
1779
|
await Sleep(0);
|
|
1714
1780
|
});
|
|
1715
1781
|
__privateAdd(this, _UpdateOptions, async (testRunnerTelemetryPayload) => {
|
|
1716
|
-
const
|
|
1717
|
-
__privateGet(this, _debug).call(this, `${chalk$1.magenta(`runner: [${
|
|
1718
|
-
console.log(chalk$1.cyan(`before: [${JSON.stringify(__privateGet(this,
|
|
1719
|
-
__privateGet(this,
|
|
1720
|
-
console.log(chalk$1.cyan(`after: [${JSON.stringify(__privateGet(this,
|
|
1721
|
-
await __privateGet(this,
|
|
1782
|
+
const runnerId = testRunnerTelemetryPayload.runner.id;
|
|
1783
|
+
__privateGet(this, _debug).call(this, `${chalk$1.magenta(`runner: [${runnerId}]`)} UpdateOptions`);
|
|
1784
|
+
console.log(chalk$1.cyan(`before: [${JSON.stringify(__privateGet(this, _GetRunnerOptionsById).call(this, runnerId))}]`));
|
|
1785
|
+
__privateGet(this, _SetRunnerOptionsById).call(this, runnerId, testRunnerTelemetryPayload.runner.options);
|
|
1786
|
+
console.log(chalk$1.cyan(`after: [${JSON.stringify(__privateGet(this, _GetRunnerOptionsById).call(this, runnerId))}]`));
|
|
1787
|
+
await __privateGet(this, _GetRunnerInstanceById).call(this, runnerId).UpdateOptions();
|
|
1722
1788
|
await Sleep(0);
|
|
1723
1789
|
});
|
|
1724
1790
|
// ProcessMessage = async(data: MessageEvent) => { // Browser version
|
|
@@ -1797,6 +1863,17 @@ _options3 = new WeakMap();
|
|
|
1797
1863
|
_workerId = new WeakMap();
|
|
1798
1864
|
_debug = new WeakMap();
|
|
1799
1865
|
_SetMessagePort = new WeakMap();
|
|
1866
|
+
_CreateRunnerEx2RunState = new WeakMap();
|
|
1867
|
+
_UpdateRunnerStateById = new WeakMap();
|
|
1868
|
+
_GetAllRunners = new WeakMap();
|
|
1869
|
+
_CanExecuteNextIterationById = new WeakMap();
|
|
1870
|
+
_GetRunnerIterationById = new WeakMap();
|
|
1871
|
+
_ResetRunnerIterationById = new WeakMap();
|
|
1872
|
+
_IncRunnerIterationById = new WeakMap();
|
|
1873
|
+
_GetRunnerInstanceById = new WeakMap();
|
|
1874
|
+
_GetRunnerExecutionProfileById = new WeakMap();
|
|
1875
|
+
_GetRunnerOptionsById = new WeakMap();
|
|
1876
|
+
_SetRunnerOptionsById = new WeakMap();
|
|
1800
1877
|
_AddRunner = new WeakMap();
|
|
1801
1878
|
_WorkerInstance_instances = new WeakSet();
|
|
1802
1879
|
SleepImmediate_fn = function() {
|
|
@@ -1804,7 +1881,9 @@ SleepImmediate_fn = function() {
|
|
|
1804
1881
|
resolve();
|
|
1805
1882
|
});
|
|
1806
1883
|
};
|
|
1884
|
+
_PostMessageToWorkerManagerById = new WeakMap();
|
|
1807
1885
|
_StartRunner = new WeakMap();
|
|
1886
|
+
_StopRunnerByRunnerById = new WeakMap();
|
|
1808
1887
|
_StopAllRunners = new WeakMap();
|
|
1809
1888
|
_StopRunner = new WeakMap();
|
|
1810
1889
|
_TerminateRunner = new WeakMap();
|
|
@@ -1974,10 +2053,17 @@ class STSWorkerManager {
|
|
|
1974
2053
|
} else {
|
|
1975
2054
|
workerFactory = __privateGet(this, _options4).workerFactory;
|
|
1976
2055
|
}
|
|
2056
|
+
const {
|
|
2057
|
+
port1,
|
|
2058
|
+
// process message port
|
|
2059
|
+
port2
|
|
2060
|
+
// collector message port
|
|
2061
|
+
} = new MessageChannel();
|
|
1977
2062
|
const workerId = v4$1();
|
|
1978
2063
|
const stsWorkerEx = {
|
|
1979
2064
|
id: workerId,
|
|
1980
2065
|
worker: workerFactory.createWorkerThreadWorker(),
|
|
2066
|
+
messagePort: port1,
|
|
1981
2067
|
state: IWorkerState.starting,
|
|
1982
2068
|
workerThreadWorkerOptions: workerFactory.workerThreadWorkerOptions,
|
|
1983
2069
|
runnersEx: {},
|
|
@@ -2005,36 +2091,44 @@ class STSWorkerManager {
|
|
|
2005
2091
|
};
|
|
2006
2092
|
__privateGet(this, _STSInstrumentController).LogEx(chalk$1.yellow(`pid: [${process.pid}] Creating new worker: [${stsWorkerEx.id}]`));
|
|
2007
2093
|
__privateGet(this, _debug2).call(this, `Adding worker: [${stsWorkerEx.id}]`);
|
|
2008
|
-
const {
|
|
2009
|
-
port1,
|
|
2010
|
-
// process message port
|
|
2011
|
-
port2
|
|
2012
|
-
// collector message port
|
|
2013
|
-
} = new MessageChannel();
|
|
2014
|
-
const workerPort = port1;
|
|
2015
2094
|
__privateGet(this, _debug2).call(this, `AddWorker::workerThreadWorkerOptions: [${stsWorkerEx.workerThreadWorkerOptions.id}]`);
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
console.log(chalk$1.magenta(`STSWorkerManager:stsWorkerEx.worker.on(exit): Worker exited with code: ${code}`));
|
|
2027
|
-
});
|
|
2028
|
-
stsWorkerEx.worker.on("error", (error) => {
|
|
2029
|
-
console.error(chalk$1.red(`STSWorkerManager:stsWorkerEx.worker.on(error): Worker error: ${error}`));
|
|
2095
|
+
if (stsWorkerEx.workerThreadWorkerOptions.mocked) {
|
|
2096
|
+
stsWorkerEx.worker.SetPort({
|
|
2097
|
+
command: eIWMessageCommands.MessagePort,
|
|
2098
|
+
payload: {
|
|
2099
|
+
port: port2,
|
|
2100
|
+
options: {
|
|
2101
|
+
...stsWorkerEx.workerThreadWorkerOptions
|
|
2102
|
+
},
|
|
2103
|
+
workerId
|
|
2104
|
+
}
|
|
2030
2105
|
});
|
|
2031
2106
|
} else {
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2107
|
+
__privateGet(this, _PostMessageToWorkerUsingDefaultChannel).call(this, stsWorkerEx, eIWMessageCommands.MessagePort, {
|
|
2108
|
+
port: port2,
|
|
2109
|
+
//applicationStoreState: stateCopy,
|
|
2110
|
+
options: {
|
|
2111
|
+
...stsWorkerEx.workerThreadWorkerOptions
|
|
2112
|
+
},
|
|
2113
|
+
workerId
|
|
2114
|
+
}, port2);
|
|
2115
|
+
}
|
|
2116
|
+
if (!stsWorkerEx.workerThreadWorkerOptions.mocked) {
|
|
2117
|
+
if (isNode$1) {
|
|
2118
|
+
stsWorkerEx.worker.on("exit", (code) => {
|
|
2119
|
+
console.log(chalk$1.magenta(`STSWorkerManager:stsWorkerEx.worker.on(exit): Worker exited with code: ${code}`));
|
|
2120
|
+
});
|
|
2121
|
+
stsWorkerEx.worker.on("error", (error) => {
|
|
2122
|
+
console.error(chalk$1.red(`STSWorkerManager:stsWorkerEx.worker.on(error): Worker error: ${error}`));
|
|
2123
|
+
});
|
|
2124
|
+
} else {
|
|
2125
|
+
stsWorkerEx.worker.onerror = (error) => {
|
|
2126
|
+
console.error(chalk$1.red("STSWorkerManager:stsWorkerEx.worker.onerror(): Error in worker:", error));
|
|
2127
|
+
};
|
|
2128
|
+
stsWorkerEx.worker.onmessageerror = (error) => {
|
|
2129
|
+
console.error(chalk$1.red("STSWorkerManager:stsWorkerEx.worker.onmessageerror(): Message error in worker:", error));
|
|
2130
|
+
};
|
|
2131
|
+
}
|
|
2038
2132
|
}
|
|
2039
2133
|
const processMessage = (data) => {
|
|
2040
2134
|
const publishMessagePayload2 = data;
|
|
@@ -2048,18 +2142,21 @@ class STSWorkerManager {
|
|
|
2048
2142
|
case eIWMessageCommands.Completed:
|
|
2049
2143
|
__privateGet(this, _ProcessCompleted).call(this, stsWorkerEx, publishMessagePayload2.payload);
|
|
2050
2144
|
break;
|
|
2145
|
+
case eIWMessageCommands.RunnerStateChange:
|
|
2146
|
+
__privateGet(this, _RunnerStateChange).call(this, stsWorkerEx, publishMessagePayload2.payload);
|
|
2147
|
+
break;
|
|
2051
2148
|
default:
|
|
2052
2149
|
__privateGet(this, _debug2).call(this, `AddWorker::default`);
|
|
2053
2150
|
}
|
|
2054
2151
|
};
|
|
2055
2152
|
let publishMessagePayload;
|
|
2056
2153
|
if (isNode$1) {
|
|
2057
|
-
|
|
2154
|
+
stsWorkerEx.messagePort.on("message", (data) => {
|
|
2058
2155
|
publishMessagePayload = data;
|
|
2059
2156
|
processMessage(publishMessagePayload);
|
|
2060
2157
|
});
|
|
2061
2158
|
} else {
|
|
2062
|
-
|
|
2159
|
+
stsWorkerEx.messagePort.onmessage = async (data) => {
|
|
2063
2160
|
publishMessagePayload = data.data;
|
|
2064
2161
|
processMessage(publishMessagePayload);
|
|
2065
2162
|
};
|
|
@@ -2102,6 +2199,13 @@ class STSWorkerManager {
|
|
|
2102
2199
|
}
|
|
2103
2200
|
}
|
|
2104
2201
|
});
|
|
2202
|
+
__privateAdd(this, _RunnerStateChange, (workerEx, payloadContents) => {
|
|
2203
|
+
const { runner } = payloadContents;
|
|
2204
|
+
if (workerEx.runnersEx[runner.id]) {
|
|
2205
|
+
const runnerEx = workerEx.runnersEx[runner.id];
|
|
2206
|
+
runnerEx.state = runner.state;
|
|
2207
|
+
}
|
|
2208
|
+
});
|
|
2105
2209
|
__privateAdd(this, _ProcessCompleted, (workerEx, payloadContents) => {
|
|
2106
2210
|
const { runner } = payloadContents;
|
|
2107
2211
|
if (workerEx.runnersEvents[runner.id]) {
|
|
@@ -2125,6 +2229,8 @@ class STSWorkerManager {
|
|
|
2125
2229
|
};
|
|
2126
2230
|
const runnerEx = {
|
|
2127
2231
|
id: runnerOptions.id,
|
|
2232
|
+
state: IRunnerState.created,
|
|
2233
|
+
iteration: 0,
|
|
2128
2234
|
publishInstrumentController: __privateGet(this, _STSInstrumentController).AddPublishInstrumentController(asyncRunnerContext),
|
|
2129
2235
|
asyncRunnerContext,
|
|
2130
2236
|
options: runnerOptions,
|
|
@@ -2167,7 +2273,7 @@ class STSWorkerManager {
|
|
|
2167
2273
|
};
|
|
2168
2274
|
return runnerEx;
|
|
2169
2275
|
});
|
|
2170
|
-
__privateAdd(this,
|
|
2276
|
+
__privateAdd(this, _PostMessageToWorkerUsingDefaultChannel, (workerEx, command, payload, transferObject) => {
|
|
2171
2277
|
if (transferObject) {
|
|
2172
2278
|
__privateGet(this, _debug2).call(this, `#PostMessageToWorker with transfer object`);
|
|
2173
2279
|
workerEx.worker.postMessage({ command, payload }, [transferObject]);
|
|
@@ -2177,28 +2283,36 @@ class STSWorkerManager {
|
|
|
2177
2283
|
workerEx.worker.postMessage({ command, payload });
|
|
2178
2284
|
}
|
|
2179
2285
|
});
|
|
2286
|
+
__privateAdd(this, _PostMessageToWorker, (workerEx, command, payload) => {
|
|
2287
|
+
__privateGet(this, _debug2).call(this, `#PostMessageToWorker`);
|
|
2288
|
+
workerEx.messagePort.postMessage({ command, payload });
|
|
2289
|
+
});
|
|
2180
2290
|
__privateAdd(this, _StartRunner2, async (workerEx, runnerEx) => {
|
|
2181
2291
|
__privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.StartRunner, {
|
|
2182
2292
|
runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopy_fn).call(this, runnerEx)
|
|
2183
2293
|
});
|
|
2294
|
+
runnerEx.state = IRunnerState.running;
|
|
2184
2295
|
return true;
|
|
2185
2296
|
});
|
|
2186
2297
|
__privateAdd(this, _ResetRunner2, async (workerEx, runnerEx) => {
|
|
2187
2298
|
__privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.ResetRunner, {
|
|
2188
2299
|
runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopy_fn).call(this, runnerEx)
|
|
2189
2300
|
});
|
|
2301
|
+
runnerEx.state = IRunnerState.stopped;
|
|
2190
2302
|
return true;
|
|
2191
2303
|
});
|
|
2192
2304
|
__privateAdd(this, _ExecuteRunner2, async (workerEx, runnerEx) => {
|
|
2193
2305
|
__privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.ExecuteRunner, {
|
|
2194
2306
|
runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopy_fn).call(this, runnerEx)
|
|
2195
2307
|
});
|
|
2308
|
+
runnerEx.state = IRunnerState.running;
|
|
2196
2309
|
return true;
|
|
2197
2310
|
});
|
|
2198
2311
|
__privateAdd(this, _StopRunner2, async (workerEx, runnerEx) => {
|
|
2199
2312
|
__privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.StopRunner, {
|
|
2200
2313
|
runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopy_fn).call(this, runnerEx)
|
|
2201
2314
|
});
|
|
2315
|
+
runnerEx.state = IRunnerState.stopped;
|
|
2202
2316
|
return true;
|
|
2203
2317
|
});
|
|
2204
2318
|
__privateAdd(this, _TerminateRunner2, async (workerEx, runnerEx = null) => {
|
|
@@ -2393,13 +2507,17 @@ CreateRunnerCopy_fn = function(runnerEx) {
|
|
|
2393
2507
|
id: runnerEx.id,
|
|
2394
2508
|
asyncRunnerContext: { ...runnerEx.asyncRunnerContext },
|
|
2395
2509
|
options: { ...runnerEx.options },
|
|
2396
|
-
instrumentData: { ...runnerEx.instrumentData }
|
|
2510
|
+
instrumentData: { ...runnerEx.instrumentData },
|
|
2511
|
+
iteration: runnerEx.iteration,
|
|
2512
|
+
state: runnerEx.state
|
|
2397
2513
|
};
|
|
2398
2514
|
};
|
|
2399
2515
|
_SetRunnerIntoWorker = new WeakMap();
|
|
2400
2516
|
_ProcessTelemetry = new WeakMap();
|
|
2517
|
+
_RunnerStateChange = new WeakMap();
|
|
2401
2518
|
_ProcessCompleted = new WeakMap();
|
|
2402
2519
|
_CreateAsyncRunner = new WeakMap();
|
|
2520
|
+
_PostMessageToWorkerUsingDefaultChannel = new WeakMap();
|
|
2403
2521
|
_PostMessageToWorker = new WeakMap();
|
|
2404
2522
|
_StartRunner2 = new WeakMap();
|
|
2405
2523
|
_ResetRunner2 = new WeakMap();
|