@artilleryio/int-core 2.0.10 → 2.0.11-076314a

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.
@@ -85,6 +85,10 @@ function HttpEngine(script) {
85
85
  this.config.http = {};
86
86
  }
87
87
 
88
+ if (typeof this.config.http.defaults === 'undefined') {
89
+ this.config.http.defaults = {};
90
+ }
91
+
88
92
  if (typeof this.config.http.cookieJarOptions === 'undefined') {
89
93
  this.config.http.cookieJarOptions = {};
90
94
  }
@@ -197,7 +201,10 @@ HttpEngine.prototype.step = function step(requestSpec, ee, opts) {
197
201
  }
198
202
 
199
203
  if (typeof requestSpec.think !== 'undefined') {
200
- return engineUtil.createThink(requestSpec, self.config.defaults.think);
204
+ return engineUtil.createThink(
205
+ requestSpec,
206
+ self.config.http.defaults.think || self.config.defaults.think
207
+ );
201
208
  }
202
209
 
203
210
  if (typeof requestSpec.log !== 'undefined') {
@@ -350,8 +357,11 @@ HttpEngine.prototype.step = function step(requestSpec, ee, opts) {
350
357
 
351
358
  // Request.js -> Got.js translation
352
359
  if (params.qs) {
353
- requestParams.searchParams = template(params.qs, context);
360
+ requestParams.searchParams = qs.stringify(
361
+ template(params.qs, context)
362
+ );
354
363
  }
364
+
355
365
  if (typeof params.gzip === 'boolean') {
356
366
  requestParams.decompress = params.gzip;
357
367
  } else {
@@ -384,7 +394,8 @@ HttpEngine.prototype.step = function step(requestSpec, ee, opts) {
384
394
 
385
395
  // Assign default headers then overwrite as needed
386
396
  let defaultHeaders = lowcaseKeys(
387
- config.defaults.headers || { 'user-agent': USER_AGENT }
397
+ config.http.defaults.headers ||
398
+ config.defaults.headers || { 'user-agent': USER_AGENT }
388
399
  );
389
400
  const combinedHeaders = _.extend(
390
401
  defaultHeaders,
@@ -808,7 +819,9 @@ function lastRequest(res, requestParams) {
808
819
  HttpEngine.prototype.setInitialContext = function (initialContext) {
809
820
  initialContext._successCount = 0;
810
821
 
811
- initialContext._defaultStrictCapture = this.config.defaults.strictCapture;
822
+ initialContext._defaultStrictCapture =
823
+ this.config.http.defaults.strictCapture ||
824
+ this.config.defaults.strictCapture;
812
825
  initialContext._jar = new tough.CookieJar(
813
826
  null,
814
827
  this.config.http.cookieJarOptions
@@ -816,8 +829,12 @@ HttpEngine.prototype.setInitialContext = function (initialContext) {
816
829
 
817
830
  initialContext._enableCookieJar = false;
818
831
  // If a default cookie is set, we will use the jar straightaway:
819
- if (typeof this.config.defaults.cookie === 'object') {
820
- initialContext._defaultCookie = this.config.defaults.cookie;
832
+ if (
833
+ typeof this.config.http.defaults.cookie === 'object' ||
834
+ typeof this.config.defaults.cookie === 'object'
835
+ ) {
836
+ initialContext._defaultCookie =
837
+ this.config.http.defaults.cookie || this.config.defaults.cookie;
821
838
  initialContext._enableCookieJar = true;
822
839
  }
823
840
 
package/lib/phases.js CHANGED
@@ -10,7 +10,7 @@ const _ = require('lodash');
10
10
  const isUndefined = _.isUndefined;
11
11
  const arrivals = require('arrivals');
12
12
  const debug = require('debug')('phases');
13
- const crypto = require('crypto');
13
+ const { randomUUID } = require('crypto');
14
14
  const driftless = require('driftless');
15
15
 
16
16
  module.exports = phaser;
@@ -89,8 +89,11 @@ function phaser(phaseSpecs) {
89
89
  function createPause(spec, ee) {
90
90
  const duration = spec.pause * 1000;
91
91
  const task = function (callback) {
92
+ spec.startTime = Date.now();
93
+ spec.id = randomUUID();
92
94
  ee.emit('phaseStarted', spec);
93
95
  setTimeout(function () {
96
+ spec.endTime = Date.now();
94
97
  ee.emit('phaseCompleted', spec);
95
98
  return callback(null);
96
99
  }, duration);
@@ -144,12 +147,14 @@ function createRamp(spec, ee) {
144
147
  debug(`periodTick ${periodTick}`);
145
148
 
146
149
  return async function rampTask(callback) {
150
+ spec.startTime = Date.now();
151
+ spec.id = randomUUID();
147
152
  ee.emit('phaseStarted', spec);
148
153
  for (let period = 0; period < periods; period++) {
149
154
  ticker(period);
150
155
  await sleep(1000);
151
156
  }
152
-
157
+ spec.endTime = Date.now();
153
158
  ee.emit('phaseCompleted', spec);
154
159
  };
155
160
 
@@ -185,6 +190,8 @@ function createRamp(spec, ee) {
185
190
 
186
191
  function createArrivalCount(spec, ee) {
187
192
  const task = function (callback) {
193
+ spec.startTime = Date.now();
194
+ spec.id = randomUUID();
188
195
  ee.emit('phaseStarted', spec);
189
196
  const duration = spec.duration * 1000;
190
197
 
@@ -195,6 +202,7 @@ function createArrivalCount(spec, ee) {
195
202
  ee.emit('arrival', spec);
196
203
  });
197
204
  p.on('finished', function () {
205
+ spec.endTime = Date.now();
198
206
  ee.emit('phaseCompleted', spec);
199
207
  return callback(null);
200
208
  });
@@ -209,6 +217,8 @@ function createArrivalCount(spec, ee) {
209
217
 
210
218
  function createArrivalRate(spec, ee) {
211
219
  const task = function (callback) {
220
+ spec.startTime = Date.now();
221
+ spec.id = randomUUID();
212
222
  ee.emit('phaseStarted', spec);
213
223
  const ar = 1000 / spec.arrivalRate;
214
224
  const duration = spec.duration * 1000;
@@ -218,6 +228,7 @@ function createArrivalRate(spec, ee) {
218
228
  ee.emit('arrival', spec);
219
229
  });
220
230
  p.on('finished', function () {
231
+ spec.endTime = Date.now();
221
232
  ee.emit('phaseCompleted', spec);
222
233
  return callback(null);
223
234
  });
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@artilleryio/int-core",
3
- "version": "2.0.10",
3
+ "version": "2.0.11-076314a",
4
4
  "main": "./index.js",
5
5
  "dependencies": {
6
- "@artilleryio/int-commons": "latest",
6
+ "@artilleryio/int-commons": "2.0.1-076314a",
7
7
  "@artilleryio/sketches-js": "^2.1.1",
8
8
  "agentkeepalive": "^4.1.0",
9
9
  "arrivals": "^2.1.2",
@@ -37,7 +37,7 @@
37
37
  "scripts": {
38
38
  "lint": "eslint --ext \".js,.ts,.tsx\" .",
39
39
  "lint-fix": "npm run lint -- --fix",
40
- "test": "tap --no-coverage --timeout=300 test/core/unit/*.test.js && bash test/core/run.sh"
40
+ "test": "tap --no-coverage --color --timeout=300 test/core/unit/*.test.js && bash test/core/run.sh"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@hapi/basic": "^6.0.0",
@@ -47,6 +47,6 @@
47
47
  "rewiremock": "^3.14.3",
48
48
  "sinon": "^4.5.0",
49
49
  "socket.io": "^4.7.1",
50
- "tap": "15.2.3"
50
+ "tap": "^16.3.7"
51
51
  }
52
- }
52
+ }