@artilleryio/int-core 2.0.11 → 2.1.0-1eac5df

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/phases.js CHANGED
@@ -12,6 +12,7 @@ const arrivals = require('arrivals');
12
12
  const debug = require('debug')('phases');
13
13
  const { randomUUID } = require('crypto');
14
14
  const driftless = require('driftless');
15
+ const ms = require('ms');
15
16
 
16
17
  module.exports = phaser;
17
18
 
@@ -25,7 +26,6 @@ function phaser(phaseSpecs) {
25
26
  let ee = new EventEmitter();
26
27
 
27
28
  let tasks = _.map(phaseSpecs, function (spec, i) {
28
- // Cast defined but non-number (eg: from ENV) values
29
29
  [
30
30
  'arrivalRate',
31
31
  'arrivalCount',
@@ -34,9 +34,27 @@ function phaser(phaseSpecs) {
34
34
  'duration',
35
35
  'maxVusers'
36
36
  ].forEach(function (k) {
37
- if (!isUndefined(spec[k]) && typeof spec[k] !== 'number') {
38
- spec[k] = _.toNumber(spec[k]);
37
+ if (isUndefined(spec[k]) || spec[k] == 'number') {
38
+ return;
39
39
  }
40
+
41
+ if (k == 'duration' || k == 'pause') {
42
+ //if it's already a number in string format, don't apply ms, as it's the default behaviour, so we don't want to do ms calculations
43
+ //otherwise, ms returns the value in milliseconds, so we need to convert to seconds
44
+ const convertedDuration = Number.isInteger(_.toNumber(spec[k]))
45
+ ? spec[k]
46
+ : ms(spec[k]) / 1000;
47
+
48
+ //throw error if invalid time format to prevent test from running infinitely
49
+ if (!convertedDuration) {
50
+ throw new Error(`Invalid ${k} for phase: ${spec[k]}`);
51
+ }
52
+
53
+ spec[k] = convertedDuration;
54
+ }
55
+
56
+ // Cast defined but non-number (eg: from ENV) values
57
+ spec[k] = _.toNumber(spec[k]);
40
58
  });
41
59
 
42
60
  if (isUndefined(spec.index)) {
package/lib/runner.js CHANGED
@@ -299,9 +299,17 @@ function runScenario(script, metrics, runState, contextVars) {
299
299
 
300
300
  runState.compiledScenarios = _.map(
301
301
  script.scenarios,
302
- function (scenarioSpec) {
302
+ function (scenarioSpec, scenarioIndex) {
303
303
  const name = scenarioSpec.engine || script.config.engine || 'http';
304
304
  const engine = runState.engines.find((e) => e.__name === name);
305
+
306
+ if (typeof engine === 'undefined') {
307
+ const scenarioNameOrIndex = scenarioSpec.name || scenarioIndex;
308
+ throw new Error(
309
+ `Failed to run scenario "${scenarioNameOrIndex}": unknown engine "${name}". Did you forget to include it in "config.engines.${name}"?`
310
+ );
311
+ }
312
+
305
313
  return engine.createScenario(scenarioSpec, runState.scenarioEvents);
306
314
  }
307
315
  );
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.0.11",
3
+ "version": "2.1.0-1eac5df",
4
4
  "main": "./index.js",
5
+ "license": "MPL-2.0",
5
6
  "dependencies": {
6
- "@artilleryio/int-commons": "latest",
7
+ "@artilleryio/int-commons": "2.0.1-1eac5df",
7
8
  "@artilleryio/sketches-js": "^2.1.1",
8
9
  "agentkeepalive": "^4.1.0",
9
10
  "arrivals": "^2.1.2",
@@ -25,6 +26,7 @@
25
26
  "hpagent": "^0.1.1",
26
27
  "https-proxy-agent": "^5.0.0",
27
28
  "lodash": "^4.17.19",
29
+ "ms": "^2.1.3",
28
30
  "protobufjs": "^7.2.4",
29
31
  "proxy": "^1.0.2",
30
32
  "socket.io-client": "^4.5.1",
@@ -37,7 +39,9 @@
37
39
  "scripts": {
38
40
  "lint": "eslint --ext \".js,.ts,.tsx\" .",
39
41
  "lint-fix": "npm run lint -- --fix",
40
- "test": "tap --no-coverage --color --timeout=300 test/core/unit/*.test.js && bash test/core/run.sh"
42
+ "test": "npm run test:unit && npm run test:acceptance",
43
+ "test:unit": "tap --no-coverage --color --timeout=300 test/core/unit/*.test.js",
44
+ "test:acceptance": "bash test/core/run.sh"
41
45
  },
42
46
  "devDependencies": {
43
47
  "@hapi/basic": "^6.0.0",