Skip to content

Commit

Permalink
refactor(cloud): add final log to cli when test run cancelled (#2324)
Browse files Browse the repository at this point in the history
* refactor(cloud): show test run stop log at the end of the run

* chore: update package-lock

* refactor(cloud): break final log message into multiple lines

* refactor: cleanup code for logging
  • Loading branch information
bernardobridge authored Dec 1, 2023
1 parent a2602d2 commit ffdd0a1
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/artillery/lib/platform/cloud/cloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ArtilleryCloudPlugin {
'x-auth-token': this.apiKey
};
this.unprocessedLogsCounter = 0;
this.hasCancellationRequest = false;
this.cancellationRequestedBy = '';

let testEndInfo = {};
global.artillery.globalEvents.on('test:init', async (testInfo) => {
Expand Down Expand Up @@ -160,7 +160,11 @@ class ArtilleryCloudPlugin {
status: opts.earlyStop ? 'EARLY_STOP' : 'COMPLETED'
});

console.log(`\nRun URL: ${testEndInfo.testRunUrl}`);
console.log('\n');
if (this.cancellationRequestedBy) {
console.log(`Test run stopped by ${this.cancellationRequestedBy}.`);
}
console.log(`Run URL: ${testEndInfo.testRunUrl}`);
}
});

Expand All @@ -179,7 +183,7 @@ class ArtilleryCloudPlugin {

setGetStatusInterval() {
const interval = setInterval(async () => {
if (this.hasCancellationRequest) {
if (this.cancellationRequestedBy) {
return;
}
const res = await this._getLoadTestStatus();
Expand All @@ -196,7 +200,7 @@ class ArtilleryCloudPlugin {
console.log(
`WARNING: Artillery Cloud user ${res.cancelledBy} requested to stop the test. Stopping test run - this may take a few seconds.`
);
this.hasCancellationRequest = true;
this.cancellationRequestedBy = res.cancelledBy;
global.artillery.suggestedExitCode = 8;
await global.artillery.shutdown({ earlyStop: true });
}, 5000);
Expand Down

0 comments on commit ffdd0a1

Please sign in to comment.