From e1d1f67bc5879c248142d09ce68652eb2d8334e3 Mon Sep 17 00:00:00 2001 From: Aaron Lehmann Date: Wed, 17 Feb 2016 13:05:47 -0800 Subject: [PATCH] Improve resilience of TestPullFromCentralRegistryImplicitRefParts Sometimes transient network issues will cause TestPullFromCentralRegistryImplicitRefParts to end up pulling with the v1 protocol. This violates the assumptions behind the test. To make the test more robust, allow a few retries if any pull ends up using the v1 protocol. Fixes #17214 Signed-off-by: Aaron Lehmann Upstream-commit: 884201115315abb0c7815e44e6728e590476aeb8 Component: engine --- .../integration-cli/docker_cli_pull_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/components/engine/integration-cli/docker_cli_pull_test.go b/components/engine/integration-cli/docker_cli_pull_test.go index 9d36296091..ad880c8352 100644 --- a/components/engine/integration-cli/docker_cli_pull_test.go +++ b/components/engine/integration-cli/docker_cli_pull_test.go @@ -86,6 +86,23 @@ func (s *DockerHubPullSuite) TestPullFromCentralRegistryImplicitRefParts(c *chec "index.docker.io/library/hello-world", } { out := s.Cmd(c, "pull", i) + v1Retries := 0 + for strings.Contains(out, "this image was pulled from a legacy registry") { + // Some network errors may cause fallbacks to the v1 + // protocol, which would violate the test's assumption + // that it will get the same images. To make the test + // more robust against these network glitches, allow a + // few retries if we end up with a v1 pull. + + if v1Retries > 2 { + c.Fatalf("too many v1 fallback incidents when pulling %s", i) + } + + s.Cmd(c, "rmi", i) + out = s.Cmd(c, "pull", i) + + v1Retries++ + } c.Assert(out, checker.Contains, "Image is up to date for hello-world:latest") }