Skip to content

Commit 73d5527

Browse files
AnilAltinaygvisor-bot
authored andcommitted
Fix flakiness of testDockerComposeBuild test
This test eats the returned error at d.WaitForOutput(ctx, want, defaultWait). Instead of waiting for a certain output that can change in the future, let's check the existence of the image periodically and get rid of this call completely. After removing this call, I did not experience test failures in my testing. Increasing the defaultWait also removed flakiness but I think we should get rid of this check. PiperOrigin-RevId: 862805236
1 parent 6b63320 commit 73d5527

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

test/image/image_test.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -745,9 +745,14 @@ func testDockerComposeBuild(ctx context.Context, t *testing.T, d *dockerutil.Con
745745
t.Fatalf("docker compose build failed: %v", err)
746746
}
747747
defer removeDockerImage(ctx, imageName, d)
748-
d.WaitForOutput(ctx, fmt.Sprintf("%s Built", imageName), defaultWait)
749-
if err := checkDockerImage(ctx, imageName, d); err != nil {
750-
t.Fatalf("failed to find docker image: %v", err)
748+
// Instead of waiting for a "Built" string, poll for the image existence.
749+
// This is more resilient to UI changes in Docker Compose.
750+
err = testutil.Poll(func() error {
751+
return checkDockerImage(ctx, imageName, d)
752+
}, defaultWait)
753+
754+
if err != nil {
755+
t.Fatalf("image %s was not created after build: %v, docker logs: %v", imageName, err, dockerLogs(ctx, d))
751756
}
752757
}
753758

0 commit comments

Comments
 (0)