From e88487b321fba4d1a6d9dcd080ec5b9ae024865e Mon Sep 17 00:00:00 2001 From: LK4D4 Date: Thu, 17 Jul 2014 21:36:45 +0400 Subject: [PATCH] Move TestCopyVolumeContent to integration-cli Docker-DCO-1.1-Signed-off-by: Alexandr Morozov (github: LK4D4) --- integration-cli/docker_cli_run_test.go | 24 ++++++++++++++++++ integration/container_test.go | 34 -------------------------- 2 files changed, 24 insertions(+), 34 deletions(-) diff --git a/integration-cli/docker_cli_run_test.go b/integration-cli/docker_cli_run_test.go index 6be4d92d7b..293c835f5e 100644 --- a/integration-cli/docker_cli_run_test.go +++ b/integration-cli/docker_cli_run_test.go @@ -1390,3 +1390,27 @@ func TestCopyVolumeUidGid(t *testing.T) { logDone("run - copy uid/gid for volume") } + +// Test for #1582 +func TestCopyVolumeContent(t *testing.T) { + name := "testruncopyvolumecontent" + defer deleteImages(name) + defer deleteAllContainers() + _, err := buildImage(name, + `FROM busybox + RUN mkdir -p /hello/local && echo hello > /hello/local/world`, + true) + if err != nil { + t.Fatal(err) + } + + // Test that the content is copied from the image to the volume + cmd := exec.Command(dockerBinary, "run", "--rm", "-v", "/hello", name, "sh", "-c", "find", "/hello") + out, _, err := runCommandWithOutput(cmd) + if err != nil { + t.Fatal(err, out) + } + if !(strings.Contains(out, "/hello/local/world") && strings.Contains(out, "/hello/local")) { + t.Fatal("Container failed to transfer content to volume") + } +} diff --git a/integration/container_test.go b/integration/container_test.go index ebef2bd4cf..cd2b9ba070 100644 --- a/integration/container_test.go +++ b/integration/container_test.go @@ -370,40 +370,6 @@ func tempDir(t *testing.T) string { return tmpDir } -// Test for #1582 -func TestCopyVolumeContent(t *testing.T) { - eng := NewTestEngine(t) - r := mkDaemonFromEngine(eng, t) - defer r.Nuke() - - // Put some content in a directory of a container and commit it - container1, _, _ := mkContainer(r, []string{"_", "/bin/sh", "-c", "mkdir -p /hello/local && echo hello > /hello/local/world"}, t) - defer r.Destroy(container1) - - if container1.State.IsRunning() { - t.Errorf("Container shouldn't be running") - } - if err := container1.Run(); err != nil { - t.Fatal(err) - } - if container1.State.IsRunning() { - t.Errorf("Container shouldn't be running") - } - - img, err := r.Commit(container1, "", "", "unit test commited image", "", true, nil) - if err != nil { - t.Error(err) - } - - // Test that the content is copied from the image to the volume - tmpDir1 := tempDir(t) - defer os.RemoveAll(tmpDir1) - stdout1, _ := runContainer(eng, r, []string{"-v", "/hello", img.ID, "find", "/hello"}, t) - if !(strings.Contains(stdout1, "/hello/local/world") && strings.Contains(stdout1, "/hello/local")) { - t.Fatal("Container failed to transfer content to volume") - } -} - func TestBindMounts(t *testing.T) { eng := NewTestEngine(t) r := mkDaemonFromEngine(eng, t)