Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add last target url to console reports #555

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions core/lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ function validate(script) {
function runner(script, payload, options, callback) {
let opts = _.assign({
periodicStats: script.config.statsInterval || 10,
mode: script.config.mode || 'uniform'
mode: script.config.mode || 'uniform',
lastTarget: script.config.target
},
options);

Expand Down Expand Up @@ -247,6 +248,8 @@ function run(script, ee, options, runState) {
let intermediate = Stats.create();
let aggregate = [];

intermediate.lastTarget = options.lastTarget;

let phaser = createPhaser(script.config.phases);
phaser.on('arrival', function() {
runScenario(script, intermediate, runState);
Expand All @@ -273,8 +276,9 @@ function run(script, ee, options, runState) {

intermediate.free();

let aggregateReport = Stats.combine(aggregate).report();
return ee.emit('done', aggregateReport);

let aggregateReport = Stats.combine(aggregate).report()
return ee.emit('done', aggregateReport, intermediate.lastTarget);
} else {
debug('Pending requests: %s', runState.pendingRequests);
debug('Pending scenarios: %s', runState.pendingScenarios);
Expand Down
10 changes: 7 additions & 3 deletions lib/console-reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ ConsoleReporter.prototype.stats = function stats(data) {
const report = data.report();
this.toggleSpinner();
console.log('Report @ %s', formatTimestamp(report.timestamp));
this.printReport(report);
this.printReport(report, {lastTarget: data.lastTarget});
this.toggleSpinner();
};

Expand Down Expand Up @@ -100,7 +100,7 @@ ConsoleReporter.prototype.highcpu = function(busyPids) {
}
};

ConsoleReporter.prototype.done = function done(data) {
ConsoleReporter.prototype.done = function done(data, lastTarget) {
if (this.quiet) {
return this;
}
Expand All @@ -110,7 +110,8 @@ ConsoleReporter.prototype.done = function done(data) {
console.log('Summary report @ %s', formatTimestamp(report.timestamp));
delete report.concurrency;
this.printReport(report, {
showScenarioCounts: true
showScenarioCounts: true,
lastTarget: lastTarget
});
};

Expand All @@ -127,6 +128,9 @@ ConsoleReporter.prototype.toggleSpinner = function toggleSpinner() {
ConsoleReporter.prototype.printReport = function printReport(report, opts) {
opts = opts || {};

if (opts.lastTarget) {
console.log(' Last Target: %s', opts.lastTarget);
}
console.log(' Scenarios launched: %s', report.scenariosCreated);
console.log(' Scenarios completed: %s', report.scenariosCompleted);
console.log(' Requests completed: %s', report.requestsCompleted);
Expand Down
4 changes: 2 additions & 2 deletions lib/runner-sp.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ Runner.prototype.run = function() {
self.events.emit('stats', stats);
});

runner.on('done', (report) => {
self.events.emit('done', Stats.combine(self._allIntermediates));
runner.on('done', (report, lastTarget) => {
self.events.emit('done', Stats.combine(self._allIntermediates), lastTarget);
});

runner.run();
Expand Down