Signed-off-by: Arnaud Porterie <arnaud.porterie@docker.com>
| ... | ... |
@@ -1,12 +1,56 @@ |
| 1 | 1 |
package main |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 |
+ "fmt" |
|
| 4 | 5 |
"os/exec" |
| 5 | 6 |
"strings" |
| 6 | 7 |
"testing" |
| 7 | 8 |
) |
| 8 | 9 |
|
| 9 |
-// FIXME: we need a test for pulling all aliases for an image (issue #8141) |
|
| 10 |
+// See issue docker/docker#8141 |
|
| 11 |
+func TestPullImageWithAliases(t *testing.T) {
|
|
| 12 |
+ defer setupRegistry(t)() |
|
| 13 |
+ |
|
| 14 |
+ repoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL)
|
|
| 15 |
+ defer deleteImages(repoName) |
|
| 16 |
+ |
|
| 17 |
+ repos := []string{}
|
|
| 18 |
+ for _, tag := range []string{"recent", "fresh"} {
|
|
| 19 |
+ repos = append(repos, fmt.Sprintf("%v:%v", repoName, tag))
|
|
| 20 |
+ } |
|
| 21 |
+ |
|
| 22 |
+ // Tag and push the same image multiple times. |
|
| 23 |
+ for _, repo := range repos {
|
|
| 24 |
+ if out, _, err := runCommandWithOutput(exec.Command(dockerBinary, "tag", "busybox", repo)); err != nil {
|
|
| 25 |
+ t.Fatalf("Failed to tag image %v: error %v, output %q", repos, err, out)
|
|
| 26 |
+ } |
|
| 27 |
+ if out, err := exec.Command(dockerBinary, "push", repo).CombinedOutput(); err != nil {
|
|
| 28 |
+ t.Fatalf("Failed to push image %v: error %v, output %q", err, string(out))
|
|
| 29 |
+ } |
|
| 30 |
+ } |
|
| 31 |
+ |
|
| 32 |
+ // Clear local images store. |
|
| 33 |
+ args := append([]string{"rmi"}, repos...)
|
|
| 34 |
+ if out, err := exec.Command(dockerBinary, args...).CombinedOutput(); err != nil {
|
|
| 35 |
+ t.Fatalf("Failed to clean images: error %v, output %q", err, string(out))
|
|
| 36 |
+ } |
|
| 37 |
+ |
|
| 38 |
+ // Pull a single tag and verify it doesn't bring down all aliases. |
|
| 39 |
+ pullCmd := exec.Command(dockerBinary, "pull", repos[0]) |
|
| 40 |
+ if out, _, err := runCommandWithOutput(pullCmd); err != nil {
|
|
| 41 |
+ t.Fatalf("Failed to pull %v: error %v, output %q", repoName, err, out)
|
|
| 42 |
+ } |
|
| 43 |
+ if err := exec.Command(dockerBinary, "inspect", repos[0]).Run(); err != nil {
|
|
| 44 |
+ t.Fatalf("Image %v was not pulled down", repos[0])
|
|
| 45 |
+ } |
|
| 46 |
+ for _, repo := range repos[1:] {
|
|
| 47 |
+ if err := exec.Command(dockerBinary, "inspect", repo).Run(); err == nil {
|
|
| 48 |
+ t.Fatalf("Image %v shouldn't have been pulled down", repo)
|
|
| 49 |
+ } |
|
| 50 |
+ } |
|
| 51 |
+ |
|
| 52 |
+ logDone("pull - image with aliases")
|
|
| 53 |
+} |
|
| 10 | 54 |
|
| 11 | 55 |
// pulling an image from the central registry should work |
| 12 | 56 |
func TestPullImageFromCentralRegistry(t *testing.T) {
|