Skip to content

Commit

Permalink
fix: handle case when config.target is set to a remote env var
Browse files Browse the repository at this point in the history
  • Loading branch information
hassy committed Dec 10, 2024
1 parent 45b9b52 commit c14b659
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/artillery/lib/util/prepare-test-execution-plan.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ async function prepareTestExecutionPlan(inputFiles, flags, _args) {
script1 = _.merge(script1, parsedData);
}

// We run the check here because subsequent steps can overwrite the target to undefined in
// cases where the value of config.target is set to a value from the environment which
// is not available at this point in time. Example: target is set to an environment variable
// the value of which is only available at runtime in AWS Fargate
const hasTarget =
script1.config.target ||
script1.config.environments[flags.environment].target;

script1 = await checkConfig(script1, scriptPath, flags);

const script2 = await resolveConfigPath(script1, flags, scriptPath);
Expand All @@ -42,7 +50,7 @@ async function prepareTestExecutionPlan(inputFiles, flags, _args) {
script4._scriptPath
);

if (!script5.config.target) {
if (!hasTarget) {
throw new Error('No target specified and no environment chosen');
}

Expand Down

0 comments on commit c14b659

Please sign in to comment.