Skip to content

Commit

Permalink
Another attempt to deflake TestPullFromCentralRegistryImplicitRefParts
Browse files Browse the repository at this point in the history
Retries after v1 fallbacks were added in moby#20411. The test still appears
to be flaky. There are two potential problems. The initial pull was not
protected against pulling from v1, so it could be giving us a different
hello-world image to compare against. Also, after experiencing a v1
fallback, we need to restore the original image before doing the next
pull, because otherwise the "Image is up to date for hello-world:latest"
message will not show up as expected.

See moby#17214.

Signed-off-by: Aaron Lehmann <[email protected]>
  • Loading branch information
aaronlehmann committed Mar 2, 2016
1 parent 793d3b5 commit 0d270ca
Showing 1 changed file with 40 additions and 14 deletions.
54 changes: 40 additions & 14 deletions integration-cli/docker_cli_pull_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,10 @@ func (s *DockerHubPullSuite) TestPullNonExistingImage(c *check.C) {
// multiple images.
func (s *DockerHubPullSuite) TestPullFromCentralRegistryImplicitRefParts(c *check.C) {
testRequires(c, DaemonIsLinux)
s.Cmd(c, "pull", "hello-world")
defer deleteImages("hello-world")

for _, i := range []string{
"hello-world",
"hello-world:latest",
"library/hello-world",
"library/hello-world:latest",
"docker.io/library/hello-world",
"index.docker.io/library/hello-world",
} {
out := s.Cmd(c, "pull", i)
// Pull hello-world from v2
pullFromV2 := func(ref string) (int, string) {
out := s.Cmd(c, "pull", "hello-world")
v1Retries := 0
for strings.Contains(out, "this image was pulled from a legacy registry") {
// Some network errors may cause fallbacks to the v1
Expand All @@ -95,17 +87,51 @@ func (s *DockerHubPullSuite) TestPullFromCentralRegistryImplicitRefParts(c *chec
// few retries if we end up with a v1 pull.

if v1Retries > 2 {
c.Fatalf("too many v1 fallback incidents when pulling %s", i)
c.Fatalf("too many v1 fallback incidents when pulling %s", ref)
}

s.Cmd(c, "rmi", i)
out = s.Cmd(c, "pull", i)
s.Cmd(c, "rmi", ref)
out = s.Cmd(c, "pull", ref)

v1Retries++
}

return v1Retries, out
}

pullFromV2("hello-world")
defer deleteImages("hello-world")

s.Cmd(c, "tag", "hello-world", "hello-world-backup")

for _, ref := range []string{
"hello-world",
"hello-world:latest",
"library/hello-world",
"library/hello-world:latest",
"docker.io/library/hello-world",
"index.docker.io/library/hello-world",
} {
var out string
for {
var v1Retries int
v1Retries, out = pullFromV2(ref)

// Keep repeating the test case until we don't hit a v1
// fallback case. We won't get the right "Image is up
// to date" message if the local image was replaced
// with one pulled from v1.
if v1Retries == 0 {
break
}
s.Cmd(c, "rmi", ref)
s.Cmd(c, "tag", "hello-world-backup", "hello-world")
}
c.Assert(out, checker.Contains, "Image is up to date for hello-world:latest")
}

s.Cmd(c, "rmi", "hello-world-backup")

// We should have a single entry in images.
img := strings.TrimSpace(s.Cmd(c, "images"))
splitImg := strings.Split(img, "\n")
Expand Down

0 comments on commit 0d270ca

Please sign in to comment.