@loadstrike/loadstrike-sdk 1.0.18901 → 1.0.21101
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/cjs/cluster.js +27 -2
- package/dist/cjs/correlation.js +132 -0
- package/dist/cjs/local.js +113 -6
- package/dist/cjs/reporting.js +12 -0
- package/dist/cjs/runtime.js +929 -14
- package/dist/esm/cluster.js +27 -2
- package/dist/esm/correlation.js +132 -0
- package/dist/esm/local.js +113 -6
- package/dist/esm/reporting.js +12 -0
- package/dist/esm/runtime.js +929 -14
- package/dist/types/cluster.d.ts +21 -1
- package/dist/types/correlation.d.ts +132 -0
- package/dist/types/local.d.ts +6 -0
- package/dist/types/reporting.d.ts +12 -0
- package/dist/types/runtime.d.ts +868 -0
- package/package.json +1 -1
package/dist/cjs/runtime.js
CHANGED
|
@@ -48,14 +48,26 @@ exports.LoadStrikeOperationType = {
|
|
|
48
48
|
Error: "Error"
|
|
49
49
|
};
|
|
50
50
|
class LoadStrikePluginDataTable {
|
|
51
|
+
/**
|
|
52
|
+
* Exposes the public constructor operation.
|
|
53
|
+
* Use this when the surrounding wrapper type makes this operation the clearest way to express your intent.
|
|
54
|
+
*/
|
|
51
55
|
constructor(tableName, headers = [], rows = []) {
|
|
52
56
|
this.tableName = requireNonEmpty(tableName, "Table name must be provided.");
|
|
53
57
|
this.headers = [...headers];
|
|
54
58
|
this.rows = rows.map((row) => ({ ...row }));
|
|
55
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Creates a new instance of this public SDK type.
|
|
62
|
+
* Use this when you are starting a run definition from scratch.
|
|
63
|
+
*/
|
|
56
64
|
static create(tableName) {
|
|
57
65
|
return new LoadStrikePluginDataTable(tableName);
|
|
58
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Creates a new instance of this public SDK type.
|
|
69
|
+
* Use this when you are starting a run definition from scratch.
|
|
70
|
+
*/
|
|
59
71
|
static Create(tableName) {
|
|
60
72
|
return LoadStrikePluginDataTable.create(tableName);
|
|
61
73
|
}
|
|
@@ -71,14 +83,26 @@ class LoadStrikePluginDataTable {
|
|
|
71
83
|
}
|
|
72
84
|
exports.LoadStrikePluginDataTable = LoadStrikePluginDataTable;
|
|
73
85
|
class LoadStrikePluginData {
|
|
86
|
+
/**
|
|
87
|
+
* Exposes the public constructor operation.
|
|
88
|
+
* Use this when the surrounding wrapper type makes this operation the clearest way to express your intent.
|
|
89
|
+
*/
|
|
74
90
|
constructor(pluginName, tables = [], hints = []) {
|
|
75
91
|
this.pluginName = requireNonEmpty(pluginName, "Plugin name must be provided.");
|
|
76
92
|
this.tables = tables.map((table) => new LoadStrikePluginDataTable(table.tableName, table.headers, table.rows));
|
|
77
93
|
this.hints = [...hints];
|
|
78
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Creates a new instance of this public SDK type.
|
|
97
|
+
* Use this when you are starting a run definition from scratch.
|
|
98
|
+
*/
|
|
79
99
|
static create(pluginName) {
|
|
80
100
|
return new LoadStrikePluginData(pluginName);
|
|
81
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Creates a new instance of this public SDK type.
|
|
104
|
+
* Use this when you are starting a run definition from scratch.
|
|
105
|
+
*/
|
|
82
106
|
static Create(pluginName) {
|
|
83
107
|
return LoadStrikePluginData.create(pluginName);
|
|
84
108
|
}
|
|
@@ -104,6 +128,10 @@ class MeasurementAccumulator {
|
|
|
104
128
|
get Count() {
|
|
105
129
|
return this.count;
|
|
106
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Exposes the public record operation.
|
|
133
|
+
* Use this when the surrounding wrapper type makes this operation the clearest way to express your intent.
|
|
134
|
+
*/
|
|
107
135
|
record(reply, observedLatencyMs) {
|
|
108
136
|
const latencyMs = resolveRecordedLatency(reply.customLatencyMs, observedLatencyMs);
|
|
109
137
|
const sizeBytes = Math.max(toNumber(reply.sizeBytes), 0);
|
|
@@ -126,6 +154,10 @@ class MeasurementAccumulator {
|
|
|
126
154
|
count: 1
|
|
127
155
|
});
|
|
128
156
|
}
|
|
157
|
+
/**
|
|
158
|
+
* Builds the configured payload or helper object.
|
|
159
|
+
* Use this when all builder inputs are ready to be materialized.
|
|
160
|
+
*/
|
|
129
161
|
build(allRequestCount, durationMs) {
|
|
130
162
|
const count = this.count;
|
|
131
163
|
const totalDurationMs = Math.max(durationMs, 0);
|
|
@@ -184,6 +216,10 @@ class StepStatsAccumulator {
|
|
|
184
216
|
this.ok = new MeasurementAccumulator();
|
|
185
217
|
this.fail = new MeasurementAccumulator();
|
|
186
218
|
}
|
|
219
|
+
/**
|
|
220
|
+
* Exposes the public record operation.
|
|
221
|
+
* Use this when the surrounding wrapper type makes this operation the clearest way to express your intent.
|
|
222
|
+
*/
|
|
187
223
|
record(reply, observedLatencyMs) {
|
|
188
224
|
if (reply.isSuccess) {
|
|
189
225
|
this.ok.record(reply, observedLatencyMs);
|
|
@@ -191,6 +227,10 @@ class StepStatsAccumulator {
|
|
|
191
227
|
}
|
|
192
228
|
this.fail.record(reply, observedLatencyMs);
|
|
193
229
|
}
|
|
230
|
+
/**
|
|
231
|
+
* Builds the configured payload or helper object.
|
|
232
|
+
* Use this when all builder inputs are ready to be materialized.
|
|
233
|
+
*/
|
|
194
234
|
build(allScenarioRequestCount, durationMs) {
|
|
195
235
|
const ok = this.ok.build(allScenarioRequestCount, durationMs);
|
|
196
236
|
const fail = this.fail.build(allScenarioRequestCount, durationMs);
|
|
@@ -230,18 +270,34 @@ class ScenarioStatsAccumulator {
|
|
|
230
270
|
this.loadSimulationStats = { simulationName: "", value: 0 };
|
|
231
271
|
this.currentOperation = "None";
|
|
232
272
|
}
|
|
273
|
+
/**
|
|
274
|
+
* Exposes the public setLoadSimulation operation.
|
|
275
|
+
* Use this when the surrounding wrapper type makes this operation the clearest way to express your intent.
|
|
276
|
+
*/
|
|
233
277
|
setLoadSimulation(simulationName, value) {
|
|
234
278
|
this.loadSimulationStats = {
|
|
235
279
|
simulationName,
|
|
236
280
|
value
|
|
237
281
|
};
|
|
238
282
|
}
|
|
283
|
+
/**
|
|
284
|
+
* Exposes the public setCurrentOperation operation.
|
|
285
|
+
* Use this when the surrounding wrapper type makes this operation the clearest way to express your intent.
|
|
286
|
+
*/
|
|
239
287
|
setCurrentOperation(operation) {
|
|
240
288
|
this.currentOperation = operation;
|
|
241
289
|
}
|
|
290
|
+
/**
|
|
291
|
+
* Returns current operation.
|
|
292
|
+
* Use this when current operation is required for branching, logging, or assertions.
|
|
293
|
+
*/
|
|
242
294
|
getCurrentOperation() {
|
|
243
295
|
return this.currentOperation;
|
|
244
296
|
}
|
|
297
|
+
/**
|
|
298
|
+
* Exposes the public recordScenario operation.
|
|
299
|
+
* Use this when the surrounding wrapper type makes this operation the clearest way to express your intent.
|
|
300
|
+
*/
|
|
245
301
|
recordScenario(reply, observedLatencyMs) {
|
|
246
302
|
if (reply.isSuccess) {
|
|
247
303
|
this.ok.record(reply, observedLatencyMs);
|
|
@@ -249,6 +305,10 @@ class ScenarioStatsAccumulator {
|
|
|
249
305
|
}
|
|
250
306
|
this.fail.record(reply, observedLatencyMs);
|
|
251
307
|
}
|
|
308
|
+
/**
|
|
309
|
+
* Exposes the public recordStep operation.
|
|
310
|
+
* Use this when the surrounding wrapper type makes this operation the clearest way to express your intent.
|
|
311
|
+
*/
|
|
252
312
|
recordStep(stepName, reply, observedLatencyMs) {
|
|
253
313
|
const existing = this.steps.get(stepName);
|
|
254
314
|
const step = existing ?? new StepStatsAccumulator(this.scenarioName, stepName, this.nextStepSortIndex += 1);
|
|
@@ -257,6 +317,10 @@ class ScenarioStatsAccumulator {
|
|
|
257
317
|
}
|
|
258
318
|
step.record(reply, observedLatencyMs);
|
|
259
319
|
}
|
|
320
|
+
/**
|
|
321
|
+
* Builds the configured payload or helper object.
|
|
322
|
+
* Use this when all builder inputs are ready to be materialized.
|
|
323
|
+
*/
|
|
260
324
|
build(durationMs) {
|
|
261
325
|
const totalRequests = this.ok.Count + this.fail.Count;
|
|
262
326
|
const ok = this.ok.build(totalRequests, durationMs);
|
|
@@ -301,6 +365,10 @@ class ScenarioStatsAccumulator {
|
|
|
301
365
|
}
|
|
302
366
|
}
|
|
303
367
|
class LoadStrikeResponse {
|
|
368
|
+
/**
|
|
369
|
+
* Creates a successful reply.
|
|
370
|
+
* Use this when a step or scenario completed successfully and should report a success response.
|
|
371
|
+
*/
|
|
304
372
|
static ok(...args) {
|
|
305
373
|
const normalized = normalizeSuccessResponseCall(args);
|
|
306
374
|
const reply = {
|
|
@@ -313,6 +381,10 @@ class LoadStrikeResponse {
|
|
|
313
381
|
};
|
|
314
382
|
return attachReplyProjection(reply);
|
|
315
383
|
}
|
|
384
|
+
/**
|
|
385
|
+
* Creates a successful reply.
|
|
386
|
+
* Use this when a step or scenario completed successfully and should report a success response.
|
|
387
|
+
*/
|
|
316
388
|
static Ok(...args) {
|
|
317
389
|
return LoadStrikeResponse.ok(...args);
|
|
318
390
|
}
|
|
@@ -322,6 +394,10 @@ class LoadStrikeResponse {
|
|
|
322
394
|
static OkWithPayload(payload, statusCode = "200", sizeBytesOrMessage = 0, messageOrSizeBytes = "", customLatencyMs) {
|
|
323
395
|
return LoadStrikeResponse.okWithPayload(payload, statusCode, sizeBytesOrMessage, messageOrSizeBytes, customLatencyMs);
|
|
324
396
|
}
|
|
397
|
+
/**
|
|
398
|
+
* Creates a failed reply.
|
|
399
|
+
* Use this when a step or scenario should record an explicit failure response.
|
|
400
|
+
*/
|
|
325
401
|
static fail(...args) {
|
|
326
402
|
const normalized = normalizeFailureResponseCall(args);
|
|
327
403
|
const reply = {
|
|
@@ -334,6 +410,10 @@ class LoadStrikeResponse {
|
|
|
334
410
|
};
|
|
335
411
|
return attachReplyProjection(reply);
|
|
336
412
|
}
|
|
413
|
+
/**
|
|
414
|
+
* Creates a failed reply.
|
|
415
|
+
* Use this when a step or scenario should record an explicit failure response.
|
|
416
|
+
*/
|
|
337
417
|
static Fail(...args) {
|
|
338
418
|
return LoadStrikeResponse.fail(...args);
|
|
339
419
|
}
|
|
@@ -384,6 +464,10 @@ class LoadStrikeStep {
|
|
|
384
464
|
}
|
|
385
465
|
exports.LoadStrikeStep = LoadStrikeStep;
|
|
386
466
|
class LoadStrikeSimulation {
|
|
467
|
+
/**
|
|
468
|
+
* Builds a constant injection load shape.
|
|
469
|
+
* Use this when requests should be injected at a fixed rate over a duration.
|
|
470
|
+
*/
|
|
387
471
|
static inject(rate, intervalSeconds, duringSeconds) {
|
|
388
472
|
return attachLoadSimulationProjection({
|
|
389
473
|
Kind: "Inject",
|
|
@@ -392,9 +476,17 @@ class LoadStrikeSimulation {
|
|
|
392
476
|
DuringSeconds: duringSeconds
|
|
393
477
|
});
|
|
394
478
|
}
|
|
479
|
+
/**
|
|
480
|
+
* Builds a constant injection load shape.
|
|
481
|
+
* Use this when requests should be injected at a fixed rate over a duration.
|
|
482
|
+
*/
|
|
395
483
|
static Inject(rate, intervalSeconds, duringSeconds) {
|
|
396
484
|
return LoadStrikeSimulation.inject(rate, intervalSeconds, duringSeconds);
|
|
397
485
|
}
|
|
486
|
+
/**
|
|
487
|
+
* Builds an iteration-limited constant-concurrency load shape.
|
|
488
|
+
* Use this when a fixed number of iterations should be shared across constant workers.
|
|
489
|
+
*/
|
|
398
490
|
static iterationsForConstant(copies, iterations) {
|
|
399
491
|
return attachLoadSimulationProjection({
|
|
400
492
|
Kind: "IterationsForConstant",
|
|
@@ -402,9 +494,17 @@ class LoadStrikeSimulation {
|
|
|
402
494
|
Iterations: iterations
|
|
403
495
|
});
|
|
404
496
|
}
|
|
497
|
+
/**
|
|
498
|
+
* Builds an iteration-limited constant-concurrency load shape.
|
|
499
|
+
* Use this when a fixed number of iterations should be shared across constant workers.
|
|
500
|
+
*/
|
|
405
501
|
static IterationsForConstant(copies, iterations) {
|
|
406
502
|
return LoadStrikeSimulation.iterationsForConstant(copies, iterations);
|
|
407
503
|
}
|
|
504
|
+
/**
|
|
505
|
+
* Builds an iteration-limited injection load shape.
|
|
506
|
+
* Use this when a fixed number of injected iterations should be executed.
|
|
507
|
+
*/
|
|
408
508
|
static iterationsForInject(rate, intervalSeconds, iterations) {
|
|
409
509
|
return attachLoadSimulationProjection({
|
|
410
510
|
Kind: "IterationsForInject",
|
|
@@ -413,9 +513,17 @@ class LoadStrikeSimulation {
|
|
|
413
513
|
Iterations: iterations
|
|
414
514
|
});
|
|
415
515
|
}
|
|
516
|
+
/**
|
|
517
|
+
* Builds an iteration-limited injection load shape.
|
|
518
|
+
* Use this when a fixed number of injected iterations should be executed.
|
|
519
|
+
*/
|
|
416
520
|
static IterationsForInject(rate, intervalSeconds, iterations) {
|
|
417
521
|
return LoadStrikeSimulation.iterationsForInject(rate, intervalSeconds, iterations);
|
|
418
522
|
}
|
|
523
|
+
/**
|
|
524
|
+
* Builds a constant-concurrency load shape.
|
|
525
|
+
* Use this when a fixed number of virtual users should stay active.
|
|
526
|
+
*/
|
|
419
527
|
static keepConstant(copies, duringSeconds) {
|
|
420
528
|
return attachLoadSimulationProjection({
|
|
421
529
|
Kind: "KeepConstant",
|
|
@@ -423,9 +531,17 @@ class LoadStrikeSimulation {
|
|
|
423
531
|
DuringSeconds: duringSeconds
|
|
424
532
|
});
|
|
425
533
|
}
|
|
534
|
+
/**
|
|
535
|
+
* Builds a constant-concurrency load shape.
|
|
536
|
+
* Use this when a fixed number of virtual users should stay active.
|
|
537
|
+
*/
|
|
426
538
|
static KeepConstant(copies, duringSeconds) {
|
|
427
539
|
return LoadStrikeSimulation.keepConstant(copies, duringSeconds);
|
|
428
540
|
}
|
|
541
|
+
/**
|
|
542
|
+
* Builds a randomized injection load shape.
|
|
543
|
+
* Use this when traffic should fluctuate between a minimum and maximum rate.
|
|
544
|
+
*/
|
|
429
545
|
static injectRandom(minRate, maxRate, intervalSeconds, duringSeconds) {
|
|
430
546
|
return attachLoadSimulationProjection({
|
|
431
547
|
Kind: "InjectRandom",
|
|
@@ -435,9 +551,17 @@ class LoadStrikeSimulation {
|
|
|
435
551
|
DuringSeconds: duringSeconds
|
|
436
552
|
});
|
|
437
553
|
}
|
|
554
|
+
/**
|
|
555
|
+
* Builds a randomized injection load shape.
|
|
556
|
+
* Use this when traffic should fluctuate between a minimum and maximum rate.
|
|
557
|
+
*/
|
|
438
558
|
static InjectRandom(minRate, maxRate, intervalSeconds, duringSeconds) {
|
|
439
559
|
return LoadStrikeSimulation.injectRandom(minRate, maxRate, intervalSeconds, duringSeconds);
|
|
440
560
|
}
|
|
561
|
+
/**
|
|
562
|
+
* Builds a ramping injection load shape.
|
|
563
|
+
* Use this when request rate should increase over time.
|
|
564
|
+
*/
|
|
441
565
|
static rampingInject(rate, intervalSeconds, duringSeconds) {
|
|
442
566
|
return attachLoadSimulationProjection({
|
|
443
567
|
Kind: "RampingInject",
|
|
@@ -446,9 +570,17 @@ class LoadStrikeSimulation {
|
|
|
446
570
|
DuringSeconds: duringSeconds
|
|
447
571
|
});
|
|
448
572
|
}
|
|
573
|
+
/**
|
|
574
|
+
* Builds a ramping injection load shape.
|
|
575
|
+
* Use this when request rate should increase over time.
|
|
576
|
+
*/
|
|
449
577
|
static RampingInject(rate, intervalSeconds, duringSeconds) {
|
|
450
578
|
return LoadStrikeSimulation.rampingInject(rate, intervalSeconds, duringSeconds);
|
|
451
579
|
}
|
|
580
|
+
/**
|
|
581
|
+
* Builds a ramping-concurrency load shape.
|
|
582
|
+
* Use this when the number of active virtual users should climb over time.
|
|
583
|
+
*/
|
|
452
584
|
static rampingConstant(copies, duringSeconds) {
|
|
453
585
|
return attachLoadSimulationProjection({
|
|
454
586
|
Kind: "RampingConstant",
|
|
@@ -456,21 +588,37 @@ class LoadStrikeSimulation {
|
|
|
456
588
|
DuringSeconds: duringSeconds
|
|
457
589
|
});
|
|
458
590
|
}
|
|
591
|
+
/**
|
|
592
|
+
* Builds a ramping-concurrency load shape.
|
|
593
|
+
* Use this when the number of active virtual users should climb over time.
|
|
594
|
+
*/
|
|
459
595
|
static RampingConstant(copies, duringSeconds) {
|
|
460
596
|
return LoadStrikeSimulation.rampingConstant(copies, duringSeconds);
|
|
461
597
|
}
|
|
598
|
+
/**
|
|
599
|
+
* Builds a pause segment in a load profile.
|
|
600
|
+
* Use this when a simulation should intentionally idle for a period.
|
|
601
|
+
*/
|
|
462
602
|
static pause(duringSeconds) {
|
|
463
603
|
return attachLoadSimulationProjection({
|
|
464
604
|
Kind: "Pause",
|
|
465
605
|
DuringSeconds: duringSeconds
|
|
466
606
|
});
|
|
467
607
|
}
|
|
608
|
+
/**
|
|
609
|
+
* Builds a pause segment in a load profile.
|
|
610
|
+
* Use this when a simulation should intentionally idle for a period.
|
|
611
|
+
*/
|
|
468
612
|
static Pause(duringSeconds) {
|
|
469
613
|
return LoadStrikeSimulation.pause(duringSeconds);
|
|
470
614
|
}
|
|
471
615
|
}
|
|
472
616
|
exports.LoadStrikeSimulation = LoadStrikeSimulation;
|
|
473
617
|
class LoadStrikeCounter {
|
|
618
|
+
/**
|
|
619
|
+
* Exposes the public constructor operation.
|
|
620
|
+
* Use this when the surrounding wrapper type makes this operation the clearest way to express your intent.
|
|
621
|
+
*/
|
|
474
622
|
constructor(name, initialValueOrUnit = 0, unitOfMeasure = "") {
|
|
475
623
|
this.type = "counter";
|
|
476
624
|
this.name = requireNonEmpty(name, "Metric name is required.");
|
|
@@ -481,20 +629,40 @@ class LoadStrikeCounter {
|
|
|
481
629
|
? 0
|
|
482
630
|
: (Number.isFinite(initialValueOrUnit) ? Number(initialValueOrUnit) : 0);
|
|
483
631
|
}
|
|
632
|
+
/**
|
|
633
|
+
* Adds a value to the current metric.
|
|
634
|
+
* Use this when a counter or gauge should be incremented by an explicit delta.
|
|
635
|
+
*/
|
|
484
636
|
add(value) {
|
|
485
637
|
const next = Number.isFinite(value) ? Number(value) : 0;
|
|
486
638
|
this.current += next;
|
|
487
639
|
return this.current;
|
|
488
640
|
}
|
|
641
|
+
/**
|
|
642
|
+
* Increments the current metric by one.
|
|
643
|
+
* Use this when events should simply be counted.
|
|
644
|
+
*/
|
|
489
645
|
increment(by = 1) {
|
|
490
646
|
return this.add(by);
|
|
491
647
|
}
|
|
648
|
+
/**
|
|
649
|
+
* Returns the current metric value.
|
|
650
|
+
* Use this when custom metric state needs to be inspected inside user code.
|
|
651
|
+
*/
|
|
492
652
|
value() {
|
|
493
653
|
return this.current;
|
|
494
654
|
}
|
|
655
|
+
/**
|
|
656
|
+
* Adds a value to the current metric.
|
|
657
|
+
* Use this when a counter or gauge should be incremented by an explicit delta.
|
|
658
|
+
*/
|
|
495
659
|
Add(value) {
|
|
496
660
|
return this.add(value);
|
|
497
661
|
}
|
|
662
|
+
/**
|
|
663
|
+
* Increments the current metric by one.
|
|
664
|
+
* Use this when events should simply be counted.
|
|
665
|
+
*/
|
|
498
666
|
Increment(by = 1) {
|
|
499
667
|
return this.increment(by);
|
|
500
668
|
}
|
|
@@ -510,6 +678,10 @@ class LoadStrikeCounter {
|
|
|
510
678
|
}
|
|
511
679
|
exports.LoadStrikeCounter = LoadStrikeCounter;
|
|
512
680
|
class LoadStrikeGauge {
|
|
681
|
+
/**
|
|
682
|
+
* Exposes the public constructor operation.
|
|
683
|
+
* Use this when the surrounding wrapper type makes this operation the clearest way to express your intent.
|
|
684
|
+
*/
|
|
513
685
|
constructor(name, initialValueOrUnit = 0, unitOfMeasure = "") {
|
|
514
686
|
this.type = "gauge";
|
|
515
687
|
this.name = requireNonEmpty(name, "Metric name is required.");
|
|
@@ -520,33 +692,69 @@ class LoadStrikeGauge {
|
|
|
520
692
|
? 0
|
|
521
693
|
: (Number.isFinite(initialValueOrUnit) ? Number(initialValueOrUnit) : 0);
|
|
522
694
|
}
|
|
695
|
+
/**
|
|
696
|
+
* Sets the current gauge value.
|
|
697
|
+
* Use this when the latest observed value should replace the previous one.
|
|
698
|
+
*/
|
|
523
699
|
set(value) {
|
|
524
700
|
this.current = Number.isFinite(value) ? Number(value) : 0;
|
|
525
701
|
return this.current;
|
|
526
702
|
}
|
|
703
|
+
/**
|
|
704
|
+
* Adds a value to the current metric.
|
|
705
|
+
* Use this when a counter or gauge should be incremented by an explicit delta.
|
|
706
|
+
*/
|
|
527
707
|
add(value) {
|
|
528
708
|
const next = Number.isFinite(value) ? Number(value) : 0;
|
|
529
709
|
this.current += next;
|
|
530
710
|
return this.current;
|
|
531
711
|
}
|
|
712
|
+
/**
|
|
713
|
+
* Increments the current metric by one.
|
|
714
|
+
* Use this when events should simply be counted.
|
|
715
|
+
*/
|
|
532
716
|
increment(by = 1) {
|
|
533
717
|
return this.add(by);
|
|
534
718
|
}
|
|
719
|
+
/**
|
|
720
|
+
* Decrements the current metric by one.
|
|
721
|
+
* Use this when a gauge should move down by a single unit.
|
|
722
|
+
*/
|
|
535
723
|
decrement(by = 1) {
|
|
536
724
|
return this.add(-by);
|
|
537
725
|
}
|
|
726
|
+
/**
|
|
727
|
+
* Returns the current metric value.
|
|
728
|
+
* Use this when custom metric state needs to be inspected inside user code.
|
|
729
|
+
*/
|
|
538
730
|
value() {
|
|
539
731
|
return this.current;
|
|
540
732
|
}
|
|
733
|
+
/**
|
|
734
|
+
* Sets the current gauge value.
|
|
735
|
+
* Use this when the latest observed value should replace the previous one.
|
|
736
|
+
*/
|
|
541
737
|
Set(value) {
|
|
542
738
|
return this.set(value);
|
|
543
739
|
}
|
|
740
|
+
/**
|
|
741
|
+
* Adds a value to the current metric.
|
|
742
|
+
* Use this when a counter or gauge should be incremented by an explicit delta.
|
|
743
|
+
*/
|
|
544
744
|
Add(value) {
|
|
545
745
|
return this.add(value);
|
|
546
746
|
}
|
|
747
|
+
/**
|
|
748
|
+
* Increments the current metric by one.
|
|
749
|
+
* Use this when events should simply be counted.
|
|
750
|
+
*/
|
|
547
751
|
Increment(by = 1) {
|
|
548
752
|
return this.increment(by);
|
|
549
753
|
}
|
|
754
|
+
/**
|
|
755
|
+
* Decrements the current metric by one.
|
|
756
|
+
* Use this when a gauge should move down by a single unit.
|
|
757
|
+
*/
|
|
550
758
|
Decrement(by = 1) {
|
|
551
759
|
return this.decrement(by);
|
|
552
760
|
}
|
|
@@ -562,21 +770,45 @@ class LoadStrikeGauge {
|
|
|
562
770
|
}
|
|
563
771
|
exports.LoadStrikeGauge = LoadStrikeGauge;
|
|
564
772
|
class LoadStrikeMetric {
|
|
773
|
+
/**
|
|
774
|
+
* Creates a counter metric.
|
|
775
|
+
* Use this when a scenario should accumulate a monotonically increasing custom metric.
|
|
776
|
+
*/
|
|
565
777
|
static counter(name, initialValueOrUnit = 0, unitOfMeasure = "") {
|
|
566
778
|
return new LoadStrikeCounter(name, initialValueOrUnit, unitOfMeasure);
|
|
567
779
|
}
|
|
780
|
+
/**
|
|
781
|
+
* Creates a gauge metric.
|
|
782
|
+
* Use this when a scenario should track the latest value of a custom metric.
|
|
783
|
+
*/
|
|
568
784
|
static gauge(name, initialValueOrUnit = 0, unitOfMeasure = "") {
|
|
569
785
|
return new LoadStrikeGauge(name, initialValueOrUnit, unitOfMeasure);
|
|
570
786
|
}
|
|
787
|
+
/**
|
|
788
|
+
* Creates a counter metric.
|
|
789
|
+
* Use this when a scenario should accumulate a monotonically increasing custom metric.
|
|
790
|
+
*/
|
|
571
791
|
static Counter(name, initialValueOrUnit = 0, unitOfMeasure = "") {
|
|
572
792
|
return LoadStrikeMetric.counter(name, initialValueOrUnit, unitOfMeasure);
|
|
573
793
|
}
|
|
794
|
+
/**
|
|
795
|
+
* Creates a gauge metric.
|
|
796
|
+
* Use this when a scenario should track the latest value of a custom metric.
|
|
797
|
+
*/
|
|
574
798
|
static Gauge(name, initialValueOrUnit = 0, unitOfMeasure = "") {
|
|
575
799
|
return LoadStrikeMetric.gauge(name, initialValueOrUnit, unitOfMeasure);
|
|
576
800
|
}
|
|
801
|
+
/**
|
|
802
|
+
* Creates a counter metric.
|
|
803
|
+
* Use this when a scenario should accumulate a monotonically increasing custom metric.
|
|
804
|
+
*/
|
|
577
805
|
static CreateCounter(name, unitOfMeasure = "") {
|
|
578
806
|
return new LoadStrikeCounter(name, 0, unitOfMeasure);
|
|
579
807
|
}
|
|
808
|
+
/**
|
|
809
|
+
* Creates a gauge metric.
|
|
810
|
+
* Use this when a scenario should track the latest value of a custom metric.
|
|
811
|
+
*/
|
|
580
812
|
static CreateGauge(name, unitOfMeasure = "") {
|
|
581
813
|
return new LoadStrikeGauge(name, 0, unitOfMeasure);
|
|
582
814
|
}
|
|
@@ -701,15 +933,31 @@ class LoadStrikeContext {
|
|
|
701
933
|
this.registeredScenarios = [...registeredScenarios];
|
|
702
934
|
this.runArgs = [...runArgs];
|
|
703
935
|
}
|
|
936
|
+
/**
|
|
937
|
+
* Creates a new instance of this public SDK type.
|
|
938
|
+
* Use this when you are starting a run definition from scratch.
|
|
939
|
+
*/
|
|
704
940
|
static create() {
|
|
705
941
|
return new LoadStrikeContext();
|
|
706
942
|
}
|
|
943
|
+
/**
|
|
944
|
+
* Exposes the public toObject operation.
|
|
945
|
+
* Use this when the surrounding wrapper type makes this operation the clearest way to express your intent.
|
|
946
|
+
*/
|
|
707
947
|
toObject() {
|
|
708
948
|
return { ...this.values };
|
|
709
949
|
}
|
|
950
|
+
/**
|
|
951
|
+
* Builds the current configuration into a runnable context.
|
|
952
|
+
* Use this when you want to inspect or reuse the final run settings before execution.
|
|
953
|
+
*/
|
|
710
954
|
buildContext() {
|
|
711
955
|
return this;
|
|
712
956
|
}
|
|
957
|
+
/**
|
|
958
|
+
* Builds the current configuration into a runnable context.
|
|
959
|
+
* Use this when you want to inspect or reuse the final run settings before execution.
|
|
960
|
+
*/
|
|
713
961
|
BuildContext() {
|
|
714
962
|
return this.buildContext();
|
|
715
963
|
}
|
|
@@ -731,6 +979,10 @@ class LoadStrikeContext {
|
|
|
731
979
|
const args = normalizeRunArgsInput(argsOrSingleArray);
|
|
732
980
|
return this.run(args);
|
|
733
981
|
}
|
|
982
|
+
/**
|
|
983
|
+
* Exposes the public toRunnerOptions operation.
|
|
984
|
+
* Use this when the surrounding wrapper type makes this operation the clearest way to express your intent.
|
|
985
|
+
*/
|
|
734
986
|
toRunnerOptions() {
|
|
735
987
|
const normalizedValues = normalizeRunContextCollectionShapes(this.values);
|
|
736
988
|
return {
|
|
@@ -803,27 +1055,59 @@ class LoadStrikeContext {
|
|
|
803
1055
|
Configure(input) {
|
|
804
1056
|
return this.configure(input);
|
|
805
1057
|
}
|
|
1058
|
+
/**
|
|
1059
|
+
* Copies settings from an existing context snapshot.
|
|
1060
|
+
* Use this when a runner should inherit configuration that was already assembled elsewhere.
|
|
1061
|
+
*/
|
|
806
1062
|
configureContext(context) {
|
|
807
1063
|
return this.configure(context);
|
|
808
1064
|
}
|
|
1065
|
+
/**
|
|
1066
|
+
* Copies settings from an existing context snapshot.
|
|
1067
|
+
* Use this when a runner should inherit configuration that was already assembled elsewhere.
|
|
1068
|
+
*/
|
|
809
1069
|
ConfigureContext(context) {
|
|
810
1070
|
return this.configureContext(context);
|
|
811
1071
|
}
|
|
1072
|
+
/**
|
|
1073
|
+
* Toggles realtime console metric output.
|
|
1074
|
+
* Use this when a local run or CI log should stream live throughput and latency updates.
|
|
1075
|
+
*/
|
|
812
1076
|
displayConsoleMetrics(enable) {
|
|
813
1077
|
return this.DisplayConsoleMetrics(enable);
|
|
814
1078
|
}
|
|
1079
|
+
/**
|
|
1080
|
+
* Toggles realtime console metric output.
|
|
1081
|
+
* Use this when a local run or CI log should stream live throughput and latency updates.
|
|
1082
|
+
*/
|
|
815
1083
|
DisplayConsoleMetrics(enable) {
|
|
816
1084
|
return this.mergeValues({ ConsoleMetricsEnabled: Boolean(enable) });
|
|
817
1085
|
}
|
|
1086
|
+
/**
|
|
1087
|
+
* Toggles local development cluster mode.
|
|
1088
|
+
* Use this when you want to simulate coordinator and agent behavior on a single machine.
|
|
1089
|
+
*/
|
|
818
1090
|
enableLocalDevCluster(enable) {
|
|
819
1091
|
return this.EnableLocalDevCluster(enable);
|
|
820
1092
|
}
|
|
1093
|
+
/**
|
|
1094
|
+
* Toggles local development cluster mode.
|
|
1095
|
+
* Use this when you want to simulate coordinator and agent behavior on a single machine.
|
|
1096
|
+
*/
|
|
821
1097
|
EnableLocalDevCluster(enable) {
|
|
822
1098
|
return this.mergeValues({ LocalDevClusterEnabled: Boolean(enable) });
|
|
823
1099
|
}
|
|
1100
|
+
/**
|
|
1101
|
+
* Loads run settings from a JSON config file.
|
|
1102
|
+
* Use this when configuration should come from a checked-in or generated config document.
|
|
1103
|
+
*/
|
|
824
1104
|
loadConfig(path) {
|
|
825
1105
|
return this.LoadConfig(path);
|
|
826
1106
|
}
|
|
1107
|
+
/**
|
|
1108
|
+
* Loads run settings from a JSON config file.
|
|
1109
|
+
* Use this when configuration should come from a checked-in or generated config document.
|
|
1110
|
+
*/
|
|
827
1111
|
LoadConfig(path) {
|
|
828
1112
|
const configPath = requireNonEmpty(path, "Config path must be provided.");
|
|
829
1113
|
const loaded = loadJsonObject(configPath);
|
|
@@ -833,9 +1117,17 @@ class LoadStrikeContext {
|
|
|
833
1117
|
...extractContextOverridesFromConfig(loaded)
|
|
834
1118
|
});
|
|
835
1119
|
}
|
|
1120
|
+
/**
|
|
1121
|
+
* Loads infrastructure settings for sinks, plugins, or transport dependencies.
|
|
1122
|
+
* Use this when runtime integrations depend on external connection details.
|
|
1123
|
+
*/
|
|
836
1124
|
loadInfraConfig(path) {
|
|
837
1125
|
return this.LoadInfraConfig(path);
|
|
838
1126
|
}
|
|
1127
|
+
/**
|
|
1128
|
+
* Loads infrastructure settings for sinks, plugins, or transport dependencies.
|
|
1129
|
+
* Use this when runtime integrations depend on external connection details.
|
|
1130
|
+
*/
|
|
839
1131
|
LoadInfraConfig(path) {
|
|
840
1132
|
const infraConfigPath = requireNonEmpty(path, "Infra config path must be provided.");
|
|
841
1133
|
return this.mergeValues({
|
|
@@ -843,87 +1135,191 @@ class LoadStrikeContext {
|
|
|
843
1135
|
InfraConfig: loadJsonObject(infraConfigPath)
|
|
844
1136
|
});
|
|
845
1137
|
}
|
|
1138
|
+
/**
|
|
1139
|
+
* Sets the agent group for this node or run.
|
|
1140
|
+
* Use this when only a subset of agents should pick up a particular workload.
|
|
1141
|
+
*/
|
|
846
1142
|
withAgentGroup(agentGroup) {
|
|
847
1143
|
return this.WithAgentGroup(agentGroup);
|
|
848
1144
|
}
|
|
1145
|
+
/**
|
|
1146
|
+
* Sets the agent group for this node or run.
|
|
1147
|
+
* Use this when only a subset of agents should pick up a particular workload.
|
|
1148
|
+
*/
|
|
849
1149
|
WithAgentGroup(agentGroup) {
|
|
850
1150
|
return this.mergeValues({ AgentGroup: requireNonEmpty(agentGroup, "Agent group must be provided.") });
|
|
851
1151
|
}
|
|
1152
|
+
/**
|
|
1153
|
+
* Sets the requested agent count.
|
|
1154
|
+
* Use this when a coordinator should fan work out across a specific number of agents.
|
|
1155
|
+
*/
|
|
852
1156
|
withAgentsCount(agentsCount) {
|
|
853
1157
|
return this.WithAgentsCount(agentsCount);
|
|
854
1158
|
}
|
|
1159
|
+
/**
|
|
1160
|
+
* Sets the requested agent count.
|
|
1161
|
+
* Use this when a coordinator should fan work out across a specific number of agents.
|
|
1162
|
+
*/
|
|
855
1163
|
WithAgentsCount(agentsCount) {
|
|
856
1164
|
if (!Number.isFinite(agentsCount) || agentsCount <= 0) {
|
|
857
1165
|
throw new RangeError("Agents count should be greater than zero.");
|
|
858
1166
|
}
|
|
859
1167
|
return this.mergeValues({ AgentsCount: Math.trunc(agentsCount) });
|
|
860
1168
|
}
|
|
1169
|
+
/**
|
|
1170
|
+
* Targets a shared set of scenarios.
|
|
1171
|
+
* Use this when only selected scenarios should execute for the current node or run.
|
|
1172
|
+
*/
|
|
861
1173
|
withTargetScenarios(...scenarioNames) {
|
|
862
1174
|
return this.WithTargetScenarios(...scenarioNames);
|
|
863
1175
|
}
|
|
1176
|
+
/**
|
|
1177
|
+
* Targets a shared set of scenarios.
|
|
1178
|
+
* Use this when only selected scenarios should execute for the current node or run.
|
|
1179
|
+
*/
|
|
864
1180
|
WithTargetScenarios(...scenarioNames) {
|
|
865
1181
|
return this.mergeValues({ TargetScenarios: validateScenarioNames(scenarioNames) });
|
|
866
1182
|
}
|
|
1183
|
+
/**
|
|
1184
|
+
* Targets scenarios for agent nodes only.
|
|
1185
|
+
* Use this when agents should execute only a subset of the registered scenarios.
|
|
1186
|
+
*/
|
|
867
1187
|
withAgentTargetScenarios(...scenarioNames) {
|
|
868
1188
|
return this.WithAgentTargetScenarios(...scenarioNames);
|
|
869
1189
|
}
|
|
1190
|
+
/**
|
|
1191
|
+
* Targets scenarios for agent nodes only.
|
|
1192
|
+
* Use this when agents should execute only a subset of the registered scenarios.
|
|
1193
|
+
*/
|
|
870
1194
|
WithAgentTargetScenarios(...scenarioNames) {
|
|
871
1195
|
return this.mergeValues({ AgentTargetScenarios: validateScenarioNames(scenarioNames) });
|
|
872
1196
|
}
|
|
1197
|
+
/**
|
|
1198
|
+
* Targets scenarios for the coordinator only.
|
|
1199
|
+
* Use this when orchestration or control-node work should run on the coordinator itself.
|
|
1200
|
+
*/
|
|
873
1201
|
withCoordinatorTargetScenarios(...scenarioNames) {
|
|
874
1202
|
return this.WithCoordinatorTargetScenarios(...scenarioNames);
|
|
875
1203
|
}
|
|
1204
|
+
/**
|
|
1205
|
+
* Targets scenarios for the coordinator only.
|
|
1206
|
+
* Use this when orchestration or control-node work should run on the coordinator itself.
|
|
1207
|
+
*/
|
|
876
1208
|
WithCoordinatorTargetScenarios(...scenarioNames) {
|
|
877
1209
|
return this.mergeValues({ CoordinatorTargetScenarios: validateScenarioNames(scenarioNames) });
|
|
878
1210
|
}
|
|
1211
|
+
/**
|
|
1212
|
+
* Sets the runner key used for licensing validation.
|
|
1213
|
+
* Use this when the run must authenticate against the licensing API before it starts.
|
|
1214
|
+
*/
|
|
879
1215
|
withRunnerKey(runnerKey) {
|
|
880
1216
|
return this.WithRunnerKey(runnerKey);
|
|
881
1217
|
}
|
|
1218
|
+
/**
|
|
1219
|
+
* Sets the runner key used for licensing validation.
|
|
1220
|
+
* Use this when the run must authenticate against the licensing API before it starts.
|
|
1221
|
+
*/
|
|
882
1222
|
WithRunnerKey(runnerKey) {
|
|
883
1223
|
return this.mergeValues({ RunnerKey: requireNonEmpty(runnerKey, "Runner key must be provided.") });
|
|
884
1224
|
}
|
|
1225
|
+
/**
|
|
1226
|
+
* Sets how long the SDK waits for licensing validation to complete.
|
|
1227
|
+
* Use this when control-plane latency or private networking requires a longer validation window.
|
|
1228
|
+
*/
|
|
885
1229
|
withLicenseValidationTimeout(timeoutSeconds) {
|
|
886
1230
|
return this.WithLicenseValidationTimeout(timeoutSeconds);
|
|
887
1231
|
}
|
|
1232
|
+
/**
|
|
1233
|
+
* Sets how long the SDK waits for licensing validation to complete.
|
|
1234
|
+
* Use this when control-plane latency or private networking requires a longer validation window.
|
|
1235
|
+
*/
|
|
888
1236
|
WithLicenseValidationTimeout(timeoutSeconds) {
|
|
889
1237
|
if (!Number.isFinite(timeoutSeconds) || timeoutSeconds <= 0) {
|
|
890
1238
|
throw new RangeError("License validation timeout should be greater than zero.");
|
|
891
1239
|
}
|
|
892
1240
|
return this.mergeValues({ LicenseValidationTimeoutSeconds: timeoutSeconds });
|
|
893
1241
|
}
|
|
1242
|
+
/**
|
|
1243
|
+
* Sets the runtime node type.
|
|
1244
|
+
* Use this when a process should behave as a single node, coordinator, or agent.
|
|
1245
|
+
*/
|
|
894
1246
|
withNodeType(nodeType) {
|
|
895
1247
|
return this.WithNodeType(nodeType);
|
|
896
1248
|
}
|
|
1249
|
+
/**
|
|
1250
|
+
* Sets the runtime node type.
|
|
1251
|
+
* Use this when a process should behave as a single node, coordinator, or agent.
|
|
1252
|
+
*/
|
|
897
1253
|
WithNodeType(nodeType) {
|
|
898
1254
|
return this.mergeValues({ NodeType: parseNodeTypeToken(nodeType) });
|
|
899
1255
|
}
|
|
1256
|
+
/**
|
|
1257
|
+
* Sets the NATS server URL used for distributed cluster coordination.
|
|
1258
|
+
* Use this when coordinator and agent nodes communicate over NATS.
|
|
1259
|
+
*/
|
|
900
1260
|
withNatsServerUrl(natsUrl) {
|
|
901
1261
|
return this.WithNatsServerUrl(natsUrl);
|
|
902
1262
|
}
|
|
1263
|
+
/**
|
|
1264
|
+
* Sets the NATS server URL used for distributed cluster coordination.
|
|
1265
|
+
* Use this when coordinator and agent nodes communicate over NATS.
|
|
1266
|
+
*/
|
|
903
1267
|
WithNatsServerUrl(natsUrl) {
|
|
904
1268
|
return this.mergeValues({ NatsServerUrl: requireNonEmpty(natsUrl, "NATS server URL must be provided.") });
|
|
905
1269
|
}
|
|
1270
|
+
/**
|
|
1271
|
+
* Disables local report generation.
|
|
1272
|
+
* Use this when reports are unnecessary or should be handled exclusively by sinks.
|
|
1273
|
+
*/
|
|
906
1274
|
withoutReports() {
|
|
907
1275
|
return this.WithoutReports();
|
|
908
1276
|
}
|
|
1277
|
+
/**
|
|
1278
|
+
* Disables local report generation.
|
|
1279
|
+
* Use this when reports are unnecessary or should be handled exclusively by sinks.
|
|
1280
|
+
*/
|
|
909
1281
|
WithoutReports() {
|
|
910
1282
|
return this.mergeValues({ ReportsEnabled: false });
|
|
911
1283
|
}
|
|
1284
|
+
/**
|
|
1285
|
+
* Sets the base file name for generated reports.
|
|
1286
|
+
* Use this when exported reports should use a predictable naming convention.
|
|
1287
|
+
*/
|
|
912
1288
|
withReportFileName(reportFileName) {
|
|
913
1289
|
return this.WithReportFileName(reportFileName);
|
|
914
1290
|
}
|
|
1291
|
+
/**
|
|
1292
|
+
* Sets the base file name for generated reports.
|
|
1293
|
+
* Use this when exported reports should use a predictable naming convention.
|
|
1294
|
+
*/
|
|
915
1295
|
WithReportFileName(reportFileName) {
|
|
916
1296
|
return this.mergeValues({ ReportFileName: requireNonEmpty(reportFileName, "Report file name must be provided.") });
|
|
917
1297
|
}
|
|
1298
|
+
/**
|
|
1299
|
+
* Sets the output folder for generated reports.
|
|
1300
|
+
* Use this when report files should land in a specific directory.
|
|
1301
|
+
*/
|
|
918
1302
|
withReportFolder(reportFolderPath) {
|
|
919
1303
|
return this.WithReportFolder(reportFolderPath);
|
|
920
1304
|
}
|
|
1305
|
+
/**
|
|
1306
|
+
* Sets the output folder for generated reports.
|
|
1307
|
+
* Use this when report files should land in a specific directory.
|
|
1308
|
+
*/
|
|
921
1309
|
WithReportFolder(reportFolderPath) {
|
|
922
1310
|
return this.mergeValues({ ReportFolderPath: requireNonEmpty(reportFolderPath, "Report folder path must be provided.") });
|
|
923
1311
|
}
|
|
1312
|
+
/**
|
|
1313
|
+
* Restricts generated reports to specific formats.
|
|
1314
|
+
* Use this when you want only selected report artifacts such as HTML, CSV, or Markdown.
|
|
1315
|
+
*/
|
|
924
1316
|
withReportFormats(...reportFormats) {
|
|
925
1317
|
return this.WithReportFormats(...reportFormats);
|
|
926
1318
|
}
|
|
1319
|
+
/**
|
|
1320
|
+
* Restricts generated reports to specific formats.
|
|
1321
|
+
* Use this when you want only selected report artifacts such as HTML, CSV, or Markdown.
|
|
1322
|
+
*/
|
|
927
1323
|
WithReportFormats(...reportFormats) {
|
|
928
1324
|
if (!reportFormats.length) {
|
|
929
1325
|
throw new Error("At least one report format should be provided.");
|
|
@@ -934,18 +1330,34 @@ class LoadStrikeContext {
|
|
|
934
1330
|
}
|
|
935
1331
|
return this.mergeValues({ ReportFormats: normalized });
|
|
936
1332
|
}
|
|
1333
|
+
/**
|
|
1334
|
+
* Sets the realtime reporting cadence.
|
|
1335
|
+
* Use this when sinks or dashboards should receive updates at a controlled interval.
|
|
1336
|
+
*/
|
|
937
1337
|
withReportingInterval(intervalSeconds) {
|
|
938
1338
|
return this.WithReportingInterval(intervalSeconds);
|
|
939
1339
|
}
|
|
1340
|
+
/**
|
|
1341
|
+
* Sets the realtime reporting cadence.
|
|
1342
|
+
* Use this when sinks or dashboards should receive updates at a controlled interval.
|
|
1343
|
+
*/
|
|
940
1344
|
WithReportingInterval(intervalSeconds) {
|
|
941
1345
|
if (!Number.isFinite(intervalSeconds) || intervalSeconds <= 0) {
|
|
942
1346
|
throw new RangeError("Reporting interval should be greater than zero.");
|
|
943
1347
|
}
|
|
944
1348
|
return this.mergeValues({ ReportingIntervalSeconds: intervalSeconds });
|
|
945
1349
|
}
|
|
1350
|
+
/**
|
|
1351
|
+
* Registers one or more reporting sinks.
|
|
1352
|
+
* Use this when run results must be pushed to external observability or storage systems.
|
|
1353
|
+
*/
|
|
946
1354
|
withReportingSinks(...sinks) {
|
|
947
1355
|
return this.WithReportingSinks(...sinks);
|
|
948
1356
|
}
|
|
1357
|
+
/**
|
|
1358
|
+
* Registers one or more reporting sinks.
|
|
1359
|
+
* Use this when run results must be pushed to external observability or storage systems.
|
|
1360
|
+
*/
|
|
949
1361
|
WithReportingSinks(...sinks) {
|
|
950
1362
|
if (!sinks.length) {
|
|
951
1363
|
throw new Error("At least one reporting sink should be provided.");
|
|
@@ -956,9 +1368,17 @@ class LoadStrikeContext {
|
|
|
956
1368
|
validateNamedReportingSinks(sinks);
|
|
957
1369
|
return this.mergeValues({ ReportingSinks: sinks });
|
|
958
1370
|
}
|
|
1371
|
+
/**
|
|
1372
|
+
* Registers runtime policies for the run.
|
|
1373
|
+
* Use this when scenario selection or step execution should obey policy callbacks.
|
|
1374
|
+
*/
|
|
959
1375
|
withRuntimePolicies(...policies) {
|
|
960
1376
|
return this.WithRuntimePolicies(...policies);
|
|
961
1377
|
}
|
|
1378
|
+
/**
|
|
1379
|
+
* Registers runtime policies for the run.
|
|
1380
|
+
* Use this when scenario selection or step execution should obey policy callbacks.
|
|
1381
|
+
*/
|
|
962
1382
|
WithRuntimePolicies(...policies) {
|
|
963
1383
|
if (!policies.length) {
|
|
964
1384
|
throw new Error("At least one runtime policy should be provided.");
|
|
@@ -968,17 +1388,33 @@ class LoadStrikeContext {
|
|
|
968
1388
|
}
|
|
969
1389
|
return this.mergeValues({ RuntimePolicies: policies });
|
|
970
1390
|
}
|
|
1391
|
+
/**
|
|
1392
|
+
* Sets how runtime policy failures are handled.
|
|
1393
|
+
* Use this when policy errors should either fail fast or be tolerated.
|
|
1394
|
+
*/
|
|
971
1395
|
withRuntimePolicyErrorMode(mode) {
|
|
972
1396
|
return this.WithRuntimePolicyErrorMode(mode);
|
|
973
1397
|
}
|
|
1398
|
+
/**
|
|
1399
|
+
* Sets how runtime policy failures are handled.
|
|
1400
|
+
* Use this when policy errors should either fail fast or be tolerated.
|
|
1401
|
+
*/
|
|
974
1402
|
WithRuntimePolicyErrorMode(mode) {
|
|
975
1403
|
return this.mergeValues({
|
|
976
1404
|
RuntimePolicyErrorMode: normalizedRuntimePolicyErrorMode(mode)
|
|
977
1405
|
});
|
|
978
1406
|
}
|
|
1407
|
+
/**
|
|
1408
|
+
* Registers worker plugins for the run.
|
|
1409
|
+
* Use this when custom plugin data should be collected alongside run results.
|
|
1410
|
+
*/
|
|
979
1411
|
withWorkerPlugins(...plugins) {
|
|
980
1412
|
return this.WithWorkerPlugins(...plugins);
|
|
981
1413
|
}
|
|
1414
|
+
/**
|
|
1415
|
+
* Registers worker plugins for the run.
|
|
1416
|
+
* Use this when custom plugin data should be collected alongside run results.
|
|
1417
|
+
*/
|
|
982
1418
|
WithWorkerPlugins(...plugins) {
|
|
983
1419
|
if (!plugins.length) {
|
|
984
1420
|
throw new Error("At least one worker plugin should be provided.");
|
|
@@ -989,71 +1425,143 @@ class LoadStrikeContext {
|
|
|
989
1425
|
validateNamedWorkerPlugins(plugins);
|
|
990
1426
|
return this.mergeValues({ WorkerPlugins: plugins });
|
|
991
1427
|
}
|
|
1428
|
+
/**
|
|
1429
|
+
* Sets the minimum runtime log level.
|
|
1430
|
+
* Use this when the run should emit less or more operational detail.
|
|
1431
|
+
*/
|
|
992
1432
|
withMinimumLogLevel(minimumLogLevel) {
|
|
993
1433
|
return this.WithMinimumLogLevel(minimumLogLevel);
|
|
994
1434
|
}
|
|
1435
|
+
/**
|
|
1436
|
+
* Sets the minimum runtime log level.
|
|
1437
|
+
* Use this when the run should emit less or more operational detail.
|
|
1438
|
+
*/
|
|
995
1439
|
WithMinimumLogLevel(minimumLogLevel) {
|
|
996
1440
|
return this.mergeValues({
|
|
997
1441
|
MinimumLogLevel: parseMinimumLogLevelToken(requireNonEmpty(minimumLogLevel, "Minimum log level must be provided."))
|
|
998
1442
|
});
|
|
999
1443
|
}
|
|
1444
|
+
/**
|
|
1445
|
+
* Supplies a custom logger configuration factory.
|
|
1446
|
+
* Use this when the default runtime logging output is not enough for your environment.
|
|
1447
|
+
*/
|
|
1000
1448
|
withLoggerConfig(loggerConfig) {
|
|
1001
1449
|
return this.WithLoggerConfig(loggerConfig);
|
|
1002
1450
|
}
|
|
1451
|
+
/**
|
|
1452
|
+
* Supplies a custom logger configuration factory.
|
|
1453
|
+
* Use this when the default runtime logging output is not enough for your environment.
|
|
1454
|
+
*/
|
|
1003
1455
|
WithLoggerConfig(loggerConfig) {
|
|
1004
1456
|
if (typeof loggerConfig !== "function") {
|
|
1005
1457
|
throw new TypeError("Logger config must be provided.");
|
|
1006
1458
|
}
|
|
1007
1459
|
return this.mergeValues({ LoggerConfig: loggerConfig });
|
|
1008
1460
|
}
|
|
1461
|
+
/**
|
|
1462
|
+
* Sets the timeout for scenario completion.
|
|
1463
|
+
* Use this when long-running scenarios need an explicit completion window.
|
|
1464
|
+
*/
|
|
1009
1465
|
withScenarioCompletionTimeout(timeoutSeconds) {
|
|
1010
1466
|
return this.WithScenarioCompletionTimeout(timeoutSeconds);
|
|
1011
1467
|
}
|
|
1468
|
+
/**
|
|
1469
|
+
* Sets the timeout for scenario completion.
|
|
1470
|
+
* Use this when long-running scenarios need an explicit completion window.
|
|
1471
|
+
*/
|
|
1012
1472
|
WithScenarioCompletionTimeout(timeoutSeconds) {
|
|
1013
1473
|
if (!Number.isFinite(timeoutSeconds) || timeoutSeconds <= 0) {
|
|
1014
1474
|
throw new RangeError("Scenario completion timeout should be greater than zero.");
|
|
1015
1475
|
}
|
|
1016
1476
|
return this.mergeValues({ ScenarioCompletionTimeoutSeconds: timeoutSeconds });
|
|
1017
1477
|
}
|
|
1478
|
+
/**
|
|
1479
|
+
* Sets the timeout for cluster command round-trips.
|
|
1480
|
+
* Use this when distributed control messages need a tighter or looser deadline.
|
|
1481
|
+
*/
|
|
1018
1482
|
withClusterCommandTimeout(timeoutSeconds) {
|
|
1019
1483
|
return this.WithClusterCommandTimeout(timeoutSeconds);
|
|
1020
1484
|
}
|
|
1485
|
+
/**
|
|
1486
|
+
* Sets the timeout for cluster command round-trips.
|
|
1487
|
+
* Use this when distributed control messages need a tighter or looser deadline.
|
|
1488
|
+
*/
|
|
1021
1489
|
WithClusterCommandTimeout(timeoutSeconds) {
|
|
1022
1490
|
if (!Number.isFinite(timeoutSeconds) || timeoutSeconds <= 0) {
|
|
1023
1491
|
throw new RangeError("Cluster command timeout should be greater than zero.");
|
|
1024
1492
|
}
|
|
1025
1493
|
return this.mergeValues({ ClusterCommandTimeoutSeconds: timeoutSeconds });
|
|
1026
1494
|
}
|
|
1495
|
+
/**
|
|
1496
|
+
* Sets the retry limit for restartable failed iterations.
|
|
1497
|
+
* Use this when transient failures should be retried a fixed number of times.
|
|
1498
|
+
*/
|
|
1027
1499
|
withRestartIterationMaxAttempts(attempts) {
|
|
1028
1500
|
return this.WithRestartIterationMaxAttempts(attempts);
|
|
1029
1501
|
}
|
|
1502
|
+
/**
|
|
1503
|
+
* Sets the retry limit for restartable failed iterations.
|
|
1504
|
+
* Use this when transient failures should be retried a fixed number of times.
|
|
1505
|
+
*/
|
|
1030
1506
|
WithRestartIterationMaxAttempts(attempts) {
|
|
1031
1507
|
if (!Number.isFinite(attempts) || attempts < 0) {
|
|
1032
1508
|
throw new RangeError("Restart iteration max attempts should be zero or greater.");
|
|
1033
1509
|
}
|
|
1034
1510
|
return this.mergeValues({ RestartIterationMaxAttempts: Math.trunc(attempts) });
|
|
1035
1511
|
}
|
|
1512
|
+
/**
|
|
1513
|
+
* Sets the session identifier for this run.
|
|
1514
|
+
* Use this when downstream logs, reports, or external systems need a stable session id.
|
|
1515
|
+
*/
|
|
1036
1516
|
withSessionId(sessionId) {
|
|
1037
1517
|
return this.WithSessionId(sessionId);
|
|
1038
1518
|
}
|
|
1519
|
+
/**
|
|
1520
|
+
* Sets the session identifier for this run.
|
|
1521
|
+
* Use this when downstream logs, reports, or external systems need a stable session id.
|
|
1522
|
+
*/
|
|
1039
1523
|
WithSessionId(sessionId) {
|
|
1040
1524
|
return this.mergeValues({ SessionId: requireNonEmpty(sessionId, "Session id must be provided.") });
|
|
1041
1525
|
}
|
|
1526
|
+
/**
|
|
1527
|
+
* Sets the test suite label for the run.
|
|
1528
|
+
* Use this when related tests should be grouped under a suite name.
|
|
1529
|
+
*/
|
|
1042
1530
|
withTestSuite(testSuite) {
|
|
1043
1531
|
return this.WithTestSuite(testSuite);
|
|
1044
1532
|
}
|
|
1533
|
+
/**
|
|
1534
|
+
* Sets the test suite label for the run.
|
|
1535
|
+
* Use this when related tests should be grouped under a suite name.
|
|
1536
|
+
*/
|
|
1045
1537
|
WithTestSuite(testSuite) {
|
|
1046
1538
|
return this.mergeValues({ TestSuite: requireNonEmpty(testSuite, "Test suite must be provided.") });
|
|
1047
1539
|
}
|
|
1540
|
+
/**
|
|
1541
|
+
* Sets the test name label for the run.
|
|
1542
|
+
* Use this when reports and logs should expose a human-readable test identifier.
|
|
1543
|
+
*/
|
|
1048
1544
|
withTestName(testName) {
|
|
1049
1545
|
return this.WithTestName(testName);
|
|
1050
1546
|
}
|
|
1547
|
+
/**
|
|
1548
|
+
* Sets the test name label for the run.
|
|
1549
|
+
* Use this when reports and logs should expose a human-readable test identifier.
|
|
1550
|
+
*/
|
|
1051
1551
|
WithTestName(testName) {
|
|
1052
1552
|
return this.mergeValues({ TestName: requireNonEmpty(testName, "Test name must be provided.") });
|
|
1053
1553
|
}
|
|
1554
|
+
/**
|
|
1555
|
+
* Sets the cluster identifier for this run.
|
|
1556
|
+
* Use this when multiple cluster nodes must join the same distributed execution.
|
|
1557
|
+
*/
|
|
1054
1558
|
withClusterId(clusterId) {
|
|
1055
1559
|
return this.WithClusterId(clusterId);
|
|
1056
1560
|
}
|
|
1561
|
+
/**
|
|
1562
|
+
* Sets the cluster identifier for this run.
|
|
1563
|
+
* Use this when multiple cluster nodes must join the same distributed execution.
|
|
1564
|
+
*/
|
|
1057
1565
|
WithClusterId(clusterId) {
|
|
1058
1566
|
return this.mergeValues({ ClusterId: requireNonEmpty(clusterId, "Cluster id must be provided.") });
|
|
1059
1567
|
}
|
|
@@ -1066,6 +1574,10 @@ class LoadStrikeContext {
|
|
|
1066
1574
|
this.runArgs = [...runArgs];
|
|
1067
1575
|
return this;
|
|
1068
1576
|
}
|
|
1577
|
+
/**
|
|
1578
|
+
* Configures registered scenarios for this SDK object.
|
|
1579
|
+
* Use this when registered scenarios should be set explicitly before the run starts.
|
|
1580
|
+
*/
|
|
1069
1581
|
withRegisteredScenarios(...scenarios) {
|
|
1070
1582
|
return this.assignState(this.values, scenarios, this.runArgs);
|
|
1071
1583
|
}
|
|
@@ -1102,57 +1614,105 @@ class LoadStrikeScenario {
|
|
|
1102
1614
|
static CreateAsync(name, runHandler) {
|
|
1103
1615
|
return LoadStrikeScenario.createAsync(name, runHandler);
|
|
1104
1616
|
}
|
|
1617
|
+
/**
|
|
1618
|
+
* Creates a placeholder scenario that returns the default success reply.
|
|
1619
|
+
* Use this when you want a scenario shell before adding setup, cleanup, or more detailed behavior.
|
|
1620
|
+
*/
|
|
1105
1621
|
static empty(name) {
|
|
1106
1622
|
return LoadStrikeScenario.create(name, () => LoadStrikeResponse.ok());
|
|
1107
1623
|
}
|
|
1624
|
+
/**
|
|
1625
|
+
* Creates a placeholder scenario that returns the default success reply.
|
|
1626
|
+
* Use this when you want a scenario shell before adding setup, cleanup, or more detailed behavior.
|
|
1627
|
+
*/
|
|
1108
1628
|
static Empty(name) {
|
|
1109
1629
|
return LoadStrikeScenario.empty(name);
|
|
1110
1630
|
}
|
|
1111
1631
|
get Name() {
|
|
1112
1632
|
return this.name;
|
|
1113
1633
|
}
|
|
1634
|
+
/**
|
|
1635
|
+
* Configures init for this SDK object.
|
|
1636
|
+
* Use this when init should be set explicitly before the run starts.
|
|
1637
|
+
*/
|
|
1114
1638
|
withInit(handler) {
|
|
1115
1639
|
if (typeof handler !== "function") {
|
|
1116
1640
|
throw new TypeError("Init handler must be provided.");
|
|
1117
1641
|
}
|
|
1118
1642
|
return new LoadStrikeScenario(this.name, this.runHandler, handler, this.cleanHandler, this.loadSimulations, this.thresholds, this.trackingConfiguration, this.maxFailCount, this.withoutWarmUpValue, this.warmUpDurationSeconds, this.weight, this.restartIterationOnFail);
|
|
1119
1643
|
}
|
|
1644
|
+
/**
|
|
1645
|
+
* Configures init async for this SDK object.
|
|
1646
|
+
* Use this when init async should be set explicitly before the run starts.
|
|
1647
|
+
*/
|
|
1120
1648
|
withInitAsync(handler) {
|
|
1121
1649
|
return this.withInit(handler);
|
|
1122
1650
|
}
|
|
1651
|
+
/**
|
|
1652
|
+
* Configures clean for this SDK object.
|
|
1653
|
+
* Use this when clean should be set explicitly before the run starts.
|
|
1654
|
+
*/
|
|
1123
1655
|
withClean(handler) {
|
|
1124
1656
|
if (typeof handler !== "function") {
|
|
1125
1657
|
throw new TypeError("Clean handler must be provided.");
|
|
1126
1658
|
}
|
|
1127
1659
|
return new LoadStrikeScenario(this.name, this.runHandler, this.initHandler, handler, this.loadSimulations, this.thresholds, this.trackingConfiguration, this.maxFailCount, this.withoutWarmUpValue, this.warmUpDurationSeconds, this.weight, this.restartIterationOnFail);
|
|
1128
1660
|
}
|
|
1661
|
+
/**
|
|
1662
|
+
* Configures clean async for this SDK object.
|
|
1663
|
+
* Use this when clean async should be set explicitly before the run starts.
|
|
1664
|
+
*/
|
|
1129
1665
|
withCleanAsync(handler) {
|
|
1130
1666
|
return this.withClean(handler);
|
|
1131
1667
|
}
|
|
1668
|
+
/**
|
|
1669
|
+
* Configures max fail count for this SDK object.
|
|
1670
|
+
* Use this when max fail count should be set explicitly before the run starts.
|
|
1671
|
+
*/
|
|
1132
1672
|
withMaxFailCount(maxFailCount) {
|
|
1133
1673
|
if (!Number.isFinite(maxFailCount)) {
|
|
1134
1674
|
throw new RangeError("maxFailCount should be a finite number.");
|
|
1135
1675
|
}
|
|
1136
1676
|
return new LoadStrikeScenario(this.name, this.runHandler, this.initHandler, this.cleanHandler, this.loadSimulations, this.thresholds, this.trackingConfiguration, Math.trunc(maxFailCount), this.withoutWarmUpValue, this.warmUpDurationSeconds, this.weight, this.restartIterationOnFail);
|
|
1137
1677
|
}
|
|
1678
|
+
/**
|
|
1679
|
+
* Configures out warm up for this SDK object.
|
|
1680
|
+
* Use this when out warm up should be set explicitly before the run starts.
|
|
1681
|
+
*/
|
|
1138
1682
|
withoutWarmUp() {
|
|
1139
1683
|
return new LoadStrikeScenario(this.name, this.runHandler, this.initHandler, this.cleanHandler, this.loadSimulations, this.thresholds, this.trackingConfiguration, this.maxFailCount, true, this.warmUpDurationSeconds, this.weight, this.restartIterationOnFail);
|
|
1140
1684
|
}
|
|
1685
|
+
/**
|
|
1686
|
+
* Configures warm up duration for this SDK object.
|
|
1687
|
+
* Use this when warm up duration should be set explicitly before the run starts.
|
|
1688
|
+
*/
|
|
1141
1689
|
withWarmUpDuration(durationSeconds) {
|
|
1142
1690
|
if (!Number.isFinite(durationSeconds)) {
|
|
1143
1691
|
throw new RangeError("Warmup duration should be a finite number.");
|
|
1144
1692
|
}
|
|
1145
1693
|
return new LoadStrikeScenario(this.name, this.runHandler, this.initHandler, this.cleanHandler, this.loadSimulations, this.thresholds, this.trackingConfiguration, this.maxFailCount, this.withoutWarmUpValue, durationSeconds, this.weight, this.restartIterationOnFail);
|
|
1146
1694
|
}
|
|
1695
|
+
/**
|
|
1696
|
+
* Configures weight for this SDK object.
|
|
1697
|
+
* Use this when weight should be set explicitly before the run starts.
|
|
1698
|
+
*/
|
|
1147
1699
|
withWeight(weight) {
|
|
1148
1700
|
if (!Number.isFinite(weight)) {
|
|
1149
1701
|
throw new RangeError("Weight should be a finite number.");
|
|
1150
1702
|
}
|
|
1151
1703
|
return new LoadStrikeScenario(this.name, this.runHandler, this.initHandler, this.cleanHandler, this.loadSimulations, this.thresholds, this.trackingConfiguration, this.maxFailCount, this.withoutWarmUpValue, this.warmUpDurationSeconds, Math.trunc(weight), this.restartIterationOnFail);
|
|
1152
1704
|
}
|
|
1705
|
+
/**
|
|
1706
|
+
* Configures restart iteration on fail for this SDK object.
|
|
1707
|
+
* Use this when restart iteration on fail should be set explicitly before the run starts.
|
|
1708
|
+
*/
|
|
1153
1709
|
withRestartIterationOnFail(shouldRestart) {
|
|
1154
1710
|
return new LoadStrikeScenario(this.name, this.runHandler, this.initHandler, this.cleanHandler, this.loadSimulations, this.thresholds, this.trackingConfiguration, this.maxFailCount, this.withoutWarmUpValue, this.warmUpDurationSeconds, this.weight, Boolean(shouldRestart));
|
|
1155
1711
|
}
|
|
1712
|
+
/**
|
|
1713
|
+
* Configures cross platform tracking for this SDK object.
|
|
1714
|
+
* Use this when cross platform tracking should be set explicitly before the run starts.
|
|
1715
|
+
*/
|
|
1156
1716
|
withCrossPlatformTracking(configuration) {
|
|
1157
1717
|
if (!configuration || typeof configuration !== "object" || Array.isArray(configuration)) {
|
|
1158
1718
|
throw new TypeError("Tracking configuration must be provided.");
|
|
@@ -1170,39 +1730,79 @@ class LoadStrikeScenario {
|
|
|
1170
1730
|
validateRuntimeTrackingConfiguration(copied, sourceEndpoint, destinationEndpoint);
|
|
1171
1731
|
return new LoadStrikeScenario(this.name, this.runHandler, this.initHandler, this.cleanHandler, this.loadSimulations, this.thresholds, copied, this.maxFailCount, this.withoutWarmUpValue, this.warmUpDurationSeconds, this.weight, this.restartIterationOnFail);
|
|
1172
1732
|
}
|
|
1733
|
+
/**
|
|
1734
|
+
* Configures load simulations for this SDK object.
|
|
1735
|
+
* Use this when load simulations should be set explicitly before the run starts.
|
|
1736
|
+
*/
|
|
1173
1737
|
withLoadSimulations(...simulations) {
|
|
1174
1738
|
if (!simulations.length) {
|
|
1175
1739
|
throw new Error("At least one load simulation should be provided.");
|
|
1176
1740
|
}
|
|
1177
1741
|
return new LoadStrikeScenario(this.name, this.runHandler, this.initHandler, this.cleanHandler, simulations.map((simulation) => attachLoadSimulationProjection({ ...simulation })), this.thresholds, this.trackingConfiguration, this.maxFailCount, this.withoutWarmUpValue, this.warmUpDurationSeconds, this.weight, this.restartIterationOnFail);
|
|
1178
1742
|
}
|
|
1743
|
+
/**
|
|
1744
|
+
* Configures thresholds for this SDK object.
|
|
1745
|
+
* Use this when thresholds should be set explicitly before the run starts.
|
|
1746
|
+
*/
|
|
1179
1747
|
withThresholds(...thresholds) {
|
|
1180
1748
|
if (!thresholds.length) {
|
|
1181
1749
|
throw new Error("At least one threshold should be provided.");
|
|
1182
1750
|
}
|
|
1183
1751
|
return new LoadStrikeScenario(this.name, this.runHandler, this.initHandler, this.cleanHandler, this.loadSimulations, thresholds.map((threshold) => ({ ...threshold })), this.trackingConfiguration, this.maxFailCount, this.withoutWarmUpValue, this.warmUpDurationSeconds, this.weight, this.restartIterationOnFail);
|
|
1184
1752
|
}
|
|
1753
|
+
/**
|
|
1754
|
+
* Returns simulations.
|
|
1755
|
+
* Use this when simulations is required for branching, logging, or assertions.
|
|
1756
|
+
*/
|
|
1185
1757
|
getSimulations() {
|
|
1186
1758
|
return this.loadSimulations.map((simulation) => attachLoadSimulationProjection({ ...simulation }));
|
|
1187
1759
|
}
|
|
1760
|
+
/**
|
|
1761
|
+
* Returns thresholds.
|
|
1762
|
+
* Use this when thresholds is required for branching, logging, or assertions.
|
|
1763
|
+
*/
|
|
1188
1764
|
getThresholds() {
|
|
1189
1765
|
return this.thresholds;
|
|
1190
1766
|
}
|
|
1767
|
+
/**
|
|
1768
|
+
* Returns tracking configuration.
|
|
1769
|
+
* Use this when tracking configuration is required for branching, logging, or assertions.
|
|
1770
|
+
*/
|
|
1191
1771
|
getTrackingConfiguration() {
|
|
1192
1772
|
return this.trackingConfiguration ? { ...this.trackingConfiguration } : undefined;
|
|
1193
1773
|
}
|
|
1774
|
+
/**
|
|
1775
|
+
* Returns max fail count.
|
|
1776
|
+
* Use this when max fail count is required for branching, logging, or assertions.
|
|
1777
|
+
*/
|
|
1194
1778
|
getMaxFailCount() {
|
|
1195
1779
|
return this.maxFailCount;
|
|
1196
1780
|
}
|
|
1781
|
+
/**
|
|
1782
|
+
* Exposes the public isWithoutWarmUp operation.
|
|
1783
|
+
* Use this when the surrounding wrapper type makes this operation the clearest way to express your intent.
|
|
1784
|
+
*/
|
|
1197
1785
|
isWithoutWarmUp() {
|
|
1198
1786
|
return this.withoutWarmUpValue;
|
|
1199
1787
|
}
|
|
1788
|
+
/**
|
|
1789
|
+
* Returns warm up duration seconds.
|
|
1790
|
+
* Use this when warm up duration seconds is required for branching, logging, or assertions.
|
|
1791
|
+
*/
|
|
1200
1792
|
getWarmUpDurationSeconds() {
|
|
1201
1793
|
return this.warmUpDurationSeconds;
|
|
1202
1794
|
}
|
|
1795
|
+
/**
|
|
1796
|
+
* Returns weight.
|
|
1797
|
+
* Use this when weight is required for branching, logging, or assertions.
|
|
1798
|
+
*/
|
|
1203
1799
|
getWeight() {
|
|
1204
1800
|
return this.weight;
|
|
1205
1801
|
}
|
|
1802
|
+
/**
|
|
1803
|
+
* Exposes the public shouldRestartIterationOnFail operation.
|
|
1804
|
+
* Use this when the surrounding wrapper type makes this operation the clearest way to express your intent.
|
|
1805
|
+
*/
|
|
1206
1806
|
shouldRestartIterationOnFail() {
|
|
1207
1807
|
return this.restartIterationOnFail;
|
|
1208
1808
|
}
|
|
@@ -1228,39 +1828,87 @@ class LoadStrikeScenario {
|
|
|
1228
1828
|
return LoadStrikeResponse.fail("exception", resolveRuntimeErrorMessage(error, "scenario failed"), 0);
|
|
1229
1829
|
}
|
|
1230
1830
|
}
|
|
1831
|
+
/**
|
|
1832
|
+
* Configures cross platform tracking for this SDK object.
|
|
1833
|
+
* Use this when cross platform tracking should be set explicitly before the run starts.
|
|
1834
|
+
*/
|
|
1231
1835
|
WithCrossPlatformTracking(configuration) {
|
|
1232
1836
|
return this.withCrossPlatformTracking(configuration);
|
|
1233
1837
|
}
|
|
1838
|
+
/**
|
|
1839
|
+
* Configures init for this SDK object.
|
|
1840
|
+
* Use this when init should be set explicitly before the run starts.
|
|
1841
|
+
*/
|
|
1234
1842
|
WithInit(handler) {
|
|
1235
1843
|
return this.withInit(handler);
|
|
1236
1844
|
}
|
|
1845
|
+
/**
|
|
1846
|
+
* Configures init async for this SDK object.
|
|
1847
|
+
* Use this when init async should be set explicitly before the run starts.
|
|
1848
|
+
*/
|
|
1237
1849
|
WithInitAsync(handler) {
|
|
1238
1850
|
return this.withInitAsync(handler);
|
|
1239
1851
|
}
|
|
1852
|
+
/**
|
|
1853
|
+
* Configures clean for this SDK object.
|
|
1854
|
+
* Use this when clean should be set explicitly before the run starts.
|
|
1855
|
+
*/
|
|
1240
1856
|
WithClean(handler) {
|
|
1241
1857
|
return this.withClean(handler);
|
|
1242
1858
|
}
|
|
1859
|
+
/**
|
|
1860
|
+
* Configures clean async for this SDK object.
|
|
1861
|
+
* Use this when clean async should be set explicitly before the run starts.
|
|
1862
|
+
*/
|
|
1243
1863
|
WithCleanAsync(handler) {
|
|
1244
1864
|
return this.withCleanAsync(handler);
|
|
1245
1865
|
}
|
|
1866
|
+
/**
|
|
1867
|
+
* Configures load simulations for this SDK object.
|
|
1868
|
+
* Use this when load simulations should be set explicitly before the run starts.
|
|
1869
|
+
*/
|
|
1246
1870
|
WithLoadSimulations(...simulations) {
|
|
1247
1871
|
return this.withLoadSimulations(...simulations);
|
|
1248
1872
|
}
|
|
1873
|
+
/**
|
|
1874
|
+
* Configures max fail count for this SDK object.
|
|
1875
|
+
* Use this when max fail count should be set explicitly before the run starts.
|
|
1876
|
+
*/
|
|
1249
1877
|
WithMaxFailCount(maxFailCount) {
|
|
1250
1878
|
return this.withMaxFailCount(maxFailCount);
|
|
1251
1879
|
}
|
|
1880
|
+
/**
|
|
1881
|
+
* Configures out warm up for this SDK object.
|
|
1882
|
+
* Use this when out warm up should be set explicitly before the run starts.
|
|
1883
|
+
*/
|
|
1252
1884
|
WithoutWarmUp() {
|
|
1253
1885
|
return this.withoutWarmUp();
|
|
1254
1886
|
}
|
|
1887
|
+
/**
|
|
1888
|
+
* Configures restart iteration on fail for this SDK object.
|
|
1889
|
+
* Use this when restart iteration on fail should be set explicitly before the run starts.
|
|
1890
|
+
*/
|
|
1255
1891
|
WithRestartIterationOnFail(shouldRestart) {
|
|
1256
1892
|
return this.withRestartIterationOnFail(shouldRestart);
|
|
1257
1893
|
}
|
|
1894
|
+
/**
|
|
1895
|
+
* Configures thresholds for this SDK object.
|
|
1896
|
+
* Use this when thresholds should be set explicitly before the run starts.
|
|
1897
|
+
*/
|
|
1258
1898
|
WithThresholds(...thresholds) {
|
|
1259
1899
|
return this.withThresholds(...thresholds);
|
|
1260
1900
|
}
|
|
1901
|
+
/**
|
|
1902
|
+
* Configures warm up duration for this SDK object.
|
|
1903
|
+
* Use this when warm up duration should be set explicitly before the run starts.
|
|
1904
|
+
*/
|
|
1261
1905
|
WithWarmUpDuration(durationSeconds) {
|
|
1262
1906
|
return this.withWarmUpDuration(durationSeconds);
|
|
1263
1907
|
}
|
|
1908
|
+
/**
|
|
1909
|
+
* Configures weight for this SDK object.
|
|
1910
|
+
* Use this when weight should be set explicitly before the run starts.
|
|
1911
|
+
*/
|
|
1264
1912
|
WithWeight(weight) {
|
|
1265
1913
|
return this.withWeight(weight);
|
|
1266
1914
|
}
|
|
@@ -1272,115 +1920,251 @@ class LoadStrikeRunner {
|
|
|
1272
1920
|
this.options = normalizeRunnerOptionCollectionShapes(options);
|
|
1273
1921
|
this.contextConfigurators = [...contextConfigurators];
|
|
1274
1922
|
}
|
|
1923
|
+
/**
|
|
1924
|
+
* Creates a new instance of this public SDK type.
|
|
1925
|
+
* Use this when you are starting a run definition from scratch.
|
|
1926
|
+
*/
|
|
1275
1927
|
static create() {
|
|
1276
1928
|
return new LoadStrikeRunner([], {});
|
|
1277
1929
|
}
|
|
1930
|
+
/**
|
|
1931
|
+
* Creates a new instance of this public SDK type.
|
|
1932
|
+
* Use this when you are starting a run definition from scratch.
|
|
1933
|
+
*/
|
|
1278
1934
|
static Create() {
|
|
1279
1935
|
return LoadStrikeRunner.create();
|
|
1280
1936
|
}
|
|
1937
|
+
/**
|
|
1938
|
+
* Registers one or more scenarios on a fresh runnable context.
|
|
1939
|
+
* Use this when you want a context immediately without composing a runner first.
|
|
1940
|
+
*/
|
|
1281
1941
|
static registerScenarios(...scenarios) {
|
|
1282
1942
|
validateRegisteredScenarios(scenarios);
|
|
1283
1943
|
return new LoadStrikeContext({}, scenarios);
|
|
1284
1944
|
}
|
|
1945
|
+
/**
|
|
1946
|
+
* Registers one or more scenarios on a fresh runnable context.
|
|
1947
|
+
* Use this when you want a context immediately without composing a runner first.
|
|
1948
|
+
*/
|
|
1285
1949
|
static RegisterScenarios(...scenarios) {
|
|
1286
1950
|
return LoadStrikeRunner.registerScenarios(...scenarios);
|
|
1287
1951
|
}
|
|
1952
|
+
/**
|
|
1953
|
+
* Toggles realtime console metric output.
|
|
1954
|
+
* Use this when a local run or CI log should stream live throughput and latency updates.
|
|
1955
|
+
*/
|
|
1288
1956
|
static DisplayConsoleMetrics(context, enable) {
|
|
1289
1957
|
return context.DisplayConsoleMetrics(enable);
|
|
1290
1958
|
}
|
|
1959
|
+
/**
|
|
1960
|
+
* Toggles local development cluster mode.
|
|
1961
|
+
* Use this when you want to simulate coordinator and agent behavior on a single machine.
|
|
1962
|
+
*/
|
|
1291
1963
|
static EnableLocalDevCluster(context, enable) {
|
|
1292
1964
|
return context.EnableLocalDevCluster(enable);
|
|
1293
1965
|
}
|
|
1966
|
+
/**
|
|
1967
|
+
* Loads run settings from a JSON config file.
|
|
1968
|
+
* Use this when configuration should come from a checked-in or generated config document.
|
|
1969
|
+
*/
|
|
1294
1970
|
static LoadConfig(context, path) {
|
|
1295
1971
|
return context.LoadConfig(path);
|
|
1296
1972
|
}
|
|
1973
|
+
/**
|
|
1974
|
+
* Loads infrastructure settings for sinks, plugins, or transport dependencies.
|
|
1975
|
+
* Use this when runtime integrations depend on external connection details.
|
|
1976
|
+
*/
|
|
1297
1977
|
static LoadInfraConfig(context, path) {
|
|
1298
1978
|
return context.LoadInfraConfig(path);
|
|
1299
1979
|
}
|
|
1980
|
+
/**
|
|
1981
|
+
* Executes the configured workload through the SDK runtime.
|
|
1982
|
+
* Use this when configuration is complete and you are ready to start the run.
|
|
1983
|
+
*/
|
|
1300
1984
|
static Run(context, ...args) {
|
|
1301
1985
|
return context.Run(args);
|
|
1302
1986
|
}
|
|
1987
|
+
/**
|
|
1988
|
+
* Sets the agent group for this node or run.
|
|
1989
|
+
* Use this when only a subset of agents should pick up a particular workload.
|
|
1990
|
+
*/
|
|
1303
1991
|
static WithAgentGroup(context, agentGroup) {
|
|
1304
1992
|
return context.WithAgentGroup(agentGroup);
|
|
1305
1993
|
}
|
|
1994
|
+
/**
|
|
1995
|
+
* Sets the requested agent count.
|
|
1996
|
+
* Use this when a coordinator should fan work out across a specific number of agents.
|
|
1997
|
+
*/
|
|
1306
1998
|
static WithAgentsCount(context, agentsCount) {
|
|
1307
1999
|
return context.WithAgentsCount(agentsCount);
|
|
1308
2000
|
}
|
|
2001
|
+
/**
|
|
2002
|
+
* Targets scenarios for agent nodes only.
|
|
2003
|
+
* Use this when agents should execute only a subset of the registered scenarios.
|
|
2004
|
+
*/
|
|
1309
2005
|
static WithAgentTargetScenarios(context, ...scenarioNames) {
|
|
1310
2006
|
return context.WithAgentTargetScenarios(...scenarioNames);
|
|
1311
2007
|
}
|
|
2008
|
+
/**
|
|
2009
|
+
* Sets the cluster identifier for this run.
|
|
2010
|
+
* Use this when multiple cluster nodes must join the same distributed execution.
|
|
2011
|
+
*/
|
|
1312
2012
|
static WithClusterId(context, clusterId) {
|
|
1313
2013
|
return context.WithClusterId(clusterId);
|
|
1314
2014
|
}
|
|
2015
|
+
/**
|
|
2016
|
+
* Targets scenarios for the coordinator only.
|
|
2017
|
+
* Use this when orchestration or control-node work should run on the coordinator itself.
|
|
2018
|
+
*/
|
|
1315
2019
|
static WithCoordinatorTargetScenarios(context, ...scenarioNames) {
|
|
1316
2020
|
return context.WithCoordinatorTargetScenarios(...scenarioNames);
|
|
1317
2021
|
}
|
|
2022
|
+
/**
|
|
2023
|
+
* Sets the runner key used for licensing validation.
|
|
2024
|
+
* Use this when the run must authenticate against the licensing API before it starts.
|
|
2025
|
+
*/
|
|
1318
2026
|
static WithRunnerKey(context, runnerKey) {
|
|
1319
2027
|
return context.WithRunnerKey(runnerKey);
|
|
1320
2028
|
}
|
|
2029
|
+
/**
|
|
2030
|
+
* Sets how long the SDK waits for licensing validation to complete.
|
|
2031
|
+
* Use this when control-plane latency or private networking requires a longer validation window.
|
|
2032
|
+
*/
|
|
1321
2033
|
static WithLicenseValidationTimeout(context, timeoutSeconds) {
|
|
1322
2034
|
return context.WithLicenseValidationTimeout(timeoutSeconds);
|
|
1323
2035
|
}
|
|
2036
|
+
/**
|
|
2037
|
+
* Supplies a custom logger configuration factory.
|
|
2038
|
+
* Use this when the default runtime logging output is not enough for your environment.
|
|
2039
|
+
*/
|
|
1324
2040
|
static WithLoggerConfig(context, loggerConfig) {
|
|
1325
2041
|
return context.WithLoggerConfig(loggerConfig);
|
|
1326
2042
|
}
|
|
2043
|
+
/**
|
|
2044
|
+
* Sets the minimum runtime log level.
|
|
2045
|
+
* Use this when the run should emit less or more operational detail.
|
|
2046
|
+
*/
|
|
1327
2047
|
static WithMinimumLogLevel(context, minimumLogLevel) {
|
|
1328
2048
|
return context.WithMinimumLogLevel(minimumLogLevel);
|
|
1329
2049
|
}
|
|
2050
|
+
/**
|
|
2051
|
+
* Sets the NATS server URL used for distributed cluster coordination.
|
|
2052
|
+
* Use this when coordinator and agent nodes communicate over NATS.
|
|
2053
|
+
*/
|
|
1330
2054
|
static WithNatsServerUrl(context, natsUrl) {
|
|
1331
2055
|
return context.WithNatsServerUrl(natsUrl);
|
|
1332
2056
|
}
|
|
1333
2057
|
static WithNodeType(context, nodeType) {
|
|
1334
2058
|
return context.WithNodeType(nodeType);
|
|
1335
2059
|
}
|
|
2060
|
+
/**
|
|
2061
|
+
* Disables local report generation.
|
|
2062
|
+
* Use this when reports are unnecessary or should be handled exclusively by sinks.
|
|
2063
|
+
*/
|
|
1336
2064
|
static WithoutReports(context) {
|
|
1337
2065
|
return context.WithoutReports();
|
|
1338
2066
|
}
|
|
2067
|
+
/**
|
|
2068
|
+
* Sets the base file name for generated reports.
|
|
2069
|
+
* Use this when exported reports should use a predictable naming convention.
|
|
2070
|
+
*/
|
|
1339
2071
|
static WithReportFileName(context, reportFileName) {
|
|
1340
2072
|
return context.WithReportFileName(reportFileName);
|
|
1341
2073
|
}
|
|
2074
|
+
/**
|
|
2075
|
+
* Sets the output folder for generated reports.
|
|
2076
|
+
* Use this when report files should land in a specific directory.
|
|
2077
|
+
*/
|
|
1342
2078
|
static WithReportFolder(context, reportFolderPath) {
|
|
1343
2079
|
return context.WithReportFolder(reportFolderPath);
|
|
1344
2080
|
}
|
|
1345
2081
|
static WithReportFormats(context, ...reportFormats) {
|
|
1346
2082
|
return context.WithReportFormats(...reportFormats);
|
|
1347
2083
|
}
|
|
2084
|
+
/**
|
|
2085
|
+
* Sets the realtime reporting cadence.
|
|
2086
|
+
* Use this when sinks or dashboards should receive updates at a controlled interval.
|
|
2087
|
+
*/
|
|
1348
2088
|
static WithReportingInterval(context, intervalSeconds) {
|
|
1349
2089
|
return context.WithReportingInterval(intervalSeconds);
|
|
1350
2090
|
}
|
|
2091
|
+
/**
|
|
2092
|
+
* Registers one or more reporting sinks.
|
|
2093
|
+
* Use this when run results must be pushed to external observability or storage systems.
|
|
2094
|
+
*/
|
|
1351
2095
|
static WithReportingSinks(context, ...sinks) {
|
|
1352
2096
|
return context.WithReportingSinks(...sinks);
|
|
1353
2097
|
}
|
|
2098
|
+
/**
|
|
2099
|
+
* Registers runtime policies for the run.
|
|
2100
|
+
* Use this when scenario selection or step execution should obey policy callbacks.
|
|
2101
|
+
*/
|
|
1354
2102
|
static WithRuntimePolicies(context, ...policies) {
|
|
1355
2103
|
return context.WithRuntimePolicies(...policies);
|
|
1356
2104
|
}
|
|
1357
2105
|
static WithRuntimePolicyErrorMode(context, mode) {
|
|
1358
2106
|
return context.WithRuntimePolicyErrorMode(mode);
|
|
1359
2107
|
}
|
|
2108
|
+
/**
|
|
2109
|
+
* Sets the timeout for scenario completion.
|
|
2110
|
+
* Use this when long-running scenarios need an explicit completion window.
|
|
2111
|
+
*/
|
|
1360
2112
|
static WithScenarioCompletionTimeout(context, timeoutSeconds) {
|
|
1361
2113
|
return context.WithScenarioCompletionTimeout(timeoutSeconds);
|
|
1362
2114
|
}
|
|
2115
|
+
/**
|
|
2116
|
+
* Sets the timeout for cluster command round-trips.
|
|
2117
|
+
* Use this when distributed control messages need a tighter or looser deadline.
|
|
2118
|
+
*/
|
|
1363
2119
|
static WithClusterCommandTimeout(context, timeoutSeconds) {
|
|
1364
2120
|
return context.WithClusterCommandTimeout(timeoutSeconds);
|
|
1365
2121
|
}
|
|
2122
|
+
/**
|
|
2123
|
+
* Sets the retry limit for restartable failed iterations.
|
|
2124
|
+
* Use this when transient failures should be retried a fixed number of times.
|
|
2125
|
+
*/
|
|
1366
2126
|
static WithRestartIterationMaxAttempts(context, attempts) {
|
|
1367
2127
|
return context.WithRestartIterationMaxAttempts(attempts);
|
|
1368
2128
|
}
|
|
2129
|
+
/**
|
|
2130
|
+
* Sets the session identifier for this run.
|
|
2131
|
+
* Use this when downstream logs, reports, or external systems need a stable session id.
|
|
2132
|
+
*/
|
|
1369
2133
|
static WithSessionId(context, sessionId) {
|
|
1370
2134
|
return context.WithSessionId(sessionId);
|
|
1371
2135
|
}
|
|
2136
|
+
/**
|
|
2137
|
+
* Targets a shared set of scenarios.
|
|
2138
|
+
* Use this when only selected scenarios should execute for the current node or run.
|
|
2139
|
+
*/
|
|
1372
2140
|
static WithTargetScenarios(context, ...scenarioNames) {
|
|
1373
2141
|
return context.WithTargetScenarios(...scenarioNames);
|
|
1374
2142
|
}
|
|
2143
|
+
/**
|
|
2144
|
+
* Sets the test name label for the run.
|
|
2145
|
+
* Use this when reports and logs should expose a human-readable test identifier.
|
|
2146
|
+
*/
|
|
1375
2147
|
static WithTestName(context, testName) {
|
|
1376
2148
|
return context.WithTestName(testName);
|
|
1377
2149
|
}
|
|
2150
|
+
/**
|
|
2151
|
+
* Sets the test suite label for the run.
|
|
2152
|
+
* Use this when related tests should be grouped under a suite name.
|
|
2153
|
+
*/
|
|
1378
2154
|
static WithTestSuite(context, testSuite) {
|
|
1379
2155
|
return context.WithTestSuite(testSuite);
|
|
1380
2156
|
}
|
|
2157
|
+
/**
|
|
2158
|
+
* Registers worker plugins for the run.
|
|
2159
|
+
* Use this when custom plugin data should be collected alongside run results.
|
|
2160
|
+
*/
|
|
1381
2161
|
static WithWorkerPlugins(context, ...plugins) {
|
|
1382
2162
|
return context.WithWorkerPlugins(...plugins);
|
|
1383
2163
|
}
|
|
2164
|
+
/**
|
|
2165
|
+
* Adds a scenario to the current runner.
|
|
2166
|
+
* Use this when the run should include one more scenario definition.
|
|
2167
|
+
*/
|
|
1384
2168
|
addScenario(scenario) {
|
|
1385
2169
|
if (!(scenario instanceof LoadStrikeScenario)) {
|
|
1386
2170
|
throw new TypeError("Scenario must be provided.");
|
|
@@ -1388,9 +2172,17 @@ class LoadStrikeRunner {
|
|
|
1388
2172
|
this.scenarios = [...this.scenarios, scenario];
|
|
1389
2173
|
return this;
|
|
1390
2174
|
}
|
|
2175
|
+
/**
|
|
2176
|
+
* Adds a scenario to the current runner.
|
|
2177
|
+
* Use this when the run should include one more scenario definition.
|
|
2178
|
+
*/
|
|
1391
2179
|
AddScenario(scenario) {
|
|
1392
2180
|
return this.addScenario(scenario);
|
|
1393
2181
|
}
|
|
2182
|
+
/**
|
|
2183
|
+
* Adds multiple scenarios to the current runner.
|
|
2184
|
+
* Use this when the run should execute a batch of scenario definitions together.
|
|
2185
|
+
*/
|
|
1394
2186
|
addScenarios(...scenarios) {
|
|
1395
2187
|
if (!scenarios.length) {
|
|
1396
2188
|
throw new Error("At least one scenario must be provided.");
|
|
@@ -1401,9 +2193,17 @@ class LoadStrikeRunner {
|
|
|
1401
2193
|
this.scenarios = [...this.scenarios, ...scenarios];
|
|
1402
2194
|
return this;
|
|
1403
2195
|
}
|
|
2196
|
+
/**
|
|
2197
|
+
* Adds multiple scenarios to the current runner.
|
|
2198
|
+
* Use this when the run should execute a batch of scenario definitions together.
|
|
2199
|
+
*/
|
|
1404
2200
|
AddScenarios(...scenarios) {
|
|
1405
2201
|
return this.addScenarios(...scenarios);
|
|
1406
2202
|
}
|
|
2203
|
+
/**
|
|
2204
|
+
* Applies a grouped configuration change to the current builder or context.
|
|
2205
|
+
* Use this when several related settings should be supplied in one step.
|
|
2206
|
+
*/
|
|
1407
2207
|
configure(options) {
|
|
1408
2208
|
if (!options || typeof options !== "object" || Array.isArray(options)) {
|
|
1409
2209
|
throw new TypeError("Configure options must be a non-null object.");
|
|
@@ -1430,6 +2230,10 @@ class LoadStrikeRunner {
|
|
|
1430
2230
|
}
|
|
1431
2231
|
return this.configure(input);
|
|
1432
2232
|
}
|
|
2233
|
+
/**
|
|
2234
|
+
* Copies settings from an existing context snapshot.
|
|
2235
|
+
* Use this when a runner should inherit configuration that was already assembled elsewhere.
|
|
2236
|
+
*/
|
|
1433
2237
|
configureContext(context) {
|
|
1434
2238
|
if (!context || typeof context !== "object" || Array.isArray(context)) {
|
|
1435
2239
|
throw new TypeError("Configure context must be a LoadStrikeContext or run context object.");
|
|
@@ -1439,66 +2243,138 @@ class LoadStrikeRunner {
|
|
|
1439
2243
|
: new LoadStrikeContext(context);
|
|
1440
2244
|
return this.configure(runtimeContext.toRunnerOptions());
|
|
1441
2245
|
}
|
|
2246
|
+
/**
|
|
2247
|
+
* Copies settings from an existing context snapshot.
|
|
2248
|
+
* Use this when a runner should inherit configuration that was already assembled elsewhere.
|
|
2249
|
+
*/
|
|
1442
2250
|
ConfigureContext(context) {
|
|
1443
2251
|
return this.configureContext(context);
|
|
1444
2252
|
}
|
|
2253
|
+
/**
|
|
2254
|
+
* Sets the test suite label for the run.
|
|
2255
|
+
* Use this when related tests should be grouped under a suite name.
|
|
2256
|
+
*/
|
|
1445
2257
|
withTestSuite(testSuite) {
|
|
1446
2258
|
return this.configure({ testSuite: requireNonEmpty(testSuite, "Test suite must be provided.") });
|
|
1447
2259
|
}
|
|
2260
|
+
/**
|
|
2261
|
+
* Sets the test suite label for the run.
|
|
2262
|
+
* Use this when related tests should be grouped under a suite name.
|
|
2263
|
+
*/
|
|
1448
2264
|
WithTestSuite(testSuite) {
|
|
1449
2265
|
return this.withTestSuite(testSuite);
|
|
1450
2266
|
}
|
|
2267
|
+
/**
|
|
2268
|
+
* Sets the test name label for the run.
|
|
2269
|
+
* Use this when reports and logs should expose a human-readable test identifier.
|
|
2270
|
+
*/
|
|
1451
2271
|
withTestName(testName) {
|
|
1452
2272
|
return this.configure({ testName: requireNonEmpty(testName, "Test name must be provided.") });
|
|
1453
2273
|
}
|
|
2274
|
+
/**
|
|
2275
|
+
* Sets the test name label for the run.
|
|
2276
|
+
* Use this when reports and logs should expose a human-readable test identifier.
|
|
2277
|
+
*/
|
|
1454
2278
|
WithTestName(testName) {
|
|
1455
2279
|
return this.withTestName(testName);
|
|
1456
2280
|
}
|
|
2281
|
+
/**
|
|
2282
|
+
* Sets the session identifier for this run.
|
|
2283
|
+
* Use this when downstream logs, reports, or external systems need a stable session id.
|
|
2284
|
+
*/
|
|
1457
2285
|
withSessionId(sessionId) {
|
|
1458
2286
|
return this.configure({ sessionId: requireNonEmpty(sessionId, "Session id must be provided.") });
|
|
1459
2287
|
}
|
|
2288
|
+
/**
|
|
2289
|
+
* Sets the session identifier for this run.
|
|
2290
|
+
* Use this when downstream logs, reports, or external systems need a stable session id.
|
|
2291
|
+
*/
|
|
1460
2292
|
WithSessionId(sessionId) {
|
|
1461
2293
|
return this.withSessionId(sessionId);
|
|
1462
2294
|
}
|
|
2295
|
+
/**
|
|
2296
|
+
* Sets the output folder for generated reports.
|
|
2297
|
+
* Use this when report files should land in a specific directory.
|
|
2298
|
+
*/
|
|
1463
2299
|
withReportFolder(reportFolderPath) {
|
|
1464
2300
|
return this.configure({ reportFolderPath: requireNonEmpty(reportFolderPath, "Report folder path must be provided.") });
|
|
1465
2301
|
}
|
|
2302
|
+
/**
|
|
2303
|
+
* Sets the output folder for generated reports.
|
|
2304
|
+
* Use this when report files should land in a specific directory.
|
|
2305
|
+
*/
|
|
1466
2306
|
WithReportFolder(reportFolderPath) {
|
|
1467
2307
|
return this.withReportFolder(reportFolderPath);
|
|
1468
2308
|
}
|
|
2309
|
+
/**
|
|
2310
|
+
* Sets the realtime reporting cadence.
|
|
2311
|
+
* Use this when sinks or dashboards should receive updates at a controlled interval.
|
|
2312
|
+
*/
|
|
1469
2313
|
withReportingInterval(intervalSeconds) {
|
|
1470
2314
|
if (!Number.isFinite(intervalSeconds) || intervalSeconds <= 0) {
|
|
1471
2315
|
throw new RangeError("Reporting interval should be greater than zero.");
|
|
1472
2316
|
}
|
|
1473
2317
|
return this.configure({ reportingIntervalSeconds: intervalSeconds });
|
|
1474
2318
|
}
|
|
2319
|
+
/**
|
|
2320
|
+
* Sets the realtime reporting cadence.
|
|
2321
|
+
* Use this when sinks or dashboards should receive updates at a controlled interval.
|
|
2322
|
+
*/
|
|
1475
2323
|
WithReportingInterval(intervalSeconds) {
|
|
1476
2324
|
return this.withReportingInterval(intervalSeconds);
|
|
1477
2325
|
}
|
|
2326
|
+
/**
|
|
2327
|
+
* Sets the timeout for cluster command round-trips.
|
|
2328
|
+
* Use this when distributed control messages need a tighter or looser deadline.
|
|
2329
|
+
*/
|
|
1478
2330
|
withClusterCommandTimeout(timeoutSeconds) {
|
|
1479
2331
|
if (!Number.isFinite(timeoutSeconds) || timeoutSeconds <= 0) {
|
|
1480
2332
|
throw new RangeError("Cluster command timeout should be greater than zero.");
|
|
1481
2333
|
}
|
|
1482
2334
|
return this.configure({ clusterCommandTimeoutSeconds: timeoutSeconds });
|
|
1483
2335
|
}
|
|
2336
|
+
/**
|
|
2337
|
+
* Sets the timeout for cluster command round-trips.
|
|
2338
|
+
* Use this when distributed control messages need a tighter or looser deadline.
|
|
2339
|
+
*/
|
|
1484
2340
|
WithClusterCommandTimeout(timeoutSeconds) {
|
|
1485
2341
|
return this.withClusterCommandTimeout(timeoutSeconds);
|
|
1486
2342
|
}
|
|
2343
|
+
/**
|
|
2344
|
+
* Sets the retry limit for restartable failed iterations.
|
|
2345
|
+
* Use this when transient failures should be retried a fixed number of times.
|
|
2346
|
+
*/
|
|
1487
2347
|
withRestartIterationMaxAttempts(attempts) {
|
|
1488
2348
|
if (!Number.isFinite(attempts) || attempts < 0) {
|
|
1489
2349
|
throw new RangeError("Restart iteration max attempts should be zero or greater.");
|
|
1490
2350
|
}
|
|
1491
2351
|
return this.configure({ restartIterationMaxAttempts: Math.trunc(attempts) });
|
|
1492
2352
|
}
|
|
2353
|
+
/**
|
|
2354
|
+
* Sets the retry limit for restartable failed iterations.
|
|
2355
|
+
* Use this when transient failures should be retried a fixed number of times.
|
|
2356
|
+
*/
|
|
1493
2357
|
WithRestartIterationMaxAttempts(attempts) {
|
|
1494
2358
|
return this.withRestartIterationMaxAttempts(attempts);
|
|
1495
2359
|
}
|
|
2360
|
+
/**
|
|
2361
|
+
* Disables local report generation.
|
|
2362
|
+
* Use this when reports are unnecessary or should be handled exclusively by sinks.
|
|
2363
|
+
*/
|
|
1496
2364
|
withoutReports() {
|
|
1497
2365
|
return this.configure({ reportsEnabled: false });
|
|
1498
2366
|
}
|
|
2367
|
+
/**
|
|
2368
|
+
* Disables local report generation.
|
|
2369
|
+
* Use this when reports are unnecessary or should be handled exclusively by sinks.
|
|
2370
|
+
*/
|
|
1499
2371
|
WithoutReports() {
|
|
1500
2372
|
return this.withoutReports();
|
|
1501
2373
|
}
|
|
2374
|
+
/**
|
|
2375
|
+
* Builds the current configuration into a runnable context.
|
|
2376
|
+
* Use this when you want to inspect or reuse the final run settings before execution.
|
|
2377
|
+
*/
|
|
1502
2378
|
buildContext() {
|
|
1503
2379
|
if (!this.scenarios.length) {
|
|
1504
2380
|
throw new Error("At least one scenario must be added before building the runner context.");
|
|
@@ -1513,6 +2389,10 @@ class LoadStrikeRunner {
|
|
|
1513
2389
|
}
|
|
1514
2390
|
return context;
|
|
1515
2391
|
}
|
|
2392
|
+
/**
|
|
2393
|
+
* Builds the current configuration into a runnable context.
|
|
2394
|
+
* Use this when you want to inspect or reuse the final run settings before execution.
|
|
2395
|
+
*/
|
|
1516
2396
|
BuildContext() {
|
|
1517
2397
|
return this.buildContext();
|
|
1518
2398
|
}
|
|
@@ -1569,14 +2449,17 @@ class LoadStrikeRunner {
|
|
|
1569
2449
|
const selectedScenarios = clusterMode === "local-coordinator" || clusterMode === "nats-coordinator"
|
|
1570
2450
|
? await this.filterScenariosWithPolicies(this.scenarios, policies, policyErrors, runtimePolicyErrorMode)
|
|
1571
2451
|
: await this.selectScenarios(policies, policyErrors, runtimePolicyErrorMode);
|
|
1572
|
-
|
|
2452
|
+
if (clusterMode === "nats-agent") {
|
|
2453
|
+
return this.runAgentWithNats(createdUtc, testInfo, nodeInfo);
|
|
2454
|
+
}
|
|
2455
|
+
licensePayload = buildLicenseValidationPayload({
|
|
2456
|
+
...this.options,
|
|
2457
|
+
sessionId: testInfo.sessionId
|
|
2458
|
+
}, this.scenarios);
|
|
1573
2459
|
licenseClient = new local_js_1.LoadStrikeLocalClient({
|
|
1574
2460
|
licenseValidationTimeoutMs: Math.max((this.options.licenseValidationTimeoutSeconds ?? 10) * 1000, 1)
|
|
1575
2461
|
});
|
|
1576
2462
|
licenseSession = await licenseClient.acquireLicenseLease(licensePayload);
|
|
1577
|
-
if (clusterMode === "nats-agent") {
|
|
1578
|
-
return this.runAgentWithNats(createdUtc, testInfo, nodeInfo);
|
|
1579
|
-
}
|
|
1580
2463
|
const loggerSetup = createLoggerSetup(this.options.loggerConfig, this.options.minimumLogLevel, this.options, testInfo, nodeInfo);
|
|
1581
2464
|
const runLogger = loggerSetup.logger;
|
|
1582
2465
|
const scenarioStartInfos = selectedScenarios.map((scenario, index) => {
|
|
@@ -1666,12 +2549,12 @@ class LoadStrikeRunner {
|
|
|
1666
2549
|
let result;
|
|
1667
2550
|
let metricStats;
|
|
1668
2551
|
if (clusterMode === "local-coordinator") {
|
|
1669
|
-
const aggregated = await this.runCoordinatorWithLocalAgents(selectedScenarios, testInfo, nodeInfo);
|
|
2552
|
+
const aggregated = await this.runCoordinatorWithLocalAgents(selectedScenarios, testInfo, nodeInfo, licenseClient, licenseSession);
|
|
1670
2553
|
metricStats = aggregated.metrics;
|
|
1671
2554
|
result = toDetailedRunResultFromNodeStats(aggregated, started.toISOString(), sinkErrors, policyErrors);
|
|
1672
2555
|
}
|
|
1673
2556
|
else if (clusterMode === "nats-coordinator") {
|
|
1674
|
-
const aggregated = await this.runCoordinatorWithNats(selectedScenarios, testInfo, nodeInfo);
|
|
2557
|
+
const aggregated = await this.runCoordinatorWithNats(selectedScenarios, testInfo, nodeInfo, licenseClient, licenseSession);
|
|
1675
2558
|
metricStats = aggregated.metrics;
|
|
1676
2559
|
result = toDetailedRunResultFromNodeStats(aggregated, started.toISOString(), sinkErrors, policyErrors);
|
|
1677
2560
|
}
|
|
@@ -1818,8 +2701,8 @@ class LoadStrikeRunner {
|
|
|
1818
2701
|
natsServerUrl: undefined,
|
|
1819
2702
|
reportFolderPath: (0, node_path_1.resolve)(this.options.reportFolderPath ?? "./reports", sanitizeReportFileName(machineName)),
|
|
1820
2703
|
targetScenarios,
|
|
1821
|
-
agentTargetScenarios:
|
|
1822
|
-
coordinatorTargetScenarios:
|
|
2704
|
+
agentTargetScenarios: undefined,
|
|
2705
|
+
coordinatorTargetScenarios: undefined,
|
|
1823
2706
|
reportsEnabled: false,
|
|
1824
2707
|
displayConsoleMetrics: false,
|
|
1825
2708
|
reportingSinks: includeWorkerExtensions ? this.options.reportingSinks : [],
|
|
@@ -1837,16 +2720,40 @@ class LoadStrikeRunner {
|
|
|
1837
2720
|
logFiles: [...(childResult.logFiles ?? [])]
|
|
1838
2721
|
};
|
|
1839
2722
|
}
|
|
1840
|
-
async runCoordinatorWithLocalAgents(scenarios, testInfo, nodeInfo) {
|
|
2723
|
+
async runCoordinatorWithLocalAgents(scenarios, testInfo, nodeInfo, licenseClient, licenseSession) {
|
|
2724
|
+
if (!licenseClient) {
|
|
2725
|
+
throw new Error("Coordinator agent execution authorization requires an initialized licensing client.");
|
|
2726
|
+
}
|
|
2727
|
+
const controllerRunToken = stringValueOrDefault(licenseSession?.runToken, "").trim();
|
|
2728
|
+
if (!controllerRunToken) {
|
|
2729
|
+
throw new Error("Coordinator agent execution authorization requires an active controller run token.");
|
|
2730
|
+
}
|
|
1841
2731
|
const assignments = planRuntimeClusterAssignments(scenarios, Math.max(this.options.agentsCount ?? 1, 1), this.options.targetScenarios ?? [], this.options.agentTargetScenarios ?? []);
|
|
1842
|
-
const nodeResults = await Promise.all(assignments.map((targetScenarios, index) =>
|
|
2732
|
+
const nodeResults = await Promise.all(assignments.map(async (targetScenarios, index) => {
|
|
2733
|
+
const commandId = (0, node_crypto_1.randomBytes)(16).toString("hex");
|
|
2734
|
+
const agentExecutionToken = await licenseClient.createAgentExecutionToken(controllerRunToken, testInfo.sessionId, commandId, index, assignments.length, targetScenarios);
|
|
2735
|
+
return this.runClusterChildNode(targetScenarios, "Agent", `local-agent-${index + 1}`, false, {
|
|
2736
|
+
sessionId: testInfo.sessionId,
|
|
2737
|
+
testSuite: testInfo.testSuite,
|
|
2738
|
+
testName: testInfo.testName,
|
|
2739
|
+
agentCommandId: commandId,
|
|
2740
|
+
agentExecutionToken
|
|
2741
|
+
});
|
|
2742
|
+
}));
|
|
1843
2743
|
const coordinatorTargets = [...(this.options.coordinatorTargetScenarios ?? [])];
|
|
1844
2744
|
if (coordinatorTargets.length) {
|
|
1845
2745
|
nodeResults.push(await this.runClusterChildNode(coordinatorTargets, "Coordinator", nodeInfo.machineName, false));
|
|
1846
2746
|
}
|
|
1847
2747
|
return aggregateNodeStats(testInfo, { ...nodeInfo, nodeType: "Coordinator" }, nodeResults);
|
|
1848
2748
|
}
|
|
1849
|
-
async runCoordinatorWithNats(scenarios, testInfo, nodeInfo) {
|
|
2749
|
+
async runCoordinatorWithNats(scenarios, testInfo, nodeInfo, licenseClient, licenseSession) {
|
|
2750
|
+
if (!licenseClient) {
|
|
2751
|
+
throw new Error("Coordinator agent execution authorization requires an initialized licensing client.");
|
|
2752
|
+
}
|
|
2753
|
+
const controllerRunToken = stringValueOrDefault(licenseSession?.runToken, "").trim();
|
|
2754
|
+
if (!controllerRunToken) {
|
|
2755
|
+
throw new Error("Coordinator agent execution authorization requires an active controller run token.");
|
|
2756
|
+
}
|
|
1850
2757
|
const assignments = planRuntimeClusterAssignments(scenarios, Math.max(this.options.agentsCount ?? 1, 1), this.options.targetScenarios ?? [], this.options.agentTargetScenarios ?? []);
|
|
1851
2758
|
const coordinator = new cluster_js_1.DistributedClusterCoordinator({
|
|
1852
2759
|
clusterId: this.options.clusterId ?? "local",
|
|
@@ -1860,7 +2767,7 @@ class LoadStrikeRunner {
|
|
|
1860
2767
|
? { ServerUrl: this.options.natsServerUrl }
|
|
1861
2768
|
: undefined
|
|
1862
2769
|
});
|
|
1863
|
-
const dispatch = await coordinator.dispatch(assignments);
|
|
2770
|
+
const dispatch = await coordinator.dispatch(assignments, (command) => licenseClient.createAgentExecutionToken(controllerRunToken, testInfo.sessionId, command.commandId, command.agentIndex, command.agentCount, command.targetScenarios));
|
|
1864
2771
|
const nodes = dispatch.nodeResults.map((value) => clusterNodeResultToNodeStats(value, testInfo, { ...nodeInfo, nodeType: "Agent" }));
|
|
1865
2772
|
const coordinatorTargets = [...(this.options.coordinatorTargetScenarios ?? [])];
|
|
1866
2773
|
if (coordinatorTargets.length) {
|
|
@@ -1890,7 +2797,9 @@ class LoadStrikeRunner {
|
|
|
1890
2797
|
handledStats = await this.runClusterChildNode(dispatch.scenarioNames, "Agent", nodeInfo.machineName, true, {
|
|
1891
2798
|
sessionId: testInfo.sessionId,
|
|
1892
2799
|
testSuite: testInfo.testSuite,
|
|
1893
|
-
testName: testInfo.testName
|
|
2800
|
+
testName: testInfo.testName,
|
|
2801
|
+
agentCommandId: dispatch.commandId,
|
|
2802
|
+
agentExecutionToken: dispatch.agentRunToken
|
|
1894
2803
|
});
|
|
1895
2804
|
return {
|
|
1896
2805
|
nodeId: handledStats.nodeInfo.machineName,
|
|
@@ -6533,10 +7442,16 @@ function toRunContext(options) {
|
|
|
6533
7442
|
RestartIterationMaxAttempts: normalized.restartIterationMaxAttempts,
|
|
6534
7443
|
WorkerPlugins: normalized.workerPlugins,
|
|
6535
7444
|
CustomSettings: normalized.customSettings,
|
|
6536
|
-
GlobalCustomSettings: normalized.globalCustomSettings
|
|
7445
|
+
GlobalCustomSettings: normalized.globalCustomSettings,
|
|
7446
|
+
AgentExecutionToken: normalized.agentExecutionToken,
|
|
7447
|
+
AgentCommandId: normalized.agentCommandId
|
|
6537
7448
|
};
|
|
6538
7449
|
}
|
|
6539
7450
|
class RuntimePolicyCallbackError extends Error {
|
|
7451
|
+
/**
|
|
7452
|
+
* Exposes the public constructor operation.
|
|
7453
|
+
* Use this when the surrounding wrapper type makes this operation the clearest way to express your intent.
|
|
7454
|
+
*/
|
|
6540
7455
|
constructor(message) {
|
|
6541
7456
|
super(message);
|
|
6542
7457
|
this.name = "RuntimePolicyCallbackError";
|