From b56cbc5daadf5e8ada3e1211e8b80209570c8c87 Mon Sep 17 00:00:00 2001 From: hveldstra Date: Fri, 30 Aug 2024 09:57:26 +0100 Subject: [PATCH 1/5] refactor: remove unused code --- packages/artillery/lib/launch-platform.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/artillery/lib/launch-platform.js b/packages/artillery/lib/launch-platform.js index 5308af0cfc..9b881a4c5f 100644 --- a/packages/artillery/lib/launch-platform.js +++ b/packages/artillery/lib/launch-platform.js @@ -8,7 +8,6 @@ const { loadPlugins, loadPluginsConfig } = require('./load-plugins'); const EventEmitter = require('eventemitter3'); const debug = require('debug')('core'); -const os = require('os'); const p = require('util').promisify; const _ = require('lodash'); @@ -41,7 +40,6 @@ class Launcher { this.workerMessageBuffer = []; this.metricsByPeriod = {}; // individual intermediates by worker - this.mergedPeriodMetrics = []; // merged intermediates for a period this.finalReportsByWorker = {}; this.events = new EventEmitter(); From 70008c531d501a5b3159260c7195d74eb942ce8d Mon Sep 17 00:00:00 2001 From: hveldstra Date: Fri, 30 Aug 2024 10:02:02 +0100 Subject: [PATCH 2/5] refactor: only need to delete once --- packages/artillery/lib/launch-platform.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/artillery/lib/launch-platform.js b/packages/artillery/lib/launch-platform.js index 9b881a4c5f..12649f60c3 100644 --- a/packages/artillery/lib/launch-platform.js +++ b/packages/artillery/lib/launch-platform.js @@ -376,18 +376,18 @@ class Launcher { ); // TODO: Track how many workers provided metrics in the metrics report - const stats = SSMS.mergeBuckets(this.metricsByPeriod[String(period)])[ - String(period) - ]; - this.mergedPeriodMetrics.push(stats); - // summarize histograms for console reporter + // summarize histograms for console reporter: + const merged = SSMS.mergeBuckets(this.metricsByPeriod[String(period)]); + const stats = merged[String(period)]; + stats.summaries = {}; for (const [name, value] of Object.entries(stats.histograms || {})) { const summary = SSMS.summarizeHistogram(value); stats.summaries[name] = summary; - delete this.metricsByPeriod[String(period)]; } + delete this.metricsByPeriod[String(period)]; + this.periodsReportedFor.push(period); this.pluginEvents.emit('stats', stats); global.artillery.globalEvents.emit('stats', stats); From b7c5168d1d4dc7bbf1d02717121eff17aabc6545 Mon Sep 17 00:00:00 2001 From: hveldstra Date: Fri, 30 Aug 2024 10:05:34 +0100 Subject: [PATCH 3/5] fix: do not send an empty stats object for idle phases Sending an empty stats object by default for every idle phase can lead to duplicate stats objects being sent for the same period, which leads to (incorrect) "multiple metric batches" warnings printed to the user. Consider the following phase definition: phases: - duration: 10 arrivalRate: 1 - pause: 10 Current behavior will lead to two stats objects being sent for the period that the pause phase falls into: - The empty stats object - A stats object containing measurements from some of the VUs from the first phase --- packages/core/lib/runner.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/packages/core/lib/runner.js b/packages/core/lib/runner.js index c9d136958a..0049e6daa2 100644 --- a/packages/core/lib/runner.js +++ b/packages/core/lib/runner.js @@ -14,7 +14,6 @@ const A = require('async'); const { SSMS } = require('./ssms'); const tryResolve = require('try-require').resolve; const createPhaser = require('./phases'); -const isIdlePhase = require('./is-idle-phase'); const createReader = require('./readers'); const engineUtil = require('@artilleryio/int-commons').engine_util; const wl = require('./weighted-pick'); @@ -223,15 +222,9 @@ function run(script, ee, options, runState, contextVars) { }); phaser.on('phaseStarted', function (spec) { ee.emit('phaseStarted', spec); - if (isIdlePhase(spec)) { - ee.emit('stats', SSMS.empty()); - } }); phaser.on('phaseCompleted', function (spec) { ee.emit('phaseCompleted', spec); - if (isIdlePhase(spec)) { - ee.emit('stats', SSMS.empty()); - } }); phaser.on('done', function () { debug('All phases launched'); From 817d6ad15b33f7481752bd83176ed7c5b545dbd1 Mon Sep 17 00:00:00 2001 From: hveldstra Date: Fri, 30 Aug 2024 10:08:44 +0100 Subject: [PATCH 4/5] refactor: remove unused imports --- packages/core/lib/runner.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/core/lib/runner.js b/packages/core/lib/runner.js index 0049e6daa2..69ca82cfe7 100644 --- a/packages/core/lib/runner.js +++ b/packages/core/lib/runner.js @@ -10,9 +10,7 @@ const _ = require('lodash'); const debug = require('debug')('runner'); const debugPerf = require('debug')('perf'); const uuidv4 = require('uuid').v4; -const A = require('async'); const { SSMS } = require('./ssms'); -const tryResolve = require('try-require').resolve; const createPhaser = require('./phases'); const createReader = require('./readers'); const engineUtil = require('@artilleryio/int-commons').engine_util; From c33e6b4bedd72c12e2648d31984275e0212bd3ea Mon Sep 17 00:00:00 2001 From: hveldstra Date: Fri, 30 Aug 2024 10:10:22 +0100 Subject: [PATCH 5/5] dep: remove try-require, no longer used --- package-lock.json | 7 ------- packages/artillery/package.json | 1 - packages/core/package.json | 1 - 3 files changed, 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9385572a56..e26713db26 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21073,11 +21073,6 @@ "node": ">=8" } }, - "node_modules/try-require": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/try-require/-/try-require-1.2.1.tgz", - "integrity": "sha512-aMzrGUIA/R2LwUgvsOusx+GTy8ERyNjpBzbWgS1Qx4oTFlXCMxY3PyyXbPE1pvrvK/CXpO+BBREEqrTkNroC+A==" - }, "node_modules/ts-node": { "version": "10.9.1", "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", @@ -23203,7 +23198,6 @@ "sqs-consumer": "5.8.0", "temp": "^0.9.4", "tmp": "0.2.1", - "try-require": "^1.2.1", "walk-sync": "^0.2.3", "yaml-js": "^0.2.3" }, @@ -24366,7 +24360,6 @@ "socket.io-client": "^4.5.1", "socketio-wildcard": "^2.0.0", "tough-cookie": "^5.0.0-rc.2", - "try-require": "^1.2.1", "uuid": "^8.0.0", "ws": "^7.5.7" }, diff --git a/packages/artillery/package.json b/packages/artillery/package.json index 1d029a8556..147bfaee06 100644 --- a/packages/artillery/package.json +++ b/packages/artillery/package.json @@ -141,7 +141,6 @@ "sqs-consumer": "5.8.0", "temp": "^0.9.4", "tmp": "0.2.1", - "try-require": "^1.2.1", "walk-sync": "^0.2.3", "yaml-js": "^0.2.3" }, diff --git a/packages/core/package.json b/packages/core/package.json index 0950c18732..fbb22106f9 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -31,7 +31,6 @@ "socket.io-client": "^4.5.1", "socketio-wildcard": "^2.0.0", "tough-cookie": "^5.0.0-rc.2", - "try-require": "^1.2.1", "uuid": "^8.0.0", "ws": "^7.5.7" },