From e45c92153d0c21308fe5983aa76182cc03ef398e Mon Sep 17 00:00:00 2001 From: Alexandr Morozov Date: Thu, 2 Oct 2014 11:33:12 -0700 Subject: [PATCH 01/11] Rewrite TestBuildCopyAddMultipleFiles to not use fixtures Signed-off-by: Alexandr Morozov --- .../TestCopy/MultipleFiles/Dockerfile | 17 --------- .../TestCopy/MultipleFiles/test_file1 | 0 .../TestCopy/MultipleFiles/test_file2 | 0 .../TestCopy/MultipleFiles/test_file3 | 0 .../TestCopy/MultipleFiles/test_file4 | 0 integration-cli/docker_cli_build_test.go | 37 ++++++++++++++++--- 6 files changed, 32 insertions(+), 22 deletions(-) delete mode 100644 integration-cli/build_tests/TestCopy/MultipleFiles/Dockerfile delete mode 100644 integration-cli/build_tests/TestCopy/MultipleFiles/test_file1 delete mode 100644 integration-cli/build_tests/TestCopy/MultipleFiles/test_file2 delete mode 100644 integration-cli/build_tests/TestCopy/MultipleFiles/test_file3 delete mode 100644 integration-cli/build_tests/TestCopy/MultipleFiles/test_file4 diff --git a/integration-cli/build_tests/TestCopy/MultipleFiles/Dockerfile b/integration-cli/build_tests/TestCopy/MultipleFiles/Dockerfile deleted file mode 100644 index 4143e65962..0000000000 --- a/integration-cli/build_tests/TestCopy/MultipleFiles/Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -FROM busybox -RUN echo 'dockerio:x:1001:1001::/bin:/bin/false' >> /etc/passwd -RUN echo 'dockerio:x:1001:' >> /etc/group -RUN mkdir /exists -RUN touch /exists/exists_file -RUN chown -R dockerio.dockerio /exists -COPY test_file1 test_file2 /exists/ -ADD test_file3 test_file4 https://docker.com/robots.txt /exists/ -RUN [ $(ls -l / | grep exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ] -RUN [ $(ls -l /exists/test_file1 | awk '{print $3":"$4}') = 'root:root' ] -RUN [ $(ls -l /exists/test_file2 | awk '{print $3":"$4}') = 'root:root' ] - -RUN [ $(ls -l /exists/test_file3 | awk '{print $3":"$4}') = 'root:root' ] -RUN [ $(ls -l /exists/test_file4 | awk '{print $3":"$4}') = 'root:root' ] -RUN [ $(ls -l /exists/robots.txt | awk '{print $3":"$4}') = 'root:root' ] - -RUN [ $(ls -l /exists/exists_file | awk '{print $3":"$4}') = 'dockerio:dockerio' ] diff --git a/integration-cli/build_tests/TestCopy/MultipleFiles/test_file1 b/integration-cli/build_tests/TestCopy/MultipleFiles/test_file1 deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/integration-cli/build_tests/TestCopy/MultipleFiles/test_file2 b/integration-cli/build_tests/TestCopy/MultipleFiles/test_file2 deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/integration-cli/build_tests/TestCopy/MultipleFiles/test_file3 b/integration-cli/build_tests/TestCopy/MultipleFiles/test_file3 deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/integration-cli/build_tests/TestCopy/MultipleFiles/test_file4 b/integration-cli/build_tests/TestCopy/MultipleFiles/test_file4 deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/integration-cli/docker_cli_build_test.go b/integration-cli/docker_cli_build_test.go index 76105fbf6a..f7d6d932a2 100644 --- a/integration-cli/docker_cli_build_test.go +++ b/integration-cli/docker_cli_build_test.go @@ -304,13 +304,40 @@ RUN [ $(ls -l /exists/exists_file | awk '{print $3":"$4}') = 'dockerio:dockerio' } func TestBuildCopyAddMultipleFiles(t *testing.T) { - buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestCopy") - if out, _, err := dockerCmdInDir(t, buildDirectory, "build", "-t", "testaddimg", "MultipleFiles"); err != nil { - t.Fatalf("build failed to complete: %s, %v", out, err) + name := "testcopymultiplefilestofile" + defer deleteImages(name) + ctx, err := fakeContext(`FROM busybox +RUN echo 'dockerio:x:1001:1001::/bin:/bin/false' >> /etc/passwd +RUN echo 'dockerio:x:1001:' >> /etc/group +RUN mkdir /exists +RUN touch /exists/exists_file +RUN chown -R dockerio.dockerio /exists +COPY test_file1 test_file2 /exists/ +ADD test_file3 test_file4 https://docker.com/robots.txt /exists/ +RUN [ $(ls -l / | grep exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ] +RUN [ $(ls -l /exists/test_file1 | awk '{print $3":"$4}') = 'root:root' ] +RUN [ $(ls -l /exists/test_file2 | awk '{print $3":"$4}') = 'root:root' ] + +RUN [ $(ls -l /exists/test_file3 | awk '{print $3":"$4}') = 'root:root' ] +RUN [ $(ls -l /exists/test_file4 | awk '{print $3":"$4}') = 'root:root' ] +RUN [ $(ls -l /exists/robots.txt | awk '{print $3":"$4}') = 'root:root' ] + +RUN [ $(ls -l /exists/exists_file | awk '{print $3":"$4}') = 'dockerio:dockerio' ] +`, + map[string]string{ + "test_file1": "test1", + "test_file2": "test2", + "test_file3": "test3", + "test_file4": "test4", + }) + defer ctx.Close() + if err != nil { + t.Fatal(err) } - deleteImages("testaddimg") - + if _, err := buildImageFromContext(name, ctx, true); err != nil { + t.Fatal(err) + } logDone("build - mulitple file copy/add tests") } From 83c5dced10c4e2a40990e927ccc15a1e0428529c Mon Sep 17 00:00:00 2001 From: Alexandr Morozov Date: Tue, 14 Oct 2014 10:07:04 -0700 Subject: [PATCH 02/11] Rewrite TestBuildCopySingleFileToRoot to not use fixtures Signed-off-by: Alexandr Morozov --- .../TestCopy/SingleFileToRoot/Dockerfile | 9 ----- integration-cli/docker_cli_build_test.go | 34 +++++++++---------- 2 files changed, 16 insertions(+), 27 deletions(-) delete mode 100644 integration-cli/build_tests/TestCopy/SingleFileToRoot/Dockerfile diff --git a/integration-cli/build_tests/TestCopy/SingleFileToRoot/Dockerfile b/integration-cli/build_tests/TestCopy/SingleFileToRoot/Dockerfile deleted file mode 100644 index 38fd09026d..0000000000 --- a/integration-cli/build_tests/TestCopy/SingleFileToRoot/Dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -FROM busybox -RUN echo 'dockerio:x:1001:1001::/bin:/bin/false' >> /etc/passwd -RUN echo 'dockerio:x:1001:' >> /etc/group -RUN touch /exists -RUN chown dockerio.dockerio /exists -COPY test_file / -RUN [ $(ls -l /test_file | awk '{print $3":"$4}') = 'root:root' ] -RUN [ $(ls -l /test_file | awk '{print $1}') = '-rw-r--r--' ] -RUN [ $(ls -l /exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ] diff --git a/integration-cli/docker_cli_build_test.go b/integration-cli/docker_cli_build_test.go index f7d6d932a2..4d379664d7 100644 --- a/integration-cli/docker_cli_build_test.go +++ b/integration-cli/docker_cli_build_test.go @@ -636,28 +636,26 @@ ADD . /`, } func TestBuildCopySingleFileToRoot(t *testing.T) { - testDirName := "SingleFileToRoot" - sourceDirectory := filepath.Join(workingDirectory, "build_tests", "TestCopy", testDirName) - buildDirectory, err := ioutil.TempDir("", "test-build-add") - defer os.RemoveAll(buildDirectory) - - err = copyWithCP(sourceDirectory, buildDirectory) - if err != nil { - t.Fatalf("failed to copy files to temporary directory: %s", err) - } - - buildDirectory = filepath.Join(buildDirectory, testDirName) - f, err := os.OpenFile(filepath.Join(buildDirectory, "test_file"), os.O_CREATE, 0644) + name := "testcopysinglefiletoroot" + defer deleteImages(name) + ctx, err := fakeContext(`FROM busybox +RUN echo 'dockerio:x:1001:1001::/bin:/bin/false' >> /etc/passwd +RUN echo 'dockerio:x:1001:' >> /etc/group +RUN touch /exists +RUN chown dockerio.dockerio /exists +COPY test_file / +RUN [ $(ls -l /test_file | awk '{print $3":"$4}') = 'root:root' ] +RUN [ $(ls -l /test_file | awk '{print $1}') = '-rw-r--r--' ] +RUN [ $(ls -l /exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ]`, + map[string]string{ + "test_file": "test1", + }) if err != nil { t.Fatal(err) } - f.Close() - if out, _, err := dockerCmdInDir(t, buildDirectory, "build", "-t", "testcopyimg", "."); err != nil { - t.Fatalf("build failed to complete: %s, %v", out, err) + if _, err := buildImageFromContext(name, ctx, true); err != nil { + t.Fatal(err) } - - deleteImages("testcopyimg") - logDone("build - copy single file to root") } From d41cba6aed1ffdda9c3e3441d720dab9afc3eb66 Mon Sep 17 00:00:00 2001 From: Alexandr Morozov Date: Tue, 14 Oct 2014 10:12:11 -0700 Subject: [PATCH 03/11] Rewrite TestBuildCopySingleFileToWorkdir to not use fixtures Signed-off-by: Alexandr Morozov --- .../TestCopy/SingleFileToWorkdir/Dockerfile | 2 -- integration-cli/docker_cli_build_test.go | 36 +++++++++---------- 2 files changed, 18 insertions(+), 20 deletions(-) delete mode 100644 integration-cli/build_tests/TestCopy/SingleFileToWorkdir/Dockerfile diff --git a/integration-cli/build_tests/TestCopy/SingleFileToWorkdir/Dockerfile b/integration-cli/build_tests/TestCopy/SingleFileToWorkdir/Dockerfile deleted file mode 100644 index ba2d797e35..0000000000 --- a/integration-cli/build_tests/TestCopy/SingleFileToWorkdir/Dockerfile +++ /dev/null @@ -1,2 +0,0 @@ -FROM busybox -COPY test_file . diff --git a/integration-cli/docker_cli_build_test.go b/integration-cli/docker_cli_build_test.go index 4d379664d7..511e2dda06 100644 --- a/integration-cli/docker_cli_build_test.go +++ b/integration-cli/docker_cli_build_test.go @@ -661,28 +661,28 @@ RUN [ $(ls -l /exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ]`, // Issue #3960: "ADD src ." hangs - adapted for COPY func TestBuildCopySingleFileToWorkdir(t *testing.T) { - testDirName := "SingleFileToWorkdir" - sourceDirectory := filepath.Join(workingDirectory, "build_tests", "TestCopy", testDirName) - buildDirectory, err := ioutil.TempDir("", "test-build-add") - defer os.RemoveAll(buildDirectory) - - err = copyWithCP(sourceDirectory, buildDirectory) - if err != nil { - t.Fatalf("failed to copy files to temporary directory: %s", err) - } - - buildDirectory = filepath.Join(buildDirectory, testDirName) - f, err := os.OpenFile(filepath.Join(buildDirectory, "test_file"), os.O_CREATE, 0644) + name := "testcopysinglefiletoworkdir" + defer deleteImages(name) + ctx, err := fakeContext(`FROM busybox +COPY test_file .`, + map[string]string{ + "test_file": "test1", + }) if err != nil { t.Fatal(err) } - f.Close() - if out, _, err := dockerCmdInDirWithTimeout(5*time.Second, buildDirectory, "build", "-t", "testcopyimg", "."); err != nil { - t.Fatalf("build failed to complete: %s, %v", out, err) + done := make(chan struct{}) + go func() { + if _, err := buildImageFromContext(name, ctx, true); err != nil { + t.Fatal(err) + } + close(done) + }() + select { + case <-time.After(5 * time.Second): + t.Fatal("Build with adding to workdir timed out") + case <-done: } - - deleteImages("testcopyimg") - logDone("build - copy single file to workdir") } From 2248109ff8607264ba40d4a4ac24bad66462d105 Mon Sep 17 00:00:00 2001 From: Alexandr Morozov Date: Tue, 14 Oct 2014 10:15:45 -0700 Subject: [PATCH 04/11] Rewrite TestBuildCopySingleFileToExistDir to not use fixtures Signed-off-by: Alexandr Morozov --- .../TestCopy/SingleFileToExistDir/Dockerfile | 10 ------- .../TestCopy/SingleFileToExistDir/test_file | 0 integration-cli/docker_cli_build_test.go | 26 ++++++++++++++----- 3 files changed, 20 insertions(+), 16 deletions(-) delete mode 100644 integration-cli/build_tests/TestCopy/SingleFileToExistDir/Dockerfile delete mode 100644 integration-cli/build_tests/TestCopy/SingleFileToExistDir/test_file diff --git a/integration-cli/build_tests/TestCopy/SingleFileToExistDir/Dockerfile b/integration-cli/build_tests/TestCopy/SingleFileToExistDir/Dockerfile deleted file mode 100644 index 3edfe661d4..0000000000 --- a/integration-cli/build_tests/TestCopy/SingleFileToExistDir/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM busybox -RUN echo 'dockerio:x:1001:1001::/bin:/bin/false' >> /etc/passwd -RUN echo 'dockerio:x:1001:' >> /etc/group -RUN mkdir /exists -RUN touch /exists/exists_file -RUN chown -R dockerio.dockerio /exists -COPY test_file /exists/ -RUN [ $(ls -l / | grep exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ] -RUN [ $(ls -l /exists/test_file | awk '{print $3":"$4}') = 'root:root' ] -RUN [ $(ls -l /exists/exists_file | awk '{print $3":"$4}') = 'dockerio:dockerio' ] diff --git a/integration-cli/build_tests/TestCopy/SingleFileToExistDir/test_file b/integration-cli/build_tests/TestCopy/SingleFileToExistDir/test_file deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/integration-cli/docker_cli_build_test.go b/integration-cli/docker_cli_build_test.go index 511e2dda06..3026a38887 100644 --- a/integration-cli/docker_cli_build_test.go +++ b/integration-cli/docker_cli_build_test.go @@ -687,13 +687,27 @@ COPY test_file .`, } func TestBuildCopySingleFileToExistDir(t *testing.T) { - buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestCopy") - if out, _, err := dockerCmdInDir(t, buildDirectory, "build", "-t", "testcopyimg", "SingleFileToExistDir"); err != nil { - t.Fatalf("build failed to complete: %s, %v", out, err) + name := "testcopysinglefiletoexistdir" + defer deleteImages(name) + ctx, err := fakeContext(`FROM busybox +RUN echo 'dockerio:x:1001:1001::/bin:/bin/false' >> /etc/passwd +RUN echo 'dockerio:x:1001:' >> /etc/group +RUN mkdir /exists +RUN touch /exists/exists_file +RUN chown -R dockerio.dockerio /exists +COPY test_file /exists/ +RUN [ $(ls -l / | grep exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ] +RUN [ $(ls -l /exists/test_file | awk '{print $3":"$4}') = 'root:root' ] +RUN [ $(ls -l /exists/exists_file | awk '{print $3":"$4}') = 'dockerio:dockerio' ]`, + map[string]string{ + "test_file": "test1", + }) + if err != nil { + t.Fatal(err) + } + if _, err := buildImageFromContext(name, ctx, true); err != nil { + t.Fatal(err) } - - deleteImages("testcopyimg") - logDone("build - copy single file to existing dir") } From 24d83afd5203f93a22a3d95a212e9ec295aadc8b Mon Sep 17 00:00:00 2001 From: Alexandr Morozov Date: Tue, 14 Oct 2014 10:19:45 -0700 Subject: [PATCH 05/11] Rewrite TestBuildCopySingleFileToNonExistDir to not use fixtures Signed-off-by: Alexandr Morozov --- .../SingleFileToNonExistDir/Dockerfile | 9 ------- .../SingleFileToNonExistDir/test_file | 0 integration-cli/docker_cli_build_test.go | 25 ++++++++++++++----- 3 files changed, 19 insertions(+), 15 deletions(-) delete mode 100644 integration-cli/build_tests/TestCopy/SingleFileToNonExistDir/Dockerfile delete mode 100644 integration-cli/build_tests/TestCopy/SingleFileToNonExistDir/test_file diff --git a/integration-cli/build_tests/TestCopy/SingleFileToNonExistDir/Dockerfile b/integration-cli/build_tests/TestCopy/SingleFileToNonExistDir/Dockerfile deleted file mode 100644 index 33b65a62c7..0000000000 --- a/integration-cli/build_tests/TestCopy/SingleFileToNonExistDir/Dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -FROM busybox -RUN echo 'dockerio:x:1001:1001::/bin:/bin/false' >> /etc/passwd -RUN echo 'dockerio:x:1001:' >> /etc/group -RUN touch /exists -RUN chown dockerio.dockerio /exists -COPY test_file /test_dir/ -RUN [ $(ls -l / | grep test_dir | awk '{print $3":"$4}') = 'root:root' ] -RUN [ $(ls -l /test_dir/test_file | awk '{print $3":"$4}') = 'root:root' ] -RUN [ $(ls -l /exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ] diff --git a/integration-cli/build_tests/TestCopy/SingleFileToNonExistDir/test_file b/integration-cli/build_tests/TestCopy/SingleFileToNonExistDir/test_file deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/integration-cli/docker_cli_build_test.go b/integration-cli/docker_cli_build_test.go index 3026a38887..66d7657f91 100644 --- a/integration-cli/docker_cli_build_test.go +++ b/integration-cli/docker_cli_build_test.go @@ -712,13 +712,26 @@ RUN [ $(ls -l /exists/exists_file | awk '{print $3":"$4}') = 'dockerio:dockerio' } func TestBuildCopySingleFileToNonExistDir(t *testing.T) { - buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestCopy") - if out, _, err := dockerCmdInDir(t, buildDirectory, "build", "-t", "testcopyimg", "SingleFileToNonExistDir"); err != nil { - t.Fatalf("build failed to complete: %s, %v", out, err) + name := "testcopysinglefiletononexistdir" + defer deleteImages(name) + ctx, err := fakeContext(`FROM busybox +RUN echo 'dockerio:x:1001:1001::/bin:/bin/false' >> /etc/passwd +RUN echo 'dockerio:x:1001:' >> /etc/group +RUN touch /exists +RUN chown dockerio.dockerio /exists +COPY test_file /test_dir/ +RUN [ $(ls -l / | grep test_dir | awk '{print $3":"$4}') = 'root:root' ] +RUN [ $(ls -l /test_dir/test_file | awk '{print $3":"$4}') = 'root:root' ] +RUN [ $(ls -l /exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ]`, + map[string]string{ + "test_file": "test1", + }) + if err != nil { + t.Fatal(err) + } + if _, err := buildImageFromContext(name, ctx, true); err != nil { + t.Fatal(err) } - - deleteImages("testcopyimg") - logDone("build - copy single file to non-existing dir") } From 832618afc6e6a8c489afb40f94340f158f9680c7 Mon Sep 17 00:00:00 2001 From: Alexandr Morozov Date: Tue, 14 Oct 2014 10:22:06 -0700 Subject: [PATCH 06/11] Rewrite TestBuildCopyDirContentToRoot to not use fixtures Signed-off-by: Alexandr Morozov --- .../TestCopy/DirContentToRoot/Dockerfile | 8 ------- .../DirContentToRoot/test_dir/test_file | 0 integration-cli/docker_cli_build_test.go | 24 ++++++++++++++----- 3 files changed, 18 insertions(+), 14 deletions(-) delete mode 100644 integration-cli/build_tests/TestCopy/DirContentToRoot/Dockerfile delete mode 100644 integration-cli/build_tests/TestCopy/DirContentToRoot/test_dir/test_file diff --git a/integration-cli/build_tests/TestCopy/DirContentToRoot/Dockerfile b/integration-cli/build_tests/TestCopy/DirContentToRoot/Dockerfile deleted file mode 100644 index 45df77e563..0000000000 --- a/integration-cli/build_tests/TestCopy/DirContentToRoot/Dockerfile +++ /dev/null @@ -1,8 +0,0 @@ -FROM busybox -RUN echo 'dockerio:x:1001:1001::/bin:/bin/false' >> /etc/passwd -RUN echo 'dockerio:x:1001:' >> /etc/group -RUN touch /exists -RUN chown dockerio.dockerio exists -COPY test_dir / -RUN [ $(ls -l /test_file | awk '{print $3":"$4}') = 'root:root' ] -RUN [ $(ls -l /exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ] diff --git a/integration-cli/build_tests/TestCopy/DirContentToRoot/test_dir/test_file b/integration-cli/build_tests/TestCopy/DirContentToRoot/test_dir/test_file deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/integration-cli/docker_cli_build_test.go b/integration-cli/docker_cli_build_test.go index 66d7657f91..6293cb8a1a 100644 --- a/integration-cli/docker_cli_build_test.go +++ b/integration-cli/docker_cli_build_test.go @@ -736,13 +736,25 @@ RUN [ $(ls -l /exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ]`, } func TestBuildCopyDirContentToRoot(t *testing.T) { - buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestCopy") - if out, _, err := dockerCmdInDir(t, buildDirectory, "build", "-t", "testcopyimg", "DirContentToRoot"); err != nil { - t.Fatalf("build failed to complete: %s, %v", out, err) + name := "testcopydircontenttoroot" + defer deleteImages(name) + ctx, err := fakeContext(`FROM busybox +RUN echo 'dockerio:x:1001:1001::/bin:/bin/false' >> /etc/passwd +RUN echo 'dockerio:x:1001:' >> /etc/group +RUN touch /exists +RUN chown dockerio.dockerio exists +COPY test_dir / +RUN [ $(ls -l /test_file | awk '{print $3":"$4}') = 'root:root' ] +RUN [ $(ls -l /exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ]`, + map[string]string{ + "test_dir/test_file": "test1", + }) + if err != nil { + t.Fatal(err) + } + if _, err := buildImageFromContext(name, ctx, true); err != nil { + t.Fatal(err) } - - deleteImages("testcopyimg") - logDone("build - copy directory contents to root") } From 4a029259ff41c37eb72a6f221f9725f66491139f Mon Sep 17 00:00:00 2001 From: Alexandr Morozov Date: Tue, 14 Oct 2014 10:26:20 -0700 Subject: [PATCH 07/11] Rewrite TestBuildCopyDirContentToExistDir to not use fixtures Signed-off-by: Alexandr Morozov --- .../TestCopy/DirContentToExistDir/Dockerfile | 10 ------- .../DirContentToExistDir/test_dir/test_file | 0 integration-cli/docker_cli_build_test.go | 26 ++++++++++++++----- 3 files changed, 20 insertions(+), 16 deletions(-) delete mode 100644 integration-cli/build_tests/TestCopy/DirContentToExistDir/Dockerfile delete mode 100644 integration-cli/build_tests/TestCopy/DirContentToExistDir/test_dir/test_file diff --git a/integration-cli/build_tests/TestCopy/DirContentToExistDir/Dockerfile b/integration-cli/build_tests/TestCopy/DirContentToExistDir/Dockerfile deleted file mode 100644 index d63e8538bb..0000000000 --- a/integration-cli/build_tests/TestCopy/DirContentToExistDir/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM busybox -RUN echo 'dockerio:x:1001:1001::/bin:/bin/false' >> /etc/passwd -RUN echo 'dockerio:x:1001:' >> /etc/group -RUN mkdir /exists -RUN touch /exists/exists_file -RUN chown -R dockerio.dockerio /exists -COPY test_dir/ /exists/ -RUN [ $(ls -l / | grep exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ] -RUN [ $(ls -l /exists/exists_file | awk '{print $3":"$4}') = 'dockerio:dockerio' ] -RUN [ $(ls -l /exists/test_file | awk '{print $3":"$4}') = 'root:root' ] diff --git a/integration-cli/build_tests/TestCopy/DirContentToExistDir/test_dir/test_file b/integration-cli/build_tests/TestCopy/DirContentToExistDir/test_dir/test_file deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/integration-cli/docker_cli_build_test.go b/integration-cli/docker_cli_build_test.go index 6293cb8a1a..146ab15ae7 100644 --- a/integration-cli/docker_cli_build_test.go +++ b/integration-cli/docker_cli_build_test.go @@ -759,13 +759,27 @@ RUN [ $(ls -l /exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ]`, } func TestBuildCopyDirContentToExistDir(t *testing.T) { - buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestCopy") - if out, _, err := dockerCmdInDir(t, buildDirectory, "build", "-t", "testcopyimg", "DirContentToExistDir"); err != nil { - t.Fatalf("build failed to complete: %s, %v", out, err) + name := "testcopydircontenttoexistdir" + defer deleteImages(name) + ctx, err := fakeContext(`FROM busybox +RUN echo 'dockerio:x:1001:1001::/bin:/bin/false' >> /etc/passwd +RUN echo 'dockerio:x:1001:' >> /etc/group +RUN mkdir /exists +RUN touch /exists/exists_file +RUN chown -R dockerio.dockerio /exists +COPY test_dir/ /exists/ +RUN [ $(ls -l / | grep exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ] +RUN [ $(ls -l /exists/exists_file | awk '{print $3":"$4}') = 'dockerio:dockerio' ] +RUN [ $(ls -l /exists/test_file | awk '{print $3":"$4}') = 'root:root' ]`, + map[string]string{ + "test_dir/test_file": "test1", + }) + if err != nil { + t.Fatal(err) + } + if _, err := buildImageFromContext(name, ctx, true); err != nil { + t.Fatal(err) } - - deleteImages("testcopyimg") - logDone("build - copy directory contents to existing dir") } From 6582ea574cfcd6cc8e3b1abebe7bfcc7aee05ece Mon Sep 17 00:00:00 2001 From: Alexandr Morozov Date: Tue, 14 Oct 2014 10:29:22 -0700 Subject: [PATCH 08/11] Rewrite TestBuildCopyWholeDirToRoot to not use fixtures Signed-off-by: Alexandr Morozov --- .../TestCopy/WholeDirToRoot/Dockerfile | 11 ----- integration-cli/docker_cli_build_test.go | 40 +++++++++---------- 2 files changed, 18 insertions(+), 33 deletions(-) delete mode 100644 integration-cli/build_tests/TestCopy/WholeDirToRoot/Dockerfile diff --git a/integration-cli/build_tests/TestCopy/WholeDirToRoot/Dockerfile b/integration-cli/build_tests/TestCopy/WholeDirToRoot/Dockerfile deleted file mode 100644 index 91be29fe7a..0000000000 --- a/integration-cli/build_tests/TestCopy/WholeDirToRoot/Dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -FROM busybox -RUN echo 'dockerio:x:1001:1001::/bin:/bin/false' >> /etc/passwd -RUN echo 'dockerio:x:1001:' >> /etc/group -RUN touch /exists -RUN chown dockerio.dockerio exists -COPY test_dir /test_dir -RUN [ $(ls -l / | grep test_dir | awk '{print $3":"$4}') = 'root:root' ] -RUN [ $(ls -l / | grep test_dir | awk '{print $1}') = 'drwxr-xr-x' ] -RUN [ $(ls -l /test_dir/test_file | awk '{print $3":"$4}') = 'root:root' ] -RUN [ $(ls -l /test_dir/test_file | awk '{print $1}') = '-rw-r--r--' ] -RUN [ $(ls -l /exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ] diff --git a/integration-cli/docker_cli_build_test.go b/integration-cli/docker_cli_build_test.go index 146ab15ae7..26901afb5c 100644 --- a/integration-cli/docker_cli_build_test.go +++ b/integration-cli/docker_cli_build_test.go @@ -784,32 +784,28 @@ RUN [ $(ls -l /exists/test_file | awk '{print $3":"$4}') = 'root:root' ]`, } func TestBuildCopyWholeDirToRoot(t *testing.T) { - testDirName := "WholeDirToRoot" - sourceDirectory := filepath.Join(workingDirectory, "build_tests", "TestCopy", testDirName) - buildDirectory, err := ioutil.TempDir("", "test-build-add") - defer os.RemoveAll(buildDirectory) - - err = copyWithCP(sourceDirectory, buildDirectory) - if err != nil { - t.Fatalf("failed to copy files to temporary directory: %s", err) - } - - buildDirectory = filepath.Join(buildDirectory, testDirName) - testDir := filepath.Join(buildDirectory, "test_dir") - if err := os.MkdirAll(testDir, 0755); err != nil { - t.Fatal(err) - } - f, err := os.OpenFile(filepath.Join(testDir, "test_file"), os.O_CREATE, 0644) + name := "testcopywholedirtoroot" + defer deleteImages(name) + ctx, err := fakeContext(`FROM busybox +RUN echo 'dockerio:x:1001:1001::/bin:/bin/false' >> /etc/passwd +RUN echo 'dockerio:x:1001:' >> /etc/group +RUN touch /exists +RUN chown dockerio.dockerio exists +COPY test_dir /test_dir +RUN [ $(ls -l / | grep test_dir | awk '{print $3":"$4}') = 'root:root' ] +RUN [ $(ls -l / | grep test_dir | awk '{print $1}') = 'drwxr-xr-x' ] +RUN [ $(ls -l /test_dir/test_file | awk '{print $3":"$4}') = 'root:root' ] +RUN [ $(ls -l /test_dir/test_file | awk '{print $1}') = '-rw-r--r--' ] +RUN [ $(ls -l /exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ]`, + map[string]string{ + "test_dir/test_file": "test1", + }) if err != nil { t.Fatal(err) } - f.Close() - if out, _, err := dockerCmdInDir(t, buildDirectory, "build", "-t", "testcopyimg", "."); err != nil { - t.Fatalf("build failed to complete: %s, %v", out, err) + if _, err := buildImageFromContext(name, ctx, true); err != nil { + t.Fatal(err) } - - deleteImages("testcopyimg") - logDone("build - copy whole directory to root") } From c8a5d56fd789b50b78ad58c07a535aaf01af77f7 Mon Sep 17 00:00:00 2001 From: Alexandr Morozov Date: Tue, 14 Oct 2014 10:32:00 -0700 Subject: [PATCH 09/11] Rewrite TestBuildCopyEtcToRoot to not use fixtures Signed-off-by: Alexandr Morozov --- .../build_tests/TestCopy/EtcToRoot/Dockerfile | 2 -- integration-cli/docker_cli_build_test.go | 17 ++++++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) delete mode 100644 integration-cli/build_tests/TestCopy/EtcToRoot/Dockerfile diff --git a/integration-cli/build_tests/TestCopy/EtcToRoot/Dockerfile b/integration-cli/build_tests/TestCopy/EtcToRoot/Dockerfile deleted file mode 100644 index b4f319f80f..0000000000 --- a/integration-cli/build_tests/TestCopy/EtcToRoot/Dockerfile +++ /dev/null @@ -1,2 +0,0 @@ -FROM scratch -COPY . / diff --git a/integration-cli/docker_cli_build_test.go b/integration-cli/docker_cli_build_test.go index 26901afb5c..1c6b6b5ac3 100644 --- a/integration-cli/docker_cli_build_test.go +++ b/integration-cli/docker_cli_build_test.go @@ -810,12 +810,19 @@ RUN [ $(ls -l /exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ]`, } func TestBuildCopyEtcToRoot(t *testing.T) { - buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestCopy") - if out, _, err := dockerCmdInDir(t, buildDirectory, "build", "-t", "testcopyimg", "EtcToRoot"); err != nil { - t.Fatalf("build failed to complete: %s, %v", out, err) + name := "testcopyetctoroot" + defer deleteImages(name) + ctx, err := fakeContext(`FROM scratch +COPY . /`, + map[string]string{ + "etc/test_file": "test1", + }) + if err != nil { + t.Fatal(err) + } + if _, err := buildImageFromContext(name, ctx, true); err != nil { + t.Fatal(err) } - - deleteImages("testcopyimg") logDone("build - copy etc directory to root") } From 98e7608b4cec04463781ccb314259873bbb56a16 Mon Sep 17 00:00:00 2001 From: Alexandr Morozov Date: Tue, 14 Oct 2014 10:37:05 -0700 Subject: [PATCH 10/11] Rewrite TestBuildCopyDisallowRemote to not use fixtures Signed-off-by: Alexandr Morozov --- .../build_tests/TestCopy/DisallowRemote/Dockerfile | 2 -- integration-cli/docker_cli_build_test.go | 14 +++++++------- 2 files changed, 7 insertions(+), 9 deletions(-) delete mode 100644 integration-cli/build_tests/TestCopy/DisallowRemote/Dockerfile diff --git a/integration-cli/build_tests/TestCopy/DisallowRemote/Dockerfile b/integration-cli/build_tests/TestCopy/DisallowRemote/Dockerfile deleted file mode 100644 index e6bc0c0dd2..0000000000 --- a/integration-cli/build_tests/TestCopy/DisallowRemote/Dockerfile +++ /dev/null @@ -1,2 +0,0 @@ -FROM busybox -COPY https://index.docker.io/robots.txt / diff --git a/integration-cli/docker_cli_build_test.go b/integration-cli/docker_cli_build_test.go index 1c6b6b5ac3..ad8f22123b 100644 --- a/integration-cli/docker_cli_build_test.go +++ b/integration-cli/docker_cli_build_test.go @@ -827,14 +827,14 @@ COPY . /`, } func TestBuildCopyDisallowRemote(t *testing.T) { - buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestCopy") - buildCmd := exec.Command(dockerBinary, "build", "-t", "testcopyimg", "DisallowRemote") - buildCmd.Dir = buildDirectory - if out, _, err := runCommandWithOutput(buildCmd); err == nil { - t.Fatalf("building the image should've failed; output: %s", out) + name := "testcopydisallowremote" + defer deleteImages(name) + _, out, err := buildImageWithOut(name, `FROM scratch +COPY https://index.docker.io/robots.txt /`, + true) + if err == nil || !strings.Contains(out, "Source can't be a URL for COPY") { + t.Fatal("Error should be about disallowed remote source, got err: %s, out: %q", err, out) } - - deleteImages("testcopyimg") logDone("build - copy - disallow copy from remote") } From 93d3c8e71d0ca8f33d905c455c0520c423fd7eb9 Mon Sep 17 00:00:00 2001 From: Alexandr Morozov Date: Tue, 14 Oct 2014 10:40:07 -0700 Subject: [PATCH 11/11] Just remove integration-cli/build_tests/TestCopy/MultipleFilesToFile because it wasn't used Signed-off-by: Alexandr Morozov --- .../build_tests/TestCopy/MultipleFilesToFile/Dockerfile | 7 ------- .../build_tests/TestCopy/MultipleFilesToFile/test_file1 | 0 .../build_tests/TestCopy/MultipleFilesToFile/test_file2 | 0 .../build_tests/TestCopy/MultipleFilesToFile/test_file3 | 0 4 files changed, 7 deletions(-) delete mode 100644 integration-cli/build_tests/TestCopy/MultipleFilesToFile/Dockerfile delete mode 100644 integration-cli/build_tests/TestCopy/MultipleFilesToFile/test_file1 delete mode 100644 integration-cli/build_tests/TestCopy/MultipleFilesToFile/test_file2 delete mode 100644 integration-cli/build_tests/TestCopy/MultipleFilesToFile/test_file3 diff --git a/integration-cli/build_tests/TestCopy/MultipleFilesToFile/Dockerfile b/integration-cli/build_tests/TestCopy/MultipleFilesToFile/Dockerfile deleted file mode 100644 index 520d356c72..0000000000 --- a/integration-cli/build_tests/TestCopy/MultipleFilesToFile/Dockerfile +++ /dev/null @@ -1,7 +0,0 @@ -FROM busybox -RUN echo 'dockerio:x:1001:1001::/bin:/bin/false' >> /etc/passwd -RUN echo 'dockerio:x:1001:' >> /etc/group -RUN mkdir /exists -RUN chown -R dockerio.dockerio /exists -COPY test_file1 /exists/ -ADD test_file2 test_file3 /exists/test_file1 diff --git a/integration-cli/build_tests/TestCopy/MultipleFilesToFile/test_file1 b/integration-cli/build_tests/TestCopy/MultipleFilesToFile/test_file1 deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/integration-cli/build_tests/TestCopy/MultipleFilesToFile/test_file2 b/integration-cli/build_tests/TestCopy/MultipleFilesToFile/test_file2 deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/integration-cli/build_tests/TestCopy/MultipleFilesToFile/test_file3 b/integration-cli/build_tests/TestCopy/MultipleFilesToFile/test_file3 deleted file mode 100644 index e69de29bb2..0000000000