Skip to content

Commit

Permalink
fix: set appropriate status when test run is cancelled
Browse files Browse the repository at this point in the history
  • Loading branch information
hassy committed Jul 19, 2023
1 parent 77f6423 commit 48a4a91
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 6 additions & 2 deletions packages/artillery/lib/cmds/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,12 @@ RunCommand.runCommandImplementation = async function (flags, argv, args) {

let finalReport = {};
let shuttingDown = false;
process.once('SIGINT', gracefulShutdown);
process.once('SIGTERM', gracefulShutdown);
process.on('SIGINT', async () => {
gracefulShutdown({ earlyStop: true });
});
process.on('SIGTERM', async () => {
gracefulShutdown({ earlyStop: true });
});

async function gracefulShutdown(opts = { exitCode: 0 }) {
debug('shutting down 🦑');
Expand Down
6 changes: 4 additions & 2 deletions packages/artillery/lib/platform/cloud/cloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,11 @@ class ArtilleryCloudPlugin {
// output has been captured and sent to the dashboard.
global.artillery.ext({
ext: 'onShutdown',
method: async () => {
method: async (opts) => {
await this._event('testrun:end', { ts: testEndInfo.endTime });
await this._event('testrun:changestatus', { status: 'COMPLETED' });
await this._event('testrun:changestatus', {
status: opts.earlyStop ? 'EARLY_STOP' : 'COMPLETED'
});
}
});

Expand Down

0 comments on commit 48a4a91

Please sign in to comment.