Skip to content

Commit

Permalink
fix: nginx request failures (testcontainers#2723)
Browse files Browse the repository at this point in the history
Fix tests which make http requests to nginx container by switching to
http startup check, which avoids issues on nginx being able to respond to
requests.
  • Loading branch information
stevenh authored Aug 13, 2024
1 parent cf3db62 commit 4d0e738
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func TestContainerWithHostNetworkOptions(t *testing.T) {
nginxHighPort,
},
Privileged: true,
WaitingFor: wait.ForListeningPort(nginxHighPort),
WaitingFor: wait.ForHTTP("/").WithPort(nginxHighPort),
HostConfigModifier: func(hc *container.HostConfig) {
hc.NetworkMode = "host"
},
Expand Down Expand Up @@ -182,7 +182,7 @@ func TestContainerWithHostNetwork(t *testing.T) {
ProviderType: providerType,
ContainerRequest: ContainerRequest{
Image: nginxAlpineImage,
WaitingFor: wait.ForListeningPort(nginxHighPort),
WaitingFor: wait.ForHTTP("/").WithPort(nginxHighPort),
Files: []ContainerFile{
{
HostFilePath: absPath,
Expand Down Expand Up @@ -414,6 +414,7 @@ func TestTwoContainersExposingTheSamePort(t *testing.T) {
ExposedPorts: []string{
nginxDefaultPort,
},
WaitingFor: wait.ForHTTP("/").WithPort(nginxDefaultPort),
},
Started: true,
})
Expand All @@ -428,7 +429,7 @@ func TestTwoContainersExposingTheSamePort(t *testing.T) {
ExposedPorts: []string{
nginxDefaultPort,
},
WaitingFor: wait.ForListeningPort(nginxDefaultPort),
WaitingFor: wait.ForHTTP("/").WithPort(nginxDefaultPort),
},
Started: true,
})
Expand Down Expand Up @@ -475,7 +476,7 @@ func TestContainerCreation(t *testing.T) {
ExposedPorts: []string{
nginxDefaultPort,
},
WaitingFor: wait.ForListeningPort(nginxDefaultPort),
WaitingFor: wait.ForHTTP("/").WithPort(nginxDefaultPort),
},
Started: true,
})
Expand Down Expand Up @@ -529,7 +530,7 @@ func TestContainerCreationWithName(t *testing.T) {
ExposedPorts: []string{
nginxDefaultPort,
},
WaitingFor: wait.ForListeningPort(nginxDefaultPort),
WaitingFor: wait.ForHTTP("/").WithPort(nginxDefaultPort),
Name: creationName,
Networks: []string{"bridge"},
},
Expand Down Expand Up @@ -592,7 +593,7 @@ func TestContainerCreationAndWaitForListeningPortLongEnough(t *testing.T) {
ExposedPorts: []string{
nginxDefaultPort,
},
WaitingFor: wait.ForListeningPort(nginxDefaultPort), // default startupTimeout is 60s
WaitingFor: wait.ForHTTP("/").WithPort(nginxDefaultPort), // default startupTimeout is 60s
},
Started: true,
})
Expand Down

0 comments on commit 4d0e738

Please sign in to comment.