From c4756860abb24d3f22256004efcdee49140a7fd9 Mon Sep 17 00:00:00 2001 From: Hassy Veldstra Date: Tue, 20 Aug 2024 11:08:39 +0100 Subject: [PATCH] feat: add --name option for setting test names in Artillery Cloud (#3317) --- packages/artillery/lib/cli/common-flags.js | 7 ++++++- packages/artillery/lib/cmds/run.js | 8 ++++++++ .../lib/platform/aws-ecs/legacy/run-cluster.js | 13 +++++++++++-- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/packages/artillery/lib/cli/common-flags.js b/packages/artillery/lib/cli/common-flags.js index f1dd6eb93b..d1461a0849 100644 --- a/packages/artillery/lib/cli/common-flags.js +++ b/packages/artillery/lib/cli/common-flags.js @@ -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' diff --git a/packages/artillery/lib/cmds/run.js b/packages/artillery/lib/cmds/run.js index 6b42932ab7..b585b74bc9 100644 --- a/packages/artillery/lib/cmds/run.js +++ b/packages/artillery/lib/cmds/run.js @@ -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); diff --git a/packages/artillery/lib/platform/aws-ecs/legacy/run-cluster.js b/packages/artillery/lib/platform/aws-ecs/legacy/run-cluster.js index b3e3219bad..75849a7b84 100644 --- a/packages/artillery/lib/platform/aws-ecs/legacy/run-cluster.js +++ b/packages/artillery/lib/platform/aws-ecs/legacy/run-cluster.js @@ -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; @@ -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],