Skip to content

Commit

Permalink
Merge pull request #3313 from artilleryio/fix/azure
Browse files Browse the repository at this point in the history
Azure improvements
  • Loading branch information
hassy authored Aug 19, 2024
2 parents 99a7df7 + b7e40b6 commit d76844c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 15 deletions.
2 changes: 1 addition & 1 deletion packages/artillery/lib/cmds/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class RunCommand extends Command {
async run() {
const { flags, argv, args } = await this.parse(RunCommand);

if (flags.platform === 'aws:fargate') {
if (flags.platform === 'aws:ecs') {
// Delegate to existing implementation
const RunFargateCommand = require('./run-fargate');
return await RunFargateCommand.run(argv);
Expand Down
3 changes: 1 addition & 2 deletions packages/artillery/lib/platform/aws-ecs/legacy/bom.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,7 @@ function getExtraFiles(context, next) {

function getDotEnv(context, next) {
const flags = context.opts.flags;
//TODO: For now only enabled on Lambda. Enable this for Fargate after refactoring to allow for it
if (!flags.dotenv || flags.platform !== 'aws:lambda') {
if (!flags.dotenv || flags.platform === 'aws:ecs') {
return next(null, context);
}

Expand Down
46 changes: 34 additions & 12 deletions packages/artillery/lib/platform/az/aci.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const debug = require('debug')('platform:azure-aci');
const { IMAGE_VERSION } = require('../aws-ecs/legacy/constants');
const { regionNames } = require('./regions');
const path = require('path');
const { Timeout, sleep } = require('../aws-ecs/legacy/time');

class PlatformAzureACI {
constructor(script, variablePayload, opts, platformOpts) {
Expand Down Expand Up @@ -323,22 +324,28 @@ class PlatformAzureACI {

let instancesCreated = false;
console.log('Waiting for Azure ACI to create container instances...');
this.workerStatusInterval = setInterval(async () => {
const containerInstanceClient = new ContainerInstanceManagementClient(
new DefaultAzureCredential(),
this.azureSubscriptionId
);

const containerInstanceClient = new ContainerInstanceManagementClient(
new DefaultAzureCredential(),
this.azureSubscriptionId
);

const provisioningWaitTimeout = new Timeout(5 * 60 * 1000).start();

let containerGroupsInTestRun = [];
while (true) {
const containerGroupListResult =
containerInstanceClient.containerGroups.listByResourceGroup(
this.resourceGroupName
);

const containerGroupsInTestRun = [];
containerGroupsInTestRun = [];
for await (const containerGroup of containerGroupListResult) {
if (containerGroup.name.indexOf(this.testRunId) > 0) {
containerGroupsInTestRun.push(containerGroup);
}
}

const byStatus = containerGroupsInTestRun.reduce((acc, cg) => {
if (!acc[cg.provisioningState]) {
acc[cg.provisioningState] = 0;
Expand All @@ -351,14 +358,29 @@ class PlatformAzureACI {
(byStatus['Succeeded'] || 0) + (byStatus['Running'] || 0) ===
this.count
) {
if (!instancesCreated)
console.log(
'Container instances created. Waiting for workers to start...'
);
instancesCreated = true;
clearInterval(this.workerStatusInterval);
break;
}
}, 10 * 1000).unref();

if (provisioningWaitTimeout.timedout()) {
break;
}

await sleep(10000);
}

if (instancesCreated) {
console.log(
'Container instances have been created. Waiting for workers to start...'
);
} else {
console.log('Some containers instances failed to provision');
console.log('Please see the Azure console for details');
console.log(
'https://portal.azure.com/#view/HubsExtension/BrowseResource/resourceType/Microsoft.ContainerInstance%2FcontainerGroups'
);
await global.artillery.shutdown();
}
}

async shutdown() {
Expand Down

0 comments on commit d76844c

Please sign in to comment.