in apps/firelens-stability/lib/cloud/ecs.ts [133:180]
async function validateAndRetryECSTask(ecsTestTask: IEcsTestTask) {
const testCase = ecsTestTask.testCase;
// Set the region name
AWS.config.update({ region: ecsTestTask.testCase.config.region });
// Create an ECS client
const ecs = new AWS.ECS();
const {
currentTasks,
startingTasks,
runningTasks,
startingTasksCount,
runningTasksCount,
endedTasksCount,
} = await validateECSTestTask(ecs, ecsTestTask);
/* Done! All tasks are in running */
if (runningTasksCount === ecsTestTask.testCase.config.taskCount) {
console.log(` ✅ ${testCase.managed.collectionName}/${testCase.managed.suiteName}/${testCase.managed.caseName}: All ${ecsTestTask.testCase.config.taskCount} tasks in running state`);
/* Mark the ECS task as resolved. */
ecsTaskReturn(ecsTestTask);
return;
}
/* Tasks need to be retried. Retry the ended tasks */
let taskArns = ecsTestTask.executionRecord.taskArns;
if (endedTasksCount !== 0) {
console.log(` 🔁 ${testCase.managed.collectionName}/${testCase.managed.suiteName}/${testCase.managed.caseName}: Retrying failed tasks`);
const taskCount = endedTasksCount;
let newTasksLaunched = await launchECSTasks(testCase, taskCount, ecs, ecsTestTask.taskDefinitionArn);
taskArns = [...startingTasks, ...runningTasks, ...newTasksLaunched];
}
/* Add back to queue for validation */
addECSTaskToQueue(
Constants.ecsConfig.retryDelaySecondsBase,
Constants.ecsConfig.retryDelaySecondsCap, {
...ecsTestTask,
executionRecord: {
...ecsTestTask.executionRecord,
taskArns: taskArns, /* Replace the task arns with updated list */
},
executionRound: ecsTestTask.executionRound + 1,
});
}