Skip to content

Commit

Permalink
fix(registry): wait for (#2793)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
stevenh authored Sep 22, 2024
1 parent c0ac18f commit 1d01e21
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
5 changes: 1 addition & 4 deletions docker_auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ func prepareLocalRegistryWithAuth(t *testing.T) string {
ContainerFilePath: "/data",
},
},
WaitingFor: wait.ForExposedPort(),
WaitingFor: wait.ForHTTP("/").WithPort("5000/tcp"),
}
// }

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

_, cancel := context.WithCancel(context.Background())
t.Cleanup(cancel)

return addr
}

Expand Down
7 changes: 3 additions & 4 deletions modules/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,9 @@ func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustom
// convenient for testing
"REGISTRY_STORAGE_DELETE_ENABLED": "true",
},
WaitingFor: wait.ForAll(
wait.ForExposedPort(),
wait.ForLog("listening on [::]:5000").WithStartupTimeout(10*time.Second),
),
WaitingFor: wait.ForHTTP("/").
WithPort(registryPort).
WithStartupTimeout(10 * time.Second),
}

genericContainerReq := testcontainers.GenericContainerRequest{
Expand Down

0 comments on commit 1d01e21

Please sign in to comment.