From c7bec92891180ccffd1536839ba3bcc85d9c96a4 Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Sat, 14 Feb 2015 03:27:06 -0700 Subject: [PATCH] Remove cirros.tar.gz completely Since `cirros.tar.gz` only existed to test `docker import`'s display and presence in `docker events`, we can instead just use `docker export` piped directly to `docker import` to achieve the same goal without another external dependency besides `busybox` (which we already have). While I was at it, I updated `TestImportDisplay` to also test that the imported image actually runs successfully as well (so we're testing the full import round-trip). Signed-off-by: Andrew "Tianon" Page --- Dockerfile | 3 -- integration-cli/docker_cli_events_test.go | 20 ++++++------ integration-cli/docker_cli_import_test.go | 37 +++++++++++++++-------- 3 files changed, 34 insertions(+), 26 deletions(-) diff --git a/Dockerfile b/Dockerfile index 76cc2b83a3..82cdf0d54b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -110,9 +110,6 @@ RUN gem install --no-rdoc --no-ri fpm --version 1.3.2 # Get the "busybox" image source so we can build locally instead of pulling RUN git clone -b buildroot-2014.02 https://github.com/jpetazzo/docker-busybox.git /docker-busybox -# Get the "cirros" image source so we can import it instead of fetching it during tests -RUN curl -sSL -o /cirros.tar.gz https://github.com/ewindisch/docker-cirros/raw/1cded459668e8b9dbf4ef976c94c05add9bbd8e9/cirros-0.3.0-x86_64-lxc.tar.gz - # Install registry ENV REGISTRY_COMMIT c448e0416925a9876d5576e412703c9b8b865e19 RUN set -x \ diff --git a/integration-cli/docker_cli_events_test.go b/integration-cli/docker_cli_events_test.go index c798882ad1..393affd6b9 100644 --- a/integration-cli/docker_cli_events_test.go +++ b/integration-cli/docker_cli_events_test.go @@ -206,18 +206,18 @@ func TestEventsImagePull(t *testing.T) { func TestEventsImageImport(t *testing.T) { since := time.Now().Unix() - defer deleteImages("cirros") - - server, err := fileServer(map[string]string{ - "/cirros.tar.gz": "/cirros.tar.gz", - }) + runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "true") + out, _, err := runCommandWithOutput(runCmd) if err != nil { - t.Fatal(err) + t.Fatal("failed to create a container", out, err) } - defer server.Close() - fileURL := fmt.Sprintf("%s/cirros.tar.gz", server.URL) - importCmd := exec.Command(dockerBinary, "import", fileURL, "cirros") - out, _, err := runCommandWithOutput(importCmd) + cleanedContainerID := stripTrailingCharacters(out) + defer deleteContainer(cleanedContainerID) + + out, _, err = runCommandPipelineWithOutput( + exec.Command(dockerBinary, "export", cleanedContainerID), + exec.Command(dockerBinary, "import", "-"), + ) if err != nil { t.Errorf("import failed with errors: %v, output: %q", err, out) } diff --git a/integration-cli/docker_cli_import_test.go b/integration-cli/docker_cli_import_test.go index 94aadc5831..1a7ee6f206 100644 --- a/integration-cli/docker_cli_import_test.go +++ b/integration-cli/docker_cli_import_test.go @@ -1,32 +1,43 @@ package main import ( - "fmt" "os/exec" "strings" "testing" ) func TestImportDisplay(t *testing.T) { - server, err := fileServer(map[string]string{ - "/cirros.tar.gz": "/cirros.tar.gz", - }) + runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "true") + out, _, err := runCommandWithOutput(runCmd) if err != nil { - t.Fatal(err) + t.Fatal("failed to create a container", out, err) } - defer server.Close() - fileURL := fmt.Sprintf("%s/cirros.tar.gz", server.URL) - importCmd := exec.Command(dockerBinary, "import", fileURL, "cirros") - out, _, err := runCommandWithOutput(importCmd) + cleanedContainerID := stripTrailingCharacters(out) + defer deleteContainer(cleanedContainerID) + + out, _, err = runCommandPipelineWithOutput( + exec.Command(dockerBinary, "export", cleanedContainerID), + exec.Command(dockerBinary, "import", "-"), + ) if err != nil { t.Errorf("import failed with errors: %v, output: %q", err, out) } - if n := strings.Count(out, "\n"); n != 2 { - t.Fatalf("display is messed up: %d '\\n' instead of 2", n) + if n := strings.Count(out, "\n"); n != 1 { + t.Fatalf("display is messed up: %d '\\n' instead of 1:\n%s", n, out) + } + image := strings.TrimSpace(out) + defer deleteImages(image) + + runCmd = exec.Command(dockerBinary, "run", "--rm", image, "true") + out, _, err = runCommandWithOutput(runCmd) + if err != nil { + t.Fatal("failed to create a container", out, err) } - deleteImages("cirros") + if out != "" { + t.Fatalf("command output should've been nothing, was %q", out) + } - logDone("import - cirros was imported and display is fine") + logDone("import - display is fine, imported image runs") }