Skip to content

Commit 1d01e21

Browse files
authored
fix(registry): wait for (#2793)
Switch registry containers to wait for http response to ensure the container is ready to serve requests, which was causing random test failures. Also remove unnecessary context creation.
1 parent c0ac18f commit 1d01e21

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

docker_auth_test.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ func prepareLocalRegistryWithAuth(t *testing.T) string {
286286
ContainerFilePath: "/data",
287287
},
288288
},
289-
WaitingFor: wait.ForExposedPort(),
289+
WaitingFor: wait.ForHTTP("/").WithPort("5000/tcp"),
290290
}
291291
// }
292292

@@ -311,9 +311,6 @@ func prepareLocalRegistryWithAuth(t *testing.T) string {
311311
removeImageFromLocalCache(t, addr+"/redis:5.0-alpine")
312312
})
313313

314-
_, cancel := context.WithCancel(context.Background())
315-
t.Cleanup(cancel)
316-
317314
return addr
318315
}
319316

modules/registry/registry.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,9 @@ func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustom
220220
// convenient for testing
221221
"REGISTRY_STORAGE_DELETE_ENABLED": "true",
222222
},
223-
WaitingFor: wait.ForAll(
224-
wait.ForExposedPort(),
225-
wait.ForLog("listening on [::]:5000").WithStartupTimeout(10*time.Second),
226-
),
223+
WaitingFor: wait.ForHTTP("/").
224+
WithPort(registryPort).
225+
WithStartupTimeout(10 * time.Second),
227226
}
228227

229228
genericContainerReq := testcontainers.GenericContainerRequest{

0 commit comments

Comments
 (0)