Skip to content

Commit

Permalink
feat: add --name option for setting test names in Artillery Cloud (#3317
Browse files Browse the repository at this point in the history
)
  • Loading branch information
hassy authored Aug 20, 2024
1 parent 926e8d8 commit c475686
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
7 changes: 6 additions & 1 deletion packages/artillery/lib/cli/common-flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,12 @@ const CommonRunFlags = {
hidden: true
}),

//Artillery Cloud commands
//Artillery Cloud options:

name: Flags.string({
description:
'Name of the test run. This name will be shown in the Artillery Cloud dashboard. Equivalent to setting a "name" tag.'
}),
tags: Flags.string({
description:
'Comma-separated list of tags in key:value format to tag the test run with in Artillery Cloud, for example: --tags team:sqa,service:foo'
Expand Down
8 changes: 8 additions & 0 deletions packages/artillery/lib/cmds/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,14 @@ RunCommand.runCommandImplementation = async function (flags, argv, args) {
value: path.basename(runnerOpts.scriptPath)
});
}
// Override the "name" tag with the value of --name if set
if (flags.name) {
for (const t of tagResult.tags) {
if (t.name === 'name') {
t.value = flags.name;
}
}
}

if (flags.config) {
runnerOpts.absoluteConfigPath = path.resolve(process.cwd(), flags.config);
Expand Down
13 changes: 11 additions & 2 deletions packages/artillery/lib/platform/aws-ecs/legacy/run-cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,14 @@ async function tryRunCluster(scriptPath, options, artilleryReporter) {
}
}

if (options.name) {
for (const t of context.tags) {
if (t.name === 'name') {
t.value = options.name;
}
}
}

context.extraSecrets = options.secret || [];

context.testId = global.artillery.testRunId;
Expand Down Expand Up @@ -1204,9 +1212,10 @@ async function ensureTaskExists(context) {
};

if (context.cliOptions.containerDnsServers) {
artilleryContainerDefinition.dnsServers = context.cliOptions.containerDnsServers.split(',');
artilleryContainerDefinition.dnsServers =
context.cliOptions.containerDnsServers.split(',');
}

let taskDefinition = {
family: context.taskName,
containerDefinitions: [artilleryContainerDefinition],
Expand Down

0 comments on commit c475686

Please sign in to comment.