Skip to content

Commit

Permalink
fix(artillery): create default SSM parameters for ECS/Fargate tests (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
hassy committed Dec 6, 2023
1 parent 2894fc4 commit d51d159
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/artillery/lib/cmds/run-fargate.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,25 @@ 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';

new CloudPlugin(null, null, { flags });

const ECS = new PlatformECS(null, null, {}, { testRunId: 'foo' });
const ECS = new PlatformECS(
null,
null,
{},
{ testRunId: 'foo', region: flags.region }
);
await ECS.init();

flags.taskRoleName = ECS_WORKER_ROLE_NAME;
process.env.USE_NOOP_BACKEND_STORE = 'true';

flags.region = flags.region || 'us-east-1';

telemetry.capture('run:fargate', {
region: flags.region,
count: flags.count
Expand Down
50 changes: 50 additions & 0 deletions packages/artillery/lib/platform/aws-ecs/ecs.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const ensureS3BucketExists = require('../aws/aws-ensure-s3-bucket-exists');
const setDefaultAWSCredentials = require('../aws/aws-set-default-credentials');
const AWS = require('aws-sdk');

const { ensureParameterExists } = require('./legacy/aws-util');

const {
S3_BUCKET_NAME_PREFIX,
ECS_WORKER_ROLE_NAME
Expand All @@ -19,6 +21,8 @@ const getAccountId = require('../aws/aws-get-account-id');
class PlatformECS {
constructor(script, payload, opts, platformOpts) {
this.opts = opts;
this.platformOpts = platformOpts;

this.testRunId = platformOpts.testRunId;
if (!this.testRunId) {
throw new Error('testRunId is required');
Expand All @@ -30,6 +34,7 @@ class PlatformECS {

this.accountId = await getAccountId();

await ensureSSMParametersExist(this.platformOpts.region);
await ensureS3BucketExists();
await createIAMResources(this.accountId);
}
Expand All @@ -45,6 +50,51 @@ class PlatformECS {
async shutdown() {}
}

async function ensureSSMParametersExist(region) {
await ensureParameterExists(
'/artilleryio/NPM_TOKEN',
'null',
'SecureString',
region
);
await ensureParameterExists(
'/artilleryio/NPM_REGISTRY',
'null',
'String',
region
);
await ensureParameterExists(
'/artilleryio/NPM_SCOPE',
'null',
'String',
region
);
await ensureParameterExists(
'/artilleryio/ARTIFACTORY_AUTH',
'null',
'SecureString',
region
);
await ensureParameterExists(
'/artilleryio/ARTIFACTORY_EMAIL',
'null',
'String',
region
);
await ensureParameterExists(
'/artilleryio/NPMRC',
'null',
'SecureString',
region
);
await ensureParameterExists(
'/artilleryio/NPM_SCOPE_REGISTRY',
'null',
'String',
region
);
}

async function createIAMResources(accountId) {
const workerRoleArn = await createWorkerRole(accountId);

Expand Down

0 comments on commit d51d159

Please sign in to comment.