in apps/firelens-stability/lib/cloud/ecs.ts [61:115]
async function startECSTask(task: IEcsTestTask) {
const testCase = task.testCase;
// Set the region name
AWS.config.update({ region: testCase.config.region });
// Create an ECS client
const ecs = new AWS.ECS();
// Create fargate cluster if it doesn't already exist
const clusters = await ecs.listClusters().promise();
if (!clusters.clusterArns.some(c => c.endsWith(`/${testCase.config.cluster}`))) {
await ecs.createCluster({
settings: [{
name: "containerInsights",
value: "enabled"
}],
clusterName: testCase.config.cluster
}).promise();
console.log(`๐ Created cluster: ${testCase.config.cluster}\n`)
await sleep(2000); /* Wait for the container to be ready to accept new tasks */
}
// Get the task definition file
const taskDefinition = await getTestCaseTaskDefinition(testCase);
// Register task definition
let taskDefinitionArn;
try {
taskDefinitionArn = (await ecs.registerTaskDefinition(taskDefinition).promise()).taskDefinition!.taskDefinitionArn;
}
catch (err) {
console.error(`Error registering task definition: ${err}`);
return;
}
// Launch tasks in groups of 10 or less
console.log(` ๐งช ${testCase.managed.collectionName}/${testCase.managed.suiteName}/${testCase.managed.caseName}: launched tasks`);
const taskCount = testCase.config.taskCount;
let launchedTasks = await launchECSTasks(testCase, taskCount, ecs, taskDefinitionArn);
// Add to the back of the task queue after a delay of 5-10 seconds for validation. Check on the status.
addECSTaskToQueue(
Constants.ecsConfig.retryDelaySecondsBase,
Constants.ecsConfig.retryDelaySecondsCap, {
successPromiseResolver: task.successPromiseResolver,
executionRecord: {
startTime: Date.now(),
taskArns: launchedTasks,
},
testCase: testCase,
executionRound: task.executionRound + 1,
taskDefinitionArn: taskDefinitionArn,
});
}