mirror of https://github.com/docker/docs.git
Merge pull request #20841 from aaronlehmann/strengthen-TestPullFromCentralRegistryImplicitRefParts-2
Another attempt to deflake TestPullFromCentralRegistryImplicitRefParts
This commit is contained in:
commit
4eb7a4916f
|
@ -74,18 +74,10 @@ func (s *DockerHubPullSuite) TestPullNonExistingImage(c *check.C) {
|
||||||
// multiple images.
|
// multiple images.
|
||||||
func (s *DockerHubPullSuite) TestPullFromCentralRegistryImplicitRefParts(c *check.C) {
|
func (s *DockerHubPullSuite) TestPullFromCentralRegistryImplicitRefParts(c *check.C) {
|
||||||
testRequires(c, DaemonIsLinux)
|
testRequires(c, DaemonIsLinux)
|
||||||
s.Cmd(c, "pull", "hello-world")
|
|
||||||
defer deleteImages("hello-world")
|
|
||||||
|
|
||||||
for _, i := range []string{
|
// Pull hello-world from v2
|
||||||
"hello-world",
|
pullFromV2 := func(ref string) (int, string) {
|
||||||
"hello-world:latest",
|
out := s.Cmd(c, "pull", "hello-world")
|
||||||
"library/hello-world",
|
|
||||||
"library/hello-world:latest",
|
|
||||||
"docker.io/library/hello-world",
|
|
||||||
"index.docker.io/library/hello-world",
|
|
||||||
} {
|
|
||||||
out := s.Cmd(c, "pull", i)
|
|
||||||
v1Retries := 0
|
v1Retries := 0
|
||||||
for strings.Contains(out, "this image was pulled from a legacy registry") {
|
for strings.Contains(out, "this image was pulled from a legacy registry") {
|
||||||
// Some network errors may cause fallbacks to the v1
|
// Some network errors may cause fallbacks to the v1
|
||||||
|
@ -95,17 +87,51 @@ func (s *DockerHubPullSuite) TestPullFromCentralRegistryImplicitRefParts(c *chec
|
||||||
// few retries if we end up with a v1 pull.
|
// few retries if we end up with a v1 pull.
|
||||||
|
|
||||||
if v1Retries > 2 {
|
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)
|
s.Cmd(c, "rmi", ref)
|
||||||
out = s.Cmd(c, "pull", i)
|
out = s.Cmd(c, "pull", ref)
|
||||||
|
|
||||||
v1Retries++
|
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")
|
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.
|
// We should have a single entry in images.
|
||||||
img := strings.TrimSpace(s.Cmd(c, "images"))
|
img := strings.TrimSpace(s.Cmd(c, "images"))
|
||||||
splitImg := strings.Split(img, "\n")
|
splitImg := strings.Split(img, "\n")
|
||||||
|
|
Loading…
Reference in New Issue