From 644a362ea9801ab38dbc30fb1a8e305ecf1cca40 Mon Sep 17 00:00:00 2001 From: Andrew Hsu Date: Tue, 25 Jul 2017 16:53:44 -0700 Subject: [PATCH 1/7] test TestRmiImageIDForceWithRunningContainersAndMultipleTags with `rmi` instead of `rmi -f` Because now the cli will always return 0 for `rmi -f`. Signed-off-by: Andrew Hsu --- components/engine/integration-cli/docker_cli_rmi_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/engine/integration-cli/docker_cli_rmi_test.go b/components/engine/integration-cli/docker_cli_rmi_test.go index afbc4c2fab0..5ba43ecfed7 100644 --- a/components/engine/integration-cli/docker_cli_rmi_test.go +++ b/components/engine/integration-cli/docker_cli_rmi_test.go @@ -150,8 +150,8 @@ func (s *DockerSuite) TestRmiImageIDForceWithRunningContainersAndMultipleTags(c dockerCmd(c, "tag", imgID, newTag) runSleepingContainerInImage(c, imgID) - out, _, err := dockerCmdWithError("rmi", "-f", imgID) - // rmi -f should not delete image with running containers + out, _, err := dockerCmdWithError("rmi", imgID) + // rmi should not delete image with running containers c.Assert(err, checker.NotNil) c.Assert(out, checker.Contains, "(cannot be forced) - image is being used by running container") } From 8a85c194b786398334a357de4fb14f3cb33c374e Mon Sep 17 00:00:00 2001 From: Andrew Hsu Date: Tue, 25 Jul 2017 17:08:21 -0700 Subject: [PATCH 2/7] test TestRmiContainerImageNotFound with `rmi` instead of `rmi -f` Because now the cli will always return 0 for `rmi -f`. Signed-off-by: Andrew Hsu --- components/engine/integration-cli/docker_cli_rmi_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/engine/integration-cli/docker_cli_rmi_test.go b/components/engine/integration-cli/docker_cli_rmi_test.go index 5ba43ecfed7..01d526eb802 100644 --- a/components/engine/integration-cli/docker_cli_rmi_test.go +++ b/components/engine/integration-cli/docker_cli_rmi_test.go @@ -243,7 +243,7 @@ func (s *DockerSuite) TestRmiContainerImageNotFound(c *check.C) { dockerCmd(c, "rmi", "-f", imageIds[1]) // Try to remove the image of the running container and see if it fails as expected. - out, _, err := dockerCmdWithError("rmi", "-f", imageIds[0]) + out, _, err := dockerCmdWithError("rmi", imageIds[0]) // The image of the running container should not be removed. c.Assert(err, checker.NotNil) c.Assert(out, checker.Contains, "image is being used by running container", check.Commentf("out: %s", out)) From e7fe48c681893d2360cd9a196df768e9ffb3a6c0 Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Wed, 26 Jul 2017 02:15:19 +0200 Subject: [PATCH 3/7] prevents failures on DockerSuite.TestRunWithNanoCPUs and DockerSuite.TestUpdateWithNanoCPUs Signed-off-by: Victor Vieux --- components/engine/integration-cli/docker_cli_run_unix_test.go | 2 +- .../engine/integration-cli/docker_cli_update_unix_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/engine/integration-cli/docker_cli_run_unix_test.go b/components/engine/integration-cli/docker_cli_run_unix_test.go index b3d1b07218d..66fa40c608e 100644 --- a/components/engine/integration-cli/docker_cli_run_unix_test.go +++ b/components/engine/integration-cli/docker_cli_run_unix_test.go @@ -1564,7 +1564,7 @@ func (s *DockerSuite) TestRunWithNanoCPUs(c *check.C) { c.Assert(strings.TrimSpace(out), checker.Equals, "50000\n100000") out = inspectField(c, "test", "HostConfig.NanoCpus") - c.Assert(out, checker.Equals, "5e+08", check.Commentf("setting the Nano CPUs failed")) + c.Assert(out, checker.Equals, "500000000", check.Commentf("setting the Nano CPUs failed")) out = inspectField(c, "test", "HostConfig.CpuQuota") c.Assert(out, checker.Equals, "0", check.Commentf("CPU CFS quota should be 0")) out = inspectField(c, "test", "HostConfig.CpuPeriod") diff --git a/components/engine/integration-cli/docker_cli_update_unix_test.go b/components/engine/integration-cli/docker_cli_update_unix_test.go index be2274bb39a..fa3e29f088d 100644 --- a/components/engine/integration-cli/docker_cli_update_unix_test.go +++ b/components/engine/integration-cli/docker_cli_update_unix_test.go @@ -296,7 +296,7 @@ func (s *DockerSuite) TestUpdateWithNanoCPUs(c *check.C) { c.Assert(strings.TrimSpace(out), checker.Equals, "50000\n100000") out = inspectField(c, "top", "HostConfig.NanoCpus") - c.Assert(out, checker.Equals, "5e+08", check.Commentf("setting the Nano CPUs failed")) + c.Assert(out, checker.Equals, "500000000", check.Commentf("setting the Nano CPUs failed")) out = inspectField(c, "top", "HostConfig.CpuQuota") c.Assert(out, checker.Equals, "0", check.Commentf("CPU CFS quota should be 0")) out = inspectField(c, "top", "HostConfig.CpuPeriod") From 0e4a0fbb511248fe6095864132deafa7fd99ee31 Mon Sep 17 00:00:00 2001 From: Andrew Hsu Date: Tue, 25 Jul 2017 18:10:55 -0700 Subject: [PATCH 4/7] prevents failures on DockerSuite.TestUpdateWithNanoCPUs Signed-off-by: Andrew Hsu --- .../engine/integration-cli/docker_cli_update_unix_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/engine/integration-cli/docker_cli_update_unix_test.go b/components/engine/integration-cli/docker_cli_update_unix_test.go index fa3e29f088d..b699f0d94be 100644 --- a/components/engine/integration-cli/docker_cli_update_unix_test.go +++ b/components/engine/integration-cli/docker_cli_update_unix_test.go @@ -308,7 +308,7 @@ func (s *DockerSuite) TestUpdateWithNanoCPUs(c *check.C) { out, _ = dockerCmd(c, "update", "--cpus", "0.8", "top") out = inspectField(c, "top", "HostConfig.NanoCpus") - c.Assert(out, checker.Equals, "8e+08", check.Commentf("updating the Nano CPUs failed")) + c.Assert(out, checker.Equals, "800000000", check.Commentf("updating the Nano CPUs failed")) out = inspectField(c, "top", "HostConfig.CpuQuota") c.Assert(out, checker.Equals, "0", check.Commentf("CPU CFS quota should be 0")) out = inspectField(c, "top", "HostConfig.CpuPeriod") From e2947c09e8948e3cfe06b098d18d9dee567266b8 Mon Sep 17 00:00:00 2001 From: Andrew Hsu Date: Tue, 25 Jul 2017 18:16:43 -0700 Subject: [PATCH 5/7] use the latest tag of busybox for tests To fix tests: - DockerSwarmSuite.TestSwarmNetworkPluginV2 - DockerSwarmSuite.TestServiceLogs Signed-off-by: Andrew Hsu --- .../engine/integration-cli/docker_cli_service_logs_test.go | 2 +- components/engine/integration-cli/docker_cli_swarm_unix_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/engine/integration-cli/docker_cli_service_logs_test.go b/components/engine/integration-cli/docker_cli_service_logs_test.go index d2ce36def06..43086a7c915 100644 --- a/components/engine/integration-cli/docker_cli_service_logs_test.go +++ b/components/engine/integration-cli/docker_cli_service_logs_test.go @@ -40,7 +40,7 @@ func (s *DockerSwarmSuite) TestServiceLogs(c *check.C) { // make sure task has been deployed. waitAndAssert(c, defaultReconciliationTimeout, d.CheckRunningTaskImages, checker.DeepEquals, - map[string]int{"busybox": len(services)}) + map[string]int{"busybox:latest": len(services)}) for name, message := range services { out, err := d.Cmd("service", "logs", name) diff --git a/components/engine/integration-cli/docker_cli_swarm_unix_test.go b/components/engine/integration-cli/docker_cli_swarm_unix_test.go index cffabcc2afd..91ddd5f0498 100644 --- a/components/engine/integration-cli/docker_cli_swarm_unix_test.go +++ b/components/engine/integration-cli/docker_cli_swarm_unix_test.go @@ -94,7 +94,7 @@ func (s *DockerSwarmSuite) TestSwarmNetworkPluginV2(c *check.C) { time.Sleep(20 * time.Second) - image := "busybox" + image := "busybox:latest" // create a new global service again. _, err = d1.Cmd("service", "create", "--no-resolve-image", "--name", serviceName, "--mode=global", "--network", networkName, image, "top") c.Assert(err, checker.IsNil) From 22c06ece3fa5f84f616d1364d197aea956777d4f Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Wed, 26 Jul 2017 03:25:36 +0200 Subject: [PATCH 6/7] prevent failure on TestSwarmServicePsMultipleServiceIDs Signed-off-by: Victor Vieux --- .../engine/integration-cli/docker_cli_swarm_test.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/components/engine/integration-cli/docker_cli_swarm_test.go b/components/engine/integration-cli/docker_cli_swarm_test.go index a0bb7a22834..ab3687c5f79 100644 --- a/components/engine/integration-cli/docker_cli_swarm_test.go +++ b/components/engine/integration-cli/docker_cli_swarm_test.go @@ -1730,18 +1730,13 @@ func (s *DockerSwarmSuite) TestSwarmServicePsMultipleServiceIDs(c *check.C) { // Name Prefix out, err = d.Cmd("service", "ps", "to") - c.Assert(err, checker.IsNil) - c.Assert(out, checker.Contains, name1+".1") - c.Assert(out, checker.Contains, name1+".2") - c.Assert(out, checker.Contains, name1+".3") - c.Assert(out, checker.Contains, name2+".1") - c.Assert(out, checker.Contains, name2+".2") - c.Assert(out, checker.Contains, name2+".3") + c.Assert(err, checker.NotNil) + c.Assert(out, checker.Contains, "no such service: to") // Name Prefix (no hit) out, err = d.Cmd("service", "ps", "noname") c.Assert(err, checker.NotNil) - c.Assert(out, checker.Contains, "no such services: noname") + c.Assert(out, checker.Contains, "no such service: noname") out, err = d.Cmd("service", "ps", id1) c.Assert(err, checker.IsNil) From da57bb437a3430894f1277afce4077322ab01642 Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Wed, 26 Jul 2017 14:14:02 -0700 Subject: [PATCH 7/7] try fix from https://github.com/tiborvass/docker/commit/7a53991bd6200b875e492d9c3f8e99a9a0c11056 Signed-off-by: Victor Vieux --- .../github.com/docker/docker/client/hijack.go | 14 ++++++++------ components/engine/client/hijack.go | 14 ++++++++------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/components/cli/vendor/github.com/docker/docker/client/hijack.go b/components/cli/vendor/github.com/docker/docker/client/hijack.go index 346c74ae829..8cf0119f3dd 100644 --- a/components/cli/vendor/github.com/docker/docker/client/hijack.go +++ b/components/cli/vendor/github.com/docker/docker/client/hijack.go @@ -177,12 +177,14 @@ func (cli *Client) setupHijackConn(req *http.Request, proto string) (net.Conn, e // Server hijacks the connection, error 'connection closed' expected resp, err := clientconn.Do(req) - if err != nil { - return nil, err - } - if resp.StatusCode != http.StatusSwitchingProtocols { - resp.Body.Close() - return nil, fmt.Errorf("unable to upgrade to %s, received %d", proto, resp.StatusCode) + if err != httputil.ErrPersistEOF { + if err != nil { + return nil, err + } + if resp.StatusCode != http.StatusSwitchingProtocols { + resp.Body.Close() + return nil, fmt.Errorf("unable to upgrade to %s, received %d", proto, resp.StatusCode) + } } c, br := clientconn.Hijack() diff --git a/components/engine/client/hijack.go b/components/engine/client/hijack.go index 346c74ae829..8cf0119f3dd 100644 --- a/components/engine/client/hijack.go +++ b/components/engine/client/hijack.go @@ -177,12 +177,14 @@ func (cli *Client) setupHijackConn(req *http.Request, proto string) (net.Conn, e // Server hijacks the connection, error 'connection closed' expected resp, err := clientconn.Do(req) - if err != nil { - return nil, err - } - if resp.StatusCode != http.StatusSwitchingProtocols { - resp.Body.Close() - return nil, fmt.Errorf("unable to upgrade to %s, received %d", proto, resp.StatusCode) + if err != httputil.ErrPersistEOF { + if err != nil { + return nil, err + } + if resp.StatusCode != http.StatusSwitchingProtocols { + resp.Body.Close() + return nil, fmt.Errorf("unable to upgrade to %s, received %d", proto, resp.StatusCode) + } } c, br := clientconn.Hijack()