From cc71c23853a33bc679d659390e392e95cfd9b680 Mon Sep 17 00:00:00 2001 From: Bernardo Guerreiro Date: Tue, 6 Feb 2024 16:14:21 +0000 Subject: [PATCH] refactor(fargate): emit phase started and completed events from workers --- .../artillery-plugin-sqs-reporter/index.js | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/packages/artillery/lib/platform/aws-ecs/legacy/plugins/artillery-plugin-sqs-reporter/index.js b/packages/artillery/lib/platform/aws-ecs/legacy/plugins/artillery-plugin-sqs-reporter/index.js index 358b1765f2..919b50add4 100644 --- a/packages/artillery/lib/platform/aws-ecs/legacy/plugins/artillery-plugin-sqs-reporter/index.js +++ b/packages/artillery/lib/platform/aws-ecs/legacy/plugins/artillery-plugin-sqs-reporter/index.js @@ -75,6 +75,54 @@ function ArtillerySQSPlugin(script, events) { }); }); + events.on('phaseStarted', (phaseContext) => { + this.unsent++; + const body = JSON.stringify({ + event: 'phaseStarted', + phase: phaseContext + }); + + const params = { + MessageBody: body, + QueueUrl: this.queueUrl, + MessageAttributes: this.messageAttributes, + MessageDeduplicationId: uuid(), + MessageGroupId: this.testId + }; + + this.sqs.sendMessage(params, (err, data) => { + if (err) { + console.error(err); + } + + this.unsent--; + }); + }); + + events.on('phaseCompleted', (phaseContext) => { + this.unsent++; + const body = JSON.stringify({ + event: 'phaseCompleted', + phase: phaseContext + }); + + const params = { + MessageBody: body, + QueueUrl: this.queueUrl, + MessageAttributes: this.messageAttributes, + MessageDeduplicationId: uuid(), + MessageGroupId: this.testId + }; + + this.sqs.sendMessage(params, (err, data) => { + if (err) { + console.error(err); + } + + this.unsent--; + }); + }); + events.on('done', (_stats) => { this.unsent++; const body = JSON.stringify({