@artilleryio/int-core 2.0.11 → 2.1.0-d39abda
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 +21 -3
- package/package.json +6 -3
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 (
|
|
38
|
-
|
|
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/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@artilleryio/int-core",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0-d39abda",
|
|
4
4
|
"main": "./index.js",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@artilleryio/int-commons": "
|
|
6
|
+
"@artilleryio/int-commons": "2.0.1-d39abda",
|
|
7
7
|
"@artilleryio/sketches-js": "^2.1.1",
|
|
8
8
|
"agentkeepalive": "^4.1.0",
|
|
9
9
|
"arrivals": "^2.1.2",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"hpagent": "^0.1.1",
|
|
26
26
|
"https-proxy-agent": "^5.0.0",
|
|
27
27
|
"lodash": "^4.17.19",
|
|
28
|
+
"ms": "^2.1.3",
|
|
28
29
|
"protobufjs": "^7.2.4",
|
|
29
30
|
"proxy": "^1.0.2",
|
|
30
31
|
"socket.io-client": "^4.5.1",
|
|
@@ -37,7 +38,9 @@
|
|
|
37
38
|
"scripts": {
|
|
38
39
|
"lint": "eslint --ext \".js,.ts,.tsx\" .",
|
|
39
40
|
"lint-fix": "npm run lint -- --fix",
|
|
40
|
-
"test": "
|
|
41
|
+
"test": "npm run test:unit && npm run test:acceptance",
|
|
42
|
+
"test:unit": "tap --no-coverage --color --timeout=300 test/core/unit/*.test.js",
|
|
43
|
+
"test:acceptance": "bash test/core/run.sh"
|
|
41
44
|
},
|
|
42
45
|
"devDependencies": {
|
|
43
46
|
"@hapi/basic": "^6.0.0",
|