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 sqs queue url to platform opts #2069

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/artillery/lib/cmds/run-lambda.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ class RunLambdaCommand extends Command {
flags['platform-opt'].push(`subnet-ids=${flags['subnet-ids']}`);
}

if (flags['sqs-queue-url']) {
flags['platform-opt'].push(`sqs-queue-url=${flags['sqs-queue-url']}`);
}

flags.platform = 'aws:lambda';

RunCommand.runCommandImplementation(flags, argv, args);
Expand Down
20 changes: 13 additions & 7 deletions packages/artillery/lib/platform/aws-lambda/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ class PlatformLambda {
this.lambdaRoleArn =
platformConfig['lambda-role-arn'] || platformConfig['lambdaRoleArn'];

this.platformSqsQueueUrl = platformConfig['sqs-queue-url'];

this.platformOpts = platformOpts;

this.artilleryArgs = [];
Expand Down Expand Up @@ -297,7 +299,8 @@ class PlatformLambda {
const s3path = await this.uploadLambdaZip(bucketName, zipfile);
debug({ s3path });
this.lambdaZipPath = s3path;
const sqsQueueUrl = await this.createSQSQueue(this.region);
const sqsQueueUrl = platformSqsQueueUrl ? platformSqsQueueUrl :
await this.createSQSQueue(this.region);
this.sqsQueueUrl = sqsQueueUrl;

if (typeof this.lambdaRoleArn === 'undefined') {
Expand Down Expand Up @@ -327,7 +330,7 @@ class PlatformLambda {
poolSize: Math.min(self.platformOpts.count, 100)
},
{
queueUrl: process.env.SQS_QUEUE_URL || this.sqsQueueUrl,
queueUrl: this.sqsQueueUrl,
region: this.region,
waitTimeSeconds: 10,
messageAttributeNames: ['testId', 'workerId'],
Expand Down Expand Up @@ -577,11 +580,14 @@ class PlatformLambda {
})
.promise();

await sqs
.deleteQueue({
QueueUrl: this.sqsQueueUrl
})
.promise();

if (typeof process.env.RETAIN_SQS_QUEUE === 'undefined' || process.env.RETAIN_SQS_QUEUE == false) {
await sqs
.deleteQueue({
QueueUrl: this.sqsQueueUrl
})
.promise();
}

if (typeof process.env.RETAIN_LAMBDA === 'undefined') {
await lambda
Expand Down
2 changes: 2 additions & 0 deletions packages/artillery/test/cloud-e2e/run-lambda.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ tap.test('Run a test on AWS Lambda', async (t) => {
'memory-size=3000',
'--platform-opt',
'region=eu-west-1',
'--platform-opt',
'sqs-queue-url="https://sqs.us-east-1.amazonaws.com/177715257436/MyQueue"',
'--config',
configPath,
scenarioPath
Expand Down