Merge pull request #751 from docker/fix-string-len-e2e

Fix e2e-aci tests on comparing with empty string
This commit is contained in:
Guillaume Tardif 2020-10-09 14:36:05 +02:00 committed by GitHub
commit 4380adeed5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View File

@ -384,7 +384,7 @@ func TestContainerRunAttached(t *testing.T) {
checkRunning := func(t poll.LogT) poll.Result {
res := c.RunDockerOrExitError("inspect", container)
if res.ExitCode == 0 && strings.Contains(res.Stdout(), `"Status": "Running"`) {
if res.ExitCode == 0 && strings.Contains(res.Stdout(), `"Status": "Running"`) && !strings.Contains(res.Stdout(), `"HostIP": ""`) {
return poll.Success()
}
return poll.Continue("waiting for container to be running, current inspect result: \n%s", res.Combined())
@ -404,7 +404,7 @@ func TestContainerRunAttached(t *testing.T) {
assert.Assert(t, is.Len(containerInspect.Ports, 1))
port := containerInspect.Ports[0]
assert.Assert(t, len(port.HostIP) > 0)
assert.Assert(t, port.HostIP != "", "empty hostIP, inspect: \n"+inspectRes.Stdout())
assert.Equal(t, port.ContainerPort, uint32(80))
assert.Equal(t, port.HostPort, uint32(80))
assert.Equal(t, containerInspect.Config.FQDN, fqdn)

View File

@ -207,7 +207,7 @@ func ParseContainerInspect(stdout string) (*containers.Container, error) {
return &res, nil
}
// HTTPGetWithRetry performs an HTTP GET on an `endpoint`.
// HTTPGetWithRetry performs an HTTP GET on an `endpoint`, using retryDelay also as a request timeout.
// In the case of an error or the response status is not the expeted one, it retries the same request,
// returning the response body as a string (empty if we could not reach it)
func HTTPGetWithRetry(t *testing.T, endpoint string, expectedStatus int, retryDelay time.Duration, timeout time.Duration) string {
@ -215,8 +215,11 @@ func HTTPGetWithRetry(t *testing.T, endpoint string, expectedStatus int, retryDe
r *http.Response
err error
)
client := &http.Client{
Timeout: retryDelay * time.Second,
}
checkUp := func(t poll.LogT) poll.Result {
r, err = http.Get(endpoint)
r, err = client.Get(endpoint)
if err != nil {
return poll.Continue("reaching %q: Error %s", endpoint, err.Error())
}