From 65d996024be65652496fda34262154453299941a Mon Sep 17 00:00:00 2001 From: droguljic <1875821+droguljic@users.noreply.github.com> Date: Wed, 28 Jan 2026 13:42:47 +0100 Subject: [PATCH] test: wait for tasks to become available in ECS EFS read/write test Wrap list tasks command, and corresponding assertion, in `backOff` to eliminate race condition where tasks are not yet available. --- tests/ecs-service/persistent-storage.test.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/ecs-service/persistent-storage.test.ts b/tests/ecs-service/persistent-storage.test.ts index 7088027..2812d5e 100644 --- a/tests/ecs-service/persistent-storage.test.ts +++ b/tests/ecs-service/persistent-storage.test.ts @@ -266,12 +266,16 @@ export function testEcsServiceWithStorage(ctx: EcsTestContext) { } const logsClient = new CloudWatchLogsClient({ region }); - const listCommand = new ListTasksCommand({ - cluster: clusterName, - family: ecsServiceWithStorage.taskDefinition.family, - }); - const { taskArns } = await ctx.clients.ecs.send(listCommand); - assert.ok(taskArns && taskArns.length > 0, 'Task should be running'); + const taskArns = await backOff(async () => { + const listCommand = new ListTasksCommand({ + cluster: clusterName, + family: ecsServiceWithStorage.taskDefinition.family, + }); + const { taskArns } = await ctx.clients.ecs.send(listCommand); + assert.ok(taskArns && taskArns.length > 0, 'Task should be running'); + + return taskArns; + }, ctx.config.exponentialBackOffConfig); const describeTasksCommand = new DescribeTasksCommand({ cluster: clusterName,