@artilleryio/int-core 2.1.0-5516ff0 → 2.1.0-5b355f8
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/lib/engine_http.js +2 -1
- package/lib/runner.js +17 -5
- package/lib/ssms.js +1 -0
- package/package.json +3 -2
package/lib/engine_http.js
CHANGED
|
@@ -167,7 +167,7 @@ HttpEngine.prototype.createScenario = function (scenarioSpec, ee) {
|
|
|
167
167
|
});
|
|
168
168
|
});
|
|
169
169
|
|
|
170
|
-
return self.compile(tasks, scenarioSpec
|
|
170
|
+
return self.compile(tasks, scenarioSpec, ee);
|
|
171
171
|
};
|
|
172
172
|
|
|
173
173
|
HttpEngine.prototype.step = function step(requestSpec, ee, opts) {
|
|
@@ -868,6 +868,7 @@ HttpEngine.prototype.compile = function compile(tasks, scenarioSpec, ee) {
|
|
|
868
868
|
|
|
869
869
|
return async function scenario(initialContext, callback) {
|
|
870
870
|
initialContext = self.setInitialContext(initialContext);
|
|
871
|
+
|
|
871
872
|
ee.emit('started');
|
|
872
873
|
let context = initialContext;
|
|
873
874
|
for (const task of tasks) {
|
package/lib/runner.js
CHANGED
|
@@ -263,7 +263,7 @@ function runScenario(script, metrics, runState, contextVars) {
|
|
|
263
263
|
const w = engineUtil.template(scenario.weight, {
|
|
264
264
|
vars: variableValues
|
|
265
265
|
});
|
|
266
|
-
scenario.weight = isNaN(parseInt(w)) ? 0 : parseInt(w);
|
|
266
|
+
scenario.weight = isNaN(parseInt(w)) ? 0 : parseInt(w); //eslint-disable-line radix
|
|
267
267
|
debug(
|
|
268
268
|
`scenario ${scenario.name} weight has been set to ${scenario.weight}`
|
|
269
269
|
);
|
|
@@ -328,7 +328,9 @@ function runScenario(script, metrics, runState, contextVars) {
|
|
|
328
328
|
metrics.counter('vusers.created', 1);
|
|
329
329
|
|
|
330
330
|
const scenarioStartedAt = process.hrtime();
|
|
331
|
-
const scenarioContext = createContext(script, contextVars
|
|
331
|
+
const scenarioContext = createContext(script, contextVars, {
|
|
332
|
+
scenario: script.scenarios[i]
|
|
333
|
+
});
|
|
332
334
|
|
|
333
335
|
const finish = process.hrtime(start);
|
|
334
336
|
const runScenarioDelta = finish[0] * 1e9 + finish[1];
|
|
@@ -391,7 +393,13 @@ function inlineVariables(script) {
|
|
|
391
393
|
/**
|
|
392
394
|
* Create initial context for a scenario.
|
|
393
395
|
*/
|
|
394
|
-
function createContext(script, contextVars) {
|
|
396
|
+
function createContext(script, contextVars, additionalProperties = {}) {
|
|
397
|
+
//allow for additional properties to be passed in, but not override vars and funcs
|
|
398
|
+
const additionalPropertiesWithoutOverride = _.omit(additionalProperties, [
|
|
399
|
+
'vars',
|
|
400
|
+
'funcs'
|
|
401
|
+
]);
|
|
402
|
+
|
|
395
403
|
const INITIAL_CONTEXT = {
|
|
396
404
|
vars: Object.assign(
|
|
397
405
|
{
|
|
@@ -406,7 +414,8 @@ function createContext(script, contextVars) {
|
|
|
406
414
|
$randomNumber: $randomNumber,
|
|
407
415
|
$randomString: $randomString,
|
|
408
416
|
$template: (input) => engineUtil.template(input, { vars: result.vars })
|
|
409
|
-
}
|
|
417
|
+
},
|
|
418
|
+
...additionalPropertiesWithoutOverride
|
|
410
419
|
};
|
|
411
420
|
|
|
412
421
|
let result = INITIAL_CONTEXT;
|
|
@@ -453,7 +462,10 @@ function handleScriptHook(hook, script, hookEvents, contextVars = {}) {
|
|
|
453
462
|
const name = script[hook].engine || 'http';
|
|
454
463
|
const engine = engines.find((e) => e.__name === name);
|
|
455
464
|
const hookScenario = engine.createScenario(script[hook], ee);
|
|
456
|
-
const hookContext = createContext(script, contextVars
|
|
465
|
+
const hookContext = createContext(script, contextVars, {
|
|
466
|
+
scenario: script[hook]
|
|
467
|
+
});
|
|
468
|
+
|
|
457
469
|
hookScenario(hookContext, function (err, context) {
|
|
458
470
|
if (err) {
|
|
459
471
|
debug(err);
|
package/lib/ssms.js
CHANGED
|
@@ -626,6 +626,7 @@ function summarizeHistogram(h) {
|
|
|
626
626
|
min: round(h.min, 1),
|
|
627
627
|
max: round(h.max, 1),
|
|
628
628
|
count: h.count,
|
|
629
|
+
mean: round(h.sum/h.count, 1),
|
|
629
630
|
p50: round(h.getValueAtQuantile(0.5), 1),
|
|
630
631
|
median: round(h.getValueAtQuantile(0.5), 1), // Here for compatibility
|
|
631
632
|
p75: round(h.getValueAtQuantile(0.75), 1),
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@artilleryio/int-core",
|
|
3
|
-
"version": "2.1.0-
|
|
3
|
+
"version": "2.1.0-5b355f8",
|
|
4
4
|
"main": "./index.js",
|
|
5
|
+
"license": "MPL-2.0",
|
|
5
6
|
"dependencies": {
|
|
6
|
-
"@artilleryio/int-commons": "2.0.1-
|
|
7
|
+
"@artilleryio/int-commons": "2.0.1-5b355f8",
|
|
7
8
|
"@artilleryio/sketches-js": "^2.1.1",
|
|
8
9
|
"agentkeepalive": "^4.1.0",
|
|
9
10
|
"arrivals": "^2.1.2",
|