Skip to content

Commit

Permalink
Merge pull request #2392 from artilleryio/bernardobridge-art-1542-qua…
Browse files Browse the repository at this point in the history
…lity-improve-descriptions-of-cli-flags

feat: improve fargate cli flag descriptions and usage
  • Loading branch information
bernardobridge authored Jan 3, 2024
2 parents 7f1d779 + 8280b36 commit 2531936
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 46 deletions.
58 changes: 31 additions & 27 deletions packages/artillery/lib/cmds/run-fargate.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const telemetry = require('../telemetry').init();
const { Plugin: CloudPlugin } = require('../platform/cloud/cloud');

const runCluster = require('../platform/aws-ecs/legacy/run-cluster');
const { supportedRegions } = require('../platform/aws-ecs/legacy/util');
const PlatformECS = require('../platform/aws-ecs/ecs');
const { ECS_WORKER_ROLE_NAME } = require('../platform/aws/constants');

Expand All @@ -18,8 +19,6 @@ class RunCommand extends Command {

async run() {
const { flags, _argv, args } = await this.parse(RunCommand);
flags.region = flags.region || 'us-east-1';

flags['platform-opt'] = [`region=${flags.region}`];

flags.platform = 'aws:ecs';
Expand Down Expand Up @@ -47,16 +46,6 @@ class RunCommand extends Command {
}
}

const runTestDescriptions = {
count: 'Number of load generator workers to launch',
cluster: 'Name of the Fargate/ECS cluster to run the test on',
region: 'The AWS region to run in',
packages:
'Path to package.json file which lists dependencies for the test script',
maxDuration: 'Maximum duration of the test run',
dotenv: 'Path to a .env file to load environment variables from'
};

RunCommand.description = `launch a test using AWS ECS/Fargate
Examples:
Expand All @@ -69,24 +58,41 @@ Examples:
RunCommand.flags = {
...CommonRunFlags,
count: Flags.integer({
description: runTestDescriptions.count
description: 'Number of load generator workers to launch'
}),
cluster: Flags.string({
description: runTestDescriptions.cluster
description: 'Name of the Fargate/ECS cluster to run the test on'
}),
region: Flags.string({
char: 'r',
description: runTestDescriptions.region
description: 'The AWS region to run in',
options: supportedRegions,
default: 'us-east-1'
}),
secret: Flags.string({
multiple: true
multiple: true,
description:
'Make secrets available to workers. The secret must exist in SSM parameter store for the given region, under /artilleryio/<SECRET_NAME>'
}),
'launch-type': Flags.string({
description: 'The launch type to use for the test. Defaults to Fargate.',
options: ['ecs:fargate', 'ecs:ec2']
}),
'launch-config': Flags.string({
description:
'JSON to customize launch configuration of ECS/Fargate tasks (see https://www.artillery.io/docs/reference/cli/run-fargate#using---launch-config)'
}),
'subnet-ids': Flags.string({
description:
'Comma-separated list of AWS VPC subnet IDs to launch Fargate tasks in'
}),
'security-group-ids': Flags.string({
description:
'Comma-separated list of AWS VPC security group IDs to launch Fargate tasks in'
}),
'task-role-name': Flags.string({
description: 'Custom IAM role name for Fargate containers to assume'
}),
// TODO: Descriptions
'launch-type': Flags.string({}),
'launch-config': Flags.string({}),
'subnet-ids': Flags.string({}),
'security-group-ids': Flags.string({}),
'task-role-name': Flags.string({}),
cpu: Flags.string({
description:
'Set task vCPU on Fargate. Value may be set as a number of vCPUs between 1-16 (e.g. 4), or as number of vCPU units (e.g. 4096)',
Expand All @@ -98,13 +104,11 @@ RunCommand.flags = {
default: '8'
}),
packages: Flags.string({
description: runTestDescriptions.packages
description:
'Path to package.json file which lists dependencies for the test script'
}),
'max-duration': Flags.string({
description: runTestDescriptions.maxDuration
}),
dotenv: Flags.string({
description: runTestDescriptions.dotenv
description: 'Maximum duration of the test run'
})
};

Expand Down
3 changes: 0 additions & 3 deletions packages/artillery/lib/cmds/run-lambda.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ RunLambdaCommand.flags = {
char: 'p',
description: 'Specify a CSV file for dynamic data'
}),
dotenv: Flags.string({
description: 'Path to a dotenv file to load environment variables from'
}),
count: Flags.string({
// locally defaults to number of CPUs with mode = distribute
default: '1'
Expand Down
17 changes: 1 addition & 16 deletions packages/artillery/lib/platform/aws-ecs/legacy/run-cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ async function tryRunCluster(scriptPath, options, artilleryReporter) {
scriptPath: absoluteScriptPath,
originalScriptPath: scriptPath,
count: count,
region: options.region,
taskName: `${TASK_NAME}_${
IS_FARGATE ? 'fargate' : ''
}_${clusterName}_${IMAGE_VERSION}_${Math.floor(Math.random() * 1e6)}`,
Expand All @@ -467,22 +468,6 @@ async function tryRunCluster(scriptPath, options, artilleryReporter) {
taskArns: []
});

if (
typeof options.region !== 'undefined' &&
util.supportedRegions.indexOf(options.region) === -1
) {
console.log(
`Unsupported region (${
options.region
}) provided. Please specify one of: ${util.supportedRegions.join(', ')} `
);
process.exit(1);
}

if (typeof options.region !== 'undefined') {
context.region = options.region;
}

let subnetIds = [];
if (options.publicSubnetIds) {
console.error(
Expand Down

0 comments on commit 2531936

Please sign in to comment.