@nsshunt/stsrunnerframework 1.0.200 → 2.0.1
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/README.md +1059 -1
- package/dist/stsrunnerframework.mjs +8263 -4105
- package/dist/stsrunnerframework.mjs.map +1 -1
- package/dist/stsrunnerframework.umd.js +8288 -4119
- package/dist/stsrunnerframework.umd.js.map +1 -1
- package/package.json +4 -4
- package/types/abstractRunnerExecutionWorker.d.ts +194 -0
- package/types/abstractRunnerExecutionWorker.d.ts.map +1 -0
- package/types/archiveManager.d.ts +172 -0
- package/types/archiveManager.d.ts.map +1 -0
- package/types/asyncRunnerInstanceManager.d.ts +108 -0
- package/types/asyncRunnerInstanceManager.d.ts.map +1 -0
- package/types/commonTypes.d.ts +115 -35
- package/types/commonTypes.d.ts.map +1 -1
- package/types/index.d.ts +1 -1
- package/types/index.d.ts.map +1 -1
- package/types/messageBroker.d.ts +324 -0
- package/types/messageBroker.d.ts.map +1 -0
- package/types/runnerInstance.d.ts +245 -0
- package/types/runnerInstance.d.ts.map +1 -0
- package/types/runnerLifecycleManager.d.ts +210 -0
- package/types/runnerLifecycleManager.d.ts.map +1 -0
- package/types/telemetryProcessor.d.ts +67 -0
- package/types/telemetryProcessor.d.ts.map +1 -1
- package/types/testing/mockedWorkerTestRunner01.d.ts +129 -2
- package/types/testing/mockedWorkerTestRunner01.d.ts.map +1 -1
- package/types/testing/testCase01.d.ts +222 -2
- package/types/testing/testCase01.d.ts.map +1 -1
- package/types/testing/testCase02.d.ts +206 -2
- package/types/testing/testCase02.d.ts.map +1 -1
- package/types/testing/wmwokerProcess.test.d.ts +1 -0
- package/types/testing/wmwokerProcess2.test.d.ts +1 -0
- package/types/workerCommandCoordinator.d.ts +152 -0
- package/types/workerCommandCoordinator.d.ts.map +1 -0
- package/types/workerInstance.d.ts +340 -16
- package/types/workerInstance.d.ts.map +1 -1
- package/types/workerInstanceMannager.d.ts +170 -0
- package/types/workerInstanceMannager.d.ts.map +1 -0
- package/types/workerManager.d.ts +335 -24
- package/types/workerManager.d.ts.map +1 -1
- package/types/workerRegistry.d.ts +251 -0
- package/types/workerRegistry.d.ts.map +1 -0
- package/types/workerStateSynchroniser.d.ts +161 -0
- package/types/workerStateSynchroniser.d.ts.map +1 -0
|
@@ -1,21 +1,241 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* TestCase01
|
|
4
|
+
* ==========
|
|
5
|
+
*
|
|
6
|
+
* Concrete test runner implementation used to validate the runner framework.
|
|
7
|
+
*
|
|
8
|
+
* Purpose
|
|
9
|
+
* -------
|
|
10
|
+
* `TestCase01` is a synthetic/example runner that performs predictable,
|
|
11
|
+
* low-risk work so the surrounding framework can be tested.
|
|
12
|
+
*
|
|
13
|
+
* It is designed to exercise and demonstrate:
|
|
14
|
+
*
|
|
15
|
+
* - runner lifecycle methods
|
|
16
|
+
* - start
|
|
17
|
+
* - stop
|
|
18
|
+
* - pause
|
|
19
|
+
* - resume
|
|
20
|
+
* - reset
|
|
21
|
+
* - update
|
|
22
|
+
* - complete
|
|
23
|
+
* - terminate
|
|
24
|
+
* - telemetry generation and batching
|
|
25
|
+
* - log message generation
|
|
26
|
+
* - metric updates
|
|
27
|
+
* - active request tracking
|
|
28
|
+
* - duration measurement
|
|
29
|
+
* - delayed work simulation using `Sleep(...)`
|
|
30
|
+
*
|
|
31
|
+
* It does not perform real business work. Instead, it simulates work by:
|
|
32
|
+
*
|
|
33
|
+
* - updating telemetry counters
|
|
34
|
+
* - optionally sleeping for a configured duration
|
|
35
|
+
* - generating periodic messages
|
|
36
|
+
* - publishing telemetry using batching and timeout logic
|
|
37
|
+
*
|
|
38
|
+
* Architectural role
|
|
39
|
+
* ------------------
|
|
40
|
+
* This class is a concrete implementation of {@link IRunnerInstance}.
|
|
41
|
+
*
|
|
42
|
+
* It is hosted by a concrete worker-side execution host such as
|
|
43
|
+
* `WorkerTestCases`, which in turn derives from
|
|
44
|
+
* {@link AbstractRunnerExecutionWorker}.
|
|
45
|
+
*
|
|
46
|
+
* The framework uses this runner to validate that:
|
|
47
|
+
*
|
|
48
|
+
* - worker command routing works
|
|
49
|
+
* - runner execution loops work
|
|
50
|
+
* - telemetry publication works
|
|
51
|
+
* - runner lifecycle messages behave as expected
|
|
52
|
+
*/
|
|
53
|
+
import { IRunnerInstance, IRunnerOptions, IRunner } from './../index';
|
|
54
|
+
import { AbstractRunnerExecutionWorker } from './../abstractRunnerExecutionWorker';
|
|
55
|
+
/**
|
|
56
|
+
* Extended runner options used specifically by `TestCase01`.
|
|
57
|
+
*
|
|
58
|
+
* In addition to standard framework runner options, this test case supports:
|
|
59
|
+
*
|
|
60
|
+
* - `sleepDuration`
|
|
61
|
+
* - `logMessageMod`
|
|
62
|
+
* - `colourIndex`
|
|
63
|
+
*
|
|
64
|
+
* These fields allow the test runner to simulate work and produce predictable
|
|
65
|
+
* telemetry/logging behaviour.
|
|
66
|
+
*/
|
|
2
67
|
export interface IRunnerOptionsEx extends IRunnerOptions {
|
|
68
|
+
/**
|
|
69
|
+
* Simulated work delay in milliseconds for each execution iteration.
|
|
70
|
+
*
|
|
71
|
+
* If greater than zero, the runner sleeps for this duration inside `ExecuteRunner()`.
|
|
72
|
+
* If zero, it yields immediately instead.
|
|
73
|
+
*/
|
|
3
74
|
sleepDuration: number;
|
|
75
|
+
/**
|
|
76
|
+
* Frequency for generating animated log messages.
|
|
77
|
+
*
|
|
78
|
+
* Example:
|
|
79
|
+
* - if `logMessageMod` is `5`, a generated log message is emitted every 5 requests.
|
|
80
|
+
*/
|
|
4
81
|
logMessageMod: number;
|
|
82
|
+
/**
|
|
83
|
+
* Placeholder/example option for colour selection.
|
|
84
|
+
*
|
|
85
|
+
* Currently present for test flexibility but not actively used in the logic shown here.
|
|
86
|
+
*/
|
|
5
87
|
colourIndex: number;
|
|
6
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* Concrete synthetic test runner implementation.
|
|
91
|
+
*
|
|
92
|
+
* This runner:
|
|
93
|
+
* - simulates work
|
|
94
|
+
* - updates telemetry counters
|
|
95
|
+
* - batches telemetry publishing
|
|
96
|
+
* - emits lifecycle log messages
|
|
97
|
+
*/
|
|
7
98
|
export declare class TestCase01 implements IRunnerInstance {
|
|
8
99
|
#private;
|
|
9
|
-
|
|
100
|
+
/**
|
|
101
|
+
* Construct a new synthetic test runner.
|
|
102
|
+
*
|
|
103
|
+
* @param runnerExecutionWorker Owning worker-side execution host.
|
|
104
|
+
* @param runner Live runner model/state for this test runner.
|
|
105
|
+
*/
|
|
106
|
+
constructor(runnerExecutionWorker: AbstractRunnerExecutionWorker, runner: IRunner);
|
|
107
|
+
/**
|
|
108
|
+
* Yield immediately to the event loop/microtask queue.
|
|
109
|
+
*
|
|
110
|
+
* Used when the runner wants to behave asynchronously but does not need
|
|
111
|
+
* a real delay.
|
|
112
|
+
*
|
|
113
|
+
* @returns Resolved promise.
|
|
114
|
+
*/
|
|
10
115
|
SleepImmediate(): Promise<void>;
|
|
116
|
+
/**
|
|
117
|
+
* Execute one synthetic unit of work for this runner.
|
|
118
|
+
*
|
|
119
|
+
* Behaviour
|
|
120
|
+
* ---------
|
|
121
|
+
* - captures start time
|
|
122
|
+
* - reads extended runner options
|
|
123
|
+
* - updates telemetry counters/metrics
|
|
124
|
+
* - optionally generates log messages
|
|
125
|
+
* - optionally emits status/progress messages
|
|
126
|
+
* - simulates actual work using:
|
|
127
|
+
* - `Sleep(options.sleepDuration)`, or
|
|
128
|
+
* - immediate yield
|
|
129
|
+
* - decrements active request count
|
|
130
|
+
* - records duration
|
|
131
|
+
* - publishes telemetry using buffered publish logic
|
|
132
|
+
*
|
|
133
|
+
* Telemetry updates performed
|
|
134
|
+
* ---------------------------
|
|
135
|
+
* - `coreCount = 1`
|
|
136
|
+
* - `activeRequestCount++`
|
|
137
|
+
* - `requestCount++`
|
|
138
|
+
* - `velocity++`
|
|
139
|
+
* - `tx += 256000`
|
|
140
|
+
* - `rx += 6500000`
|
|
141
|
+
* - `duration = measured execution time`
|
|
142
|
+
*
|
|
143
|
+
* Notes
|
|
144
|
+
* -----
|
|
145
|
+
* - This method simulates real work rather than performing domain logic
|
|
146
|
+
* - It is intended to validate the framework's runner/telemetry lifecycle
|
|
147
|
+
* - After the awaited work delay, the actual framework runner state may have
|
|
148
|
+
* changed externally, but this test implementation does not directly react here
|
|
149
|
+
*
|
|
150
|
+
* @returns `true` when the synthetic work cycle completes.
|
|
151
|
+
*/
|
|
11
152
|
ExecuteRunner: () => Promise<any>;
|
|
153
|
+
/**
|
|
154
|
+
* Handle framework "start" lifecycle event for this runner.
|
|
155
|
+
*
|
|
156
|
+
* Behaviour:
|
|
157
|
+
* - writes a lifecycle message
|
|
158
|
+
* - forces immediate telemetry publication
|
|
159
|
+
*
|
|
160
|
+
* @returns `true`
|
|
161
|
+
*/
|
|
12
162
|
StartRunner: () => Promise<any>;
|
|
163
|
+
/**
|
|
164
|
+
* Handle framework "stop" lifecycle event for this runner.
|
|
165
|
+
*
|
|
166
|
+
* Behaviour:
|
|
167
|
+
* - writes a lifecycle message
|
|
168
|
+
* - forces immediate telemetry publication
|
|
169
|
+
*
|
|
170
|
+
* @returns `true`
|
|
171
|
+
*/
|
|
13
172
|
StopRunner: () => Promise<any>;
|
|
173
|
+
/**
|
|
174
|
+
* Handle framework "terminate" lifecycle event for this runner.
|
|
175
|
+
*
|
|
176
|
+
* Behaviour:
|
|
177
|
+
* - writes a lifecycle message
|
|
178
|
+
* - forces immediate telemetry publication
|
|
179
|
+
*
|
|
180
|
+
* @returns `true`
|
|
181
|
+
*/
|
|
14
182
|
TerminateRunner: () => Promise<any>;
|
|
183
|
+
/**
|
|
184
|
+
* Handle framework "completed" lifecycle event for this runner.
|
|
185
|
+
*
|
|
186
|
+
* Behaviour:
|
|
187
|
+
* - writes a completion lifecycle message including current telemetry snapshot
|
|
188
|
+
* - forces immediate telemetry publication
|
|
189
|
+
*
|
|
190
|
+
* @returns `true`
|
|
191
|
+
*/
|
|
15
192
|
Completed: () => Promise<any>;
|
|
193
|
+
/**
|
|
194
|
+
* Handle framework "pause" lifecycle event for this runner.
|
|
195
|
+
*
|
|
196
|
+
* Behaviour:
|
|
197
|
+
* - writes a lifecycle message
|
|
198
|
+
* - forces immediate telemetry publication
|
|
199
|
+
* - returns a descriptive diagnostic string
|
|
200
|
+
*
|
|
201
|
+
* @returns Diagnostic pause message.
|
|
202
|
+
*/
|
|
16
203
|
PauseRunner: () => Promise<any>;
|
|
204
|
+
/**
|
|
205
|
+
* Handle framework "resume" lifecycle event for this runner.
|
|
206
|
+
*
|
|
207
|
+
* Behaviour:
|
|
208
|
+
* - writes a lifecycle message
|
|
209
|
+
* - forces immediate telemetry publication
|
|
210
|
+
* - returns a descriptive diagnostic string
|
|
211
|
+
*
|
|
212
|
+
* @returns Diagnostic resume message.
|
|
213
|
+
*/
|
|
17
214
|
ResumeRunner: () => Promise<any>;
|
|
215
|
+
/**
|
|
216
|
+
* Handle framework "reset" lifecycle event for this runner.
|
|
217
|
+
*
|
|
218
|
+
* Behaviour:
|
|
219
|
+
* - writes a lifecycle message
|
|
220
|
+
* - resets `requestCount` to zero
|
|
221
|
+
* - forces immediate telemetry publication
|
|
222
|
+
*
|
|
223
|
+
* @returns `true`
|
|
224
|
+
*/
|
|
18
225
|
ResetRunner: () => Promise<any>;
|
|
226
|
+
/**
|
|
227
|
+
* Handle framework "update" lifecycle event for this runner.
|
|
228
|
+
*
|
|
229
|
+
* Behaviour:
|
|
230
|
+
* - writes a lifecycle message
|
|
231
|
+
* - forces immediate telemetry publication
|
|
232
|
+
*
|
|
233
|
+
* Note:
|
|
234
|
+
* - this implementation does not directly apply option changes itself;
|
|
235
|
+
* it simply acknowledges the lifecycle event for framework testing
|
|
236
|
+
*
|
|
237
|
+
* @returns `true`
|
|
238
|
+
*/
|
|
19
239
|
UpdateRunner: () => Promise<any>;
|
|
20
240
|
}
|
|
21
241
|
//# sourceMappingURL=testCase01.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testCase01.d.ts","sourceRoot":"","sources":["../../src/testing/testCase01.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"testCase01.d.ts","sourceRoot":"","sources":["../../src/testing/testCase01.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AAEH,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACtE,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AA0CnF;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,gBAAiB,SAAQ,cAAc;IACpD;;;;;OAKG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;;;;OAKG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;GAQG;AACH,qBAAa,UAAW,YAAW,eAAe;;IAqD9C;;;;;OAKG;gBACS,qBAAqB,EAAE,6BAA6B,EAAE,MAAM,EAAE,OAAO;IA0KjF;;;;;;;OAOG;IACH,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAM/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACH,aAAa,QAAa,OAAO,CAAC,GAAG,CAAC,CA+CpC;IAeF;;;;;;;;OAQG;IACH,WAAW,QAAa,OAAO,CAAC,GAAG,CAAC,CAIlC;IAEF;;;;;;;;OAQG;IACH,UAAU,QAAa,OAAO,CAAC,GAAG,CAAC,CAIjC;IAEF;;;;;;;;OAQG;IACH,eAAe,QAAa,OAAO,CAAC,GAAG,CAAC,CAItC;IAEF;;;;;;;;OAQG;IACH,SAAS,QAAa,OAAO,CAAC,GAAG,CAAC,CAIhC;IAEF;;;;;;;;;OASG;IACH,WAAW,QAAa,OAAO,CAAC,GAAG,CAAC,CAIlC;IAEF;;;;;;;;;OASG;IACH,YAAY,QAAa,OAAO,CAAC,GAAG,CAAC,CAInC;IAEF;;;;;;;;;OASG;IACH,WAAW,QAAa,OAAO,CAAC,GAAG,CAAC,CAKlC;IAEF;;;;;;;;;;;;OAYG;IACH,YAAY,QAAa,OAAO,CAAC,GAAG,CAAC,CAInC;CACL"}
|
|
@@ -1,21 +1,225 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* TestCase02
|
|
4
|
+
* ==========
|
|
5
|
+
*
|
|
6
|
+
* Second concrete example runner used to test and demonstrate the runner framework.
|
|
7
|
+
*
|
|
8
|
+
* Purpose
|
|
9
|
+
* -------
|
|
10
|
+
* `TestCase02` is a synthetic runner implementation very similar to `TestCase01`,
|
|
11
|
+
* but with slightly different behaviour and output style. It is intended to help
|
|
12
|
+
* validate that the framework can host multiple concrete runner types behind the
|
|
13
|
+
* same worker/runtime abstraction.
|
|
14
|
+
*
|
|
15
|
+
* This test runner is useful for exercising:
|
|
16
|
+
*
|
|
17
|
+
* - runner lifecycle callbacks
|
|
18
|
+
* - telemetry batching and publishing
|
|
19
|
+
* - execution timing/duration capture
|
|
20
|
+
* - log message generation
|
|
21
|
+
* - active request tracking
|
|
22
|
+
* - update/reset/pause/resume/terminate flows
|
|
23
|
+
* - multiple concrete test runner implementations in the same framework
|
|
24
|
+
*
|
|
25
|
+
* Key difference from TestCase01
|
|
26
|
+
* ------------------------------
|
|
27
|
+
* While structurally very similar to `TestCase01`, this runner also writes a
|
|
28
|
+
* per-iteration status message directly to `console.log(...)` during execution.
|
|
29
|
+
*
|
|
30
|
+
* That makes this class useful when you want:
|
|
31
|
+
*
|
|
32
|
+
* - visible console progress while testing
|
|
33
|
+
* - easier manual observation of iteration flow
|
|
34
|
+
* - a second runner implementation to verify type-based runner selection
|
|
35
|
+
*
|
|
36
|
+
* Architectural role
|
|
37
|
+
* ------------------
|
|
38
|
+
* `TestCase02` is a concrete implementation of {@link IRunnerInstance}.
|
|
39
|
+
*
|
|
40
|
+
* It is hosted by a worker-side execution host such as `WorkerTestCases`,
|
|
41
|
+
* which itself derives from {@link AbstractRunnerExecutionWorker}.
|
|
42
|
+
*
|
|
43
|
+
* Like `TestCase01`, this runner does not perform real business work. Instead,
|
|
44
|
+
* it simulates repeatable work and emits telemetry so the surrounding framework
|
|
45
|
+
* can be validated.
|
|
46
|
+
*/
|
|
47
|
+
import { IRunnerInstance, IRunnerOptions, IRunner } from './../index';
|
|
48
|
+
import { AbstractRunnerExecutionWorker } from './../abstractRunnerExecutionWorker';
|
|
49
|
+
/**
|
|
50
|
+
* Extended runner options used by `TestCase02`.
|
|
51
|
+
*
|
|
52
|
+
* In addition to the standard runner options, this test runner supports:
|
|
53
|
+
*
|
|
54
|
+
* - `sleepDuration`
|
|
55
|
+
* - `logMessageMod`
|
|
56
|
+
* - `colourIndex`
|
|
57
|
+
*/
|
|
2
58
|
export interface IRunnerOptionsEx extends IRunnerOptions {
|
|
59
|
+
/**
|
|
60
|
+
* Simulated work delay in milliseconds for each execution cycle.
|
|
61
|
+
*/
|
|
3
62
|
sleepDuration: number;
|
|
63
|
+
/**
|
|
64
|
+
* Frequency used for generated "Hello World" log messages.
|
|
65
|
+
*
|
|
66
|
+
* Example:
|
|
67
|
+
* - if set to `10`, an animated log message is generated every 10 requests.
|
|
68
|
+
*/
|
|
4
69
|
logMessageMod: number;
|
|
70
|
+
/**
|
|
71
|
+
* Placeholder/example option for colour selection.
|
|
72
|
+
*
|
|
73
|
+
* Present for testing/extensibility, though not directly used in the logic shown.
|
|
74
|
+
*/
|
|
5
75
|
colourIndex: number;
|
|
6
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Concrete synthetic test runner implementation.
|
|
79
|
+
*
|
|
80
|
+
* This runner simulates work, updates telemetry, batches telemetry publishing,
|
|
81
|
+
* and writes both internal telemetry messages and visible console progress.
|
|
82
|
+
*/
|
|
7
83
|
export declare class TestCase02 implements IRunnerInstance {
|
|
8
84
|
#private;
|
|
9
|
-
|
|
85
|
+
/**
|
|
86
|
+
* Construct a new `TestCase02` runner.
|
|
87
|
+
*
|
|
88
|
+
* @param runnerExecutionWorker Owning worker-side execution host.
|
|
89
|
+
* @param runner Live runner model/state.
|
|
90
|
+
*/
|
|
91
|
+
constructor(runnerExecutionWorker: AbstractRunnerExecutionWorker, runner: IRunner);
|
|
92
|
+
/**
|
|
93
|
+
* Yield immediately to the event loop/microtask queue.
|
|
94
|
+
*
|
|
95
|
+
* Used when asynchronous behaviour is desired but no real delay is needed.
|
|
96
|
+
*
|
|
97
|
+
* @returns Resolved promise.
|
|
98
|
+
*/
|
|
10
99
|
SleepImmediate(): Promise<void>;
|
|
100
|
+
/**
|
|
101
|
+
* Execute one synthetic unit of work for this runner.
|
|
102
|
+
*
|
|
103
|
+
* Behaviour
|
|
104
|
+
* ---------
|
|
105
|
+
* - captures start time
|
|
106
|
+
* - reads extended test options
|
|
107
|
+
* - updates runner telemetry
|
|
108
|
+
* - optionally generates animated telemetry messages
|
|
109
|
+
* - always generates a progress message for telemetry
|
|
110
|
+
* - always writes a progress message to `console.log(...)`
|
|
111
|
+
* - simulates work with either:
|
|
112
|
+
* - `Sleep(options.sleepDuration)`, or
|
|
113
|
+
* - immediate yield
|
|
114
|
+
* - decrements active request count
|
|
115
|
+
* - calculates and stores execution duration
|
|
116
|
+
* - performs buffered telemetry publication
|
|
117
|
+
*
|
|
118
|
+
* Telemetry fields updated
|
|
119
|
+
* ------------------------
|
|
120
|
+
* - `coreCount = 1`
|
|
121
|
+
* - `activeRequestCount++`
|
|
122
|
+
* - `requestCount++`
|
|
123
|
+
* - `velocity++`
|
|
124
|
+
* - `tx += 256000`
|
|
125
|
+
* - `rx += 6500000`
|
|
126
|
+
* - `duration = measured elapsed time`
|
|
127
|
+
*
|
|
128
|
+
* Additional visible behaviour
|
|
129
|
+
* ----------------------------
|
|
130
|
+
* Unlike `TestCase01`, this implementation always writes a progress message
|
|
131
|
+
* directly to the process/browser console using `console.log(...)`.
|
|
132
|
+
*
|
|
133
|
+
* This makes it more useful for manually watching test progress while the
|
|
134
|
+
* framework is running.
|
|
135
|
+
*
|
|
136
|
+
* @returns `true` when the simulated work cycle completes.
|
|
137
|
+
*/
|
|
11
138
|
ExecuteRunner: () => Promise<boolean>;
|
|
139
|
+
/**
|
|
140
|
+
* Handle framework "start" lifecycle event.
|
|
141
|
+
*
|
|
142
|
+
* Behaviour:
|
|
143
|
+
* - writes a lifecycle message
|
|
144
|
+
* - forces immediate telemetry publication
|
|
145
|
+
*
|
|
146
|
+
* @returns `true`
|
|
147
|
+
*/
|
|
12
148
|
StartRunner: () => Promise<boolean>;
|
|
149
|
+
/**
|
|
150
|
+
* Handle framework "stop" lifecycle event.
|
|
151
|
+
*
|
|
152
|
+
* Behaviour:
|
|
153
|
+
* - writes a lifecycle message
|
|
154
|
+
* - forces immediate telemetry publication
|
|
155
|
+
*
|
|
156
|
+
* @returns `true`
|
|
157
|
+
*/
|
|
13
158
|
StopRunner: () => Promise<boolean>;
|
|
159
|
+
/**
|
|
160
|
+
* Handle framework "terminate" lifecycle event.
|
|
161
|
+
*
|
|
162
|
+
* Behaviour:
|
|
163
|
+
* - writes a lifecycle message
|
|
164
|
+
* - forces immediate telemetry publication
|
|
165
|
+
*
|
|
166
|
+
* @returns `true`
|
|
167
|
+
*/
|
|
14
168
|
TerminateRunner: () => Promise<boolean>;
|
|
169
|
+
/**
|
|
170
|
+
* Handle framework "completed" lifecycle event.
|
|
171
|
+
*
|
|
172
|
+
* Behaviour:
|
|
173
|
+
* - writes a completion message including the current telemetry snapshot
|
|
174
|
+
* - forces immediate telemetry publication
|
|
175
|
+
*
|
|
176
|
+
* @returns `true`
|
|
177
|
+
*/
|
|
15
178
|
Completed: () => Promise<boolean>;
|
|
179
|
+
/**
|
|
180
|
+
* Handle framework "pause" lifecycle event.
|
|
181
|
+
*
|
|
182
|
+
* Behaviour:
|
|
183
|
+
* - writes a lifecycle message
|
|
184
|
+
* - forces immediate telemetry publication
|
|
185
|
+
*
|
|
186
|
+
* @returns `true`
|
|
187
|
+
*/
|
|
16
188
|
PauseRunner: () => Promise<boolean>;
|
|
189
|
+
/**
|
|
190
|
+
* Handle framework "resume" lifecycle event.
|
|
191
|
+
*
|
|
192
|
+
* Behaviour:
|
|
193
|
+
* - writes a lifecycle message
|
|
194
|
+
* - forces immediate telemetry publication
|
|
195
|
+
*
|
|
196
|
+
* @returns `true`
|
|
197
|
+
*/
|
|
17
198
|
ResumeRunner: () => Promise<boolean>;
|
|
199
|
+
/**
|
|
200
|
+
* Handle framework "reset" lifecycle event.
|
|
201
|
+
*
|
|
202
|
+
* Behaviour:
|
|
203
|
+
* - writes a lifecycle message
|
|
204
|
+
* - resets `requestCount` to zero
|
|
205
|
+
* - forces immediate telemetry publication
|
|
206
|
+
*
|
|
207
|
+
* @returns `true`
|
|
208
|
+
*/
|
|
18
209
|
ResetRunner: () => Promise<boolean>;
|
|
210
|
+
/**
|
|
211
|
+
* Handle framework "update" lifecycle event.
|
|
212
|
+
*
|
|
213
|
+
* Behaviour:
|
|
214
|
+
* - writes a lifecycle message
|
|
215
|
+
* - forces immediate telemetry publication
|
|
216
|
+
*
|
|
217
|
+
* Note:
|
|
218
|
+
* - this implementation acknowledges the update event but does not apply
|
|
219
|
+
* custom update logic itself
|
|
220
|
+
*
|
|
221
|
+
* @returns `true`
|
|
222
|
+
*/
|
|
19
223
|
UpdateRunner: () => Promise<boolean>;
|
|
20
224
|
}
|
|
21
225
|
//# sourceMappingURL=testCase02.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testCase02.d.ts","sourceRoot":"","sources":["../../src/testing/testCase02.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"testCase02.d.ts","sourceRoot":"","sources":["../../src/testing/testCase02.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACtE,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AAyCnF;;;;;;;;GAQG;AACH,MAAM,WAAW,gBAAiB,SAAQ,cAAc;IACpD;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;;;;OAKG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC;CACvB;AAED;;;;;GAKG;AACH,qBAAa,UAAW,YAAW,eAAe;;IAmD9C;;;;;OAKG;gBACS,qBAAqB,EAAE,6BAA6B,EAAE,MAAM,EAAE,OAAO;IA8JjF;;;;;;OAMG;IACH,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAM/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAqCG;IACH,aAAa,QAAa,OAAO,CAAC,OAAO,CAAC,CAyDxC;IAeF;;;;;;;;OAQG;IACH,WAAW,QAAa,OAAO,CAAC,OAAO,CAAC,CAItC;IAEF;;;;;;;;OAQG;IACH,UAAU,QAAa,OAAO,CAAC,OAAO,CAAC,CAIrC;IAEF;;;;;;;;OAQG;IACH,eAAe,QAAa,OAAO,CAAC,OAAO,CAAC,CAI1C;IAEF;;;;;;;;OAQG;IACH,SAAS,QAAa,OAAO,CAAC,OAAO,CAAC,CAIpC;IAEF;;;;;;;;OAQG;IACH,WAAW,QAAa,OAAO,CAAC,OAAO,CAAC,CAItC;IAEF;;;;;;;;OAQG;IACH,YAAY,QAAa,OAAO,CAAC,OAAO,CAAC,CAIvC;IAEF;;;;;;;;;OASG;IACH,WAAW,QAAa,OAAO,CAAC,OAAO,CAAC,CAKtC;IAEF;;;;;;;;;;;;OAYG;IACH,YAAY,QAAa,OAAO,CAAC,OAAO,CAAC,CAIvC;CACL"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* WorkerCommandCoordinator
|
|
4
|
+
* ------------------------
|
|
5
|
+
* Orchestration component responsible for executing commands across:
|
|
6
|
+
*
|
|
7
|
+
* 1. one or more workers
|
|
8
|
+
* 2. one or more runners within a specific worker
|
|
9
|
+
*
|
|
10
|
+
* This class does not own workers or runners directly. Instead, it coordinates
|
|
11
|
+
* command execution using the shared {@link WorkerRegistry}.
|
|
12
|
+
*
|
|
13
|
+
* Responsibilities:
|
|
14
|
+
* - locate target workers from the registry
|
|
15
|
+
* - fan out a command to multiple workers
|
|
16
|
+
* - fan out a command to multiple runners within a worker
|
|
17
|
+
* - aggregate per-runner results into worker-level result structures
|
|
18
|
+
* - centralise error handling and logging for command orchestration
|
|
19
|
+
*
|
|
20
|
+
* Typical commands handled:
|
|
21
|
+
* - Start
|
|
22
|
+
* - Stop
|
|
23
|
+
* - Pause
|
|
24
|
+
* - Resume
|
|
25
|
+
* - Execute
|
|
26
|
+
* - Reset
|
|
27
|
+
* - Terminate
|
|
28
|
+
* - Update
|
|
29
|
+
*
|
|
30
|
+
* Notes:
|
|
31
|
+
* - Worker-level commands ultimately invoke matching methods on {@link IWorkerEx}
|
|
32
|
+
* - Runner-level commands ultimately invoke matching methods on {@link IRunnerEx}
|
|
33
|
+
* - `Update` is handled specially because it requires `runnerOptions`
|
|
34
|
+
* - An empty `workerIds` or `runnerIds` array is treated as "all"
|
|
35
|
+
* for the relevant scope, depending on how the registry/worker methods behave
|
|
36
|
+
*/
|
|
37
|
+
import { IRunnerOptions, IExecuteWorkerActionResult, IExecuteRunnerActionResult } from './commonTypes';
|
|
38
|
+
import { WorkerRegistry } from './workerRegistry';
|
|
39
|
+
import { ISTSLogger } from '@nsshunt/stsutils';
|
|
40
|
+
/**
|
|
41
|
+
* Constructor options for {@link WorkerCommandCoordinator}.
|
|
42
|
+
*/
|
|
43
|
+
export interface IWorkerCommandCoordinator {
|
|
44
|
+
/**
|
|
45
|
+
* Logger used for diagnostics and error reporting.
|
|
46
|
+
*/
|
|
47
|
+
logger: ISTSLogger;
|
|
48
|
+
/**
|
|
49
|
+
* Shared live worker registry used to resolve workers and runners.
|
|
50
|
+
*/
|
|
51
|
+
workerRegistry: WorkerRegistry;
|
|
52
|
+
/**
|
|
53
|
+
* Id of the top-level worker manager that owns the workers being coordinated.
|
|
54
|
+
*
|
|
55
|
+
* This value is included in worker-level result payloads so callers can
|
|
56
|
+
* trace results back to the manager instance that executed them.
|
|
57
|
+
*/
|
|
58
|
+
workerManagerId: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Central coordinator for worker-level and runner-level command execution.
|
|
62
|
+
*
|
|
63
|
+
* This class is intentionally orchestration-only:
|
|
64
|
+
* - it does not store workers itself
|
|
65
|
+
* - it does not mutate registry structure directly
|
|
66
|
+
* - it does not implement worker/runner business logic
|
|
67
|
+
*
|
|
68
|
+
* Instead, it:
|
|
69
|
+
* - resolves workers/runners from the registry
|
|
70
|
+
* - dispatches command calls to them
|
|
71
|
+
* - collects/normalises the resulting responses
|
|
72
|
+
*/
|
|
73
|
+
export declare class WorkerCommandCoordinator {
|
|
74
|
+
/**
|
|
75
|
+
* Immutable configuration and dependencies for this coordinator.
|
|
76
|
+
*/
|
|
77
|
+
private readonly options;
|
|
78
|
+
/**
|
|
79
|
+
* Construct a new worker command coordinator.
|
|
80
|
+
*
|
|
81
|
+
* @param options Logger, worker registry, and worker manager id.
|
|
82
|
+
*/
|
|
83
|
+
constructor(options: IWorkerCommandCoordinator);
|
|
84
|
+
/**
|
|
85
|
+
* Execute the same command against one or more workers.
|
|
86
|
+
*
|
|
87
|
+
* Behaviour:
|
|
88
|
+
* - resolves the target workers from the registry using `workerIds`
|
|
89
|
+
* - invokes the specified command on each worker
|
|
90
|
+
* - waits for all worker command calls to complete
|
|
91
|
+
* - wraps each worker's per-runner result list in an `IExecuteWorkerActionResult`
|
|
92
|
+
* - returns a result entry per worker
|
|
93
|
+
*
|
|
94
|
+
* Command semantics:
|
|
95
|
+
* - For non-`Update` commands, the worker method is invoked with no arguments
|
|
96
|
+
* - For `Update`, the worker method is invoked with `runnerOptions`
|
|
97
|
+
*
|
|
98
|
+
* Worker selection:
|
|
99
|
+
* - The underlying registry method `GetWorkersEx(workerIds)` determines how
|
|
100
|
+
* worker filtering works
|
|
101
|
+
* - In the current design, an empty `workerIds` array typically means "all workers"
|
|
102
|
+
*
|
|
103
|
+
* Returned structure:
|
|
104
|
+
* Each result includes:
|
|
105
|
+
* - `workerManagerId`
|
|
106
|
+
* - `workerId`
|
|
107
|
+
* - `executeRunnerActionResults`
|
|
108
|
+
*
|
|
109
|
+
* Error handling:
|
|
110
|
+
* - Errors are logged
|
|
111
|
+
* - The method returns an empty array on failure rather than throwing
|
|
112
|
+
*
|
|
113
|
+
* @param workerIds List of target worker ids. Use `[]` to target all workers, if supported by the registry.
|
|
114
|
+
* @param command Worker command to execute.
|
|
115
|
+
* @param runnerOptions Optional runner option updates, only used for `Update`.
|
|
116
|
+
* @returns Array of worker-level aggregated results.
|
|
117
|
+
*/
|
|
118
|
+
ExecuteWorkerCommands: (workerIds: string[], command: "Start" | "Stop" | "Pause" | "Resume" | "Execute" | "Reset" | "Terminate" | "Update", runnerOptions?: Partial<IRunnerOptions>) => Promise<IExecuteWorkerActionResult[]>;
|
|
119
|
+
/**
|
|
120
|
+
* Execute the same command against one or more runners within a single worker.
|
|
121
|
+
*
|
|
122
|
+
* Behaviour:
|
|
123
|
+
* - resolves the target worker from the registry
|
|
124
|
+
* - if `runnerIds` is empty, executes the worker-level command directly
|
|
125
|
+
* (which applies to all runners in that worker)
|
|
126
|
+
* - otherwise resolves the specific target runners from the worker
|
|
127
|
+
* - invokes the specified command on each target runner
|
|
128
|
+
* - waits for all runner command calls to complete
|
|
129
|
+
* - returns a flat array of per-runner results
|
|
130
|
+
*
|
|
131
|
+
* Command semantics:
|
|
132
|
+
* - For non-`Update` commands, the runner method is invoked with no arguments
|
|
133
|
+
* - For `Update`, the runner method is invoked with `runnerOptions`
|
|
134
|
+
*
|
|
135
|
+
* Runner selection:
|
|
136
|
+
* - If `runnerIds.length === 0`, the worker itself is asked to execute the command
|
|
137
|
+
* across all its runners
|
|
138
|
+
* - Otherwise only runners matching the supplied ids are targeted
|
|
139
|
+
*
|
|
140
|
+
* Error handling:
|
|
141
|
+
* - Errors are logged
|
|
142
|
+
* - The method returns an empty array on failure rather than throwing
|
|
143
|
+
*
|
|
144
|
+
* @param workerId Id of the worker containing the target runners.
|
|
145
|
+
* @param runnerIds List of target runner ids. Use `[]` to target all runners in the worker.
|
|
146
|
+
* @param command Runner command to execute.
|
|
147
|
+
* @param runnerOptions Optional runner option updates, only used for `Update`.
|
|
148
|
+
* @returns Array of per-runner action results.
|
|
149
|
+
*/
|
|
150
|
+
ExecuteRunnerCommands: (workerId: string, runnerIds: string[], command: "Start" | "Stop" | "Pause" | "Resume" | "Execute" | "Reset" | "Terminate" | "Update", runnerOptions?: Partial<IRunnerOptions>) => Promise<IExecuteRunnerActionResult[]>;
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=workerCommandCoordinator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workerCommandCoordinator.d.ts","sourceRoot":"","sources":["../src/workerCommandCoordinator.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAGH,OAAO,EACH,cAAc,EACd,0BAA0B,EAC1B,0BAA0B,EAC7B,MAAM,eAAe,CAAC;AAKvB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACtC;;OAEG;IACH,MAAM,EAAE,UAAU,CAAC;IAEnB;;OAEG;IACH,cAAc,EAAE,cAAc,CAAC;IAE/B;;;;;OAKG;IACH,eAAe,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,wBAAwB;IACjC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA4B;IAEpD;;;;OAIG;gBACS,OAAO,EAAE,yBAAyB;IAI9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACI,qBAAqB,GACxB,WAAW,MAAM,EAAE,EACnB,SAAS,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,GAAG,WAAW,GAAG,QAAQ,EAC7F,gBAAgB,OAAO,CAAC,cAAc,CAAC,KACxC,OAAO,CAAC,0BAA0B,EAAE,CAAC,CA2DtC;IAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,qBAAqB,GACjB,UAAU,MAAM,EAChB,WAAW,MAAM,EAAE,EACnB,SAAS,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,GAAG,WAAW,GAAG,QAAQ,EAC7F,gBAAgB,OAAO,CAAC,cAAc,CAAC,KACxC,OAAO,CAAC,0BAA0B,EAAE,CAAC,CA2EtC;CACL"}
|