summaryrefslogtreecommitdiff
path: root/test/e2e
diff options
context:
space:
mode:
authorKazım SARIKAYA <kazimsarikaya@sanaldiyar.com>2021-01-03 19:04:25 +0300
committerKazım SARIKAYA <kazimsarikaya@sanaldiyar.com>2021-01-03 19:26:02 +0300
commit3ae91aff9ee67acac64f3e97908e55c5912a33fe (patch)
tree7d18b1bb2e748b32fa4fec77980b763846a3ed2a /test/e2e
parent142b4ac966e12559c534be380093a44d0a1d2959 (diff)
downloadpodman-3ae91aff9ee67acac64f3e97908e55c5912a33fe.tar.gz
podman-3ae91aff9ee67acac64f3e97908e55c5912a33fe.tar.bz2
podman-3ae91aff9ee67acac64f3e97908e55c5912a33fe.zip
podman-remote fix sending tar content
1.) podman cannot send proper dockerfile when it is not inside root folder. 2.) support for sending symlinks and folders inside context dir 3.) when sending context dir as tar to remote, prevent sending items inside .dockerignore Signed-off-by: Kazım SARIKAYA <kazimsarikaya@sanaldiyar.com>
Diffstat (limited to 'test/e2e')
-rw-r--r--test/e2e/build_test.go216
1 files changed, 215 insertions, 1 deletions
diff --git a/test/e2e/build_test.go b/test/e2e/build_test.go
index ac9481797..21f98d3d0 100644
--- a/test/e2e/build_test.go
+++ b/test/e2e/build_test.go
@@ -234,7 +234,7 @@ RUN printenv http_proxy`
})
It("podman build and check identity", func() {
- session := podmanTest.Podman([]string{"build", "-f", "Containerfile.path", "--no-cache", "-t", "test", "build/basicalpine"})
+ session := podmanTest.Podman([]string{"build", "-f", "build/basicalpine/Containerfile.path", "--no-cache", "-t", "test", "build/basicalpine"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
@@ -244,4 +244,218 @@ RUN printenv http_proxy`
data := inspect.OutputToString()
Expect(data).To(ContainSubstring(buildah.Version))
})
+
+ It("podman remote test container/docker file is not inside context dir", func() {
+ // Given
+ // Switch to temp dir and restore it afterwards
+ cwd, err := os.Getwd()
+ Expect(err).To(BeNil())
+
+ podmanTest.AddImageToRWStore(ALPINE)
+
+ // Write target and fake files
+ targetPath, err := CreateTempDirInTempDir()
+ Expect(err).To(BeNil())
+ targetSubPath := filepath.Join(targetPath, "subdir")
+ err = os.Mkdir(targetSubPath, 0755)
+ Expect(err).To(BeNil())
+ dummyFile := filepath.Join(targetSubPath, "dummy")
+ err = ioutil.WriteFile(dummyFile, []byte("dummy"), 0644)
+ Expect(err).To(BeNil())
+
+ containerfile := `FROM quay.io/libpod/alpine:latest
+ADD . /test
+RUN find /test`
+
+ containerfilePath := filepath.Join(targetPath, "Containerfile")
+ err = ioutil.WriteFile(containerfilePath, []byte(containerfile), 0644)
+ Expect(err).To(BeNil())
+
+ defer func() {
+ Expect(os.Chdir(cwd)).To(BeNil())
+ Expect(os.RemoveAll(targetPath)).To(BeNil())
+ }()
+
+ // make cwd as context root path
+ Expect(os.Chdir(targetPath)).To(BeNil())
+
+ session := podmanTest.Podman([]string{"build", "-t", "test", "-f", "Containerfile", targetSubPath})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ ok, _ := session.GrepString("/test/dummy")
+ Expect(ok).To(BeTrue())
+ })
+
+ It("podman remote test container/docker file is not at root of context dir", func() {
+ if IsRemote() {
+ podmanTest.StopRemoteService()
+ podmanTest.StartRemoteService()
+ } else {
+ Skip("Only valid at remote test")
+ }
+ // Given
+ // Switch to temp dir and restore it afterwards
+ cwd, err := os.Getwd()
+ Expect(err).To(BeNil())
+
+ podmanTest.AddImageToRWStore(ALPINE)
+
+ // Write target and fake files
+ targetPath, err := CreateTempDirInTempDir()
+ Expect(err).To(BeNil())
+ targetSubPath := filepath.Join(targetPath, "subdir")
+ err = os.Mkdir(targetSubPath, 0755)
+ Expect(err).To(BeNil())
+
+ containerfile := `FROM quay.io/libpod/alpine:latest`
+
+ containerfilePath := filepath.Join(targetSubPath, "Containerfile")
+ err = ioutil.WriteFile(containerfilePath, []byte(containerfile), 0644)
+ Expect(err).To(BeNil())
+
+ defer func() {
+ Expect(os.Chdir(cwd)).To(BeNil())
+ Expect(os.RemoveAll(targetPath)).To(BeNil())
+ }()
+
+ // make cwd as context root path
+ Expect(os.Chdir(targetPath)).To(BeNil())
+
+ session := podmanTest.Podman([]string{"build", "-t", "test", "-f", "subdir/Containerfile", "."})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ })
+
+ It("podman remote test .dockerignore", func() {
+ if IsRemote() {
+ podmanTest.StopRemoteService()
+ podmanTest.StartRemoteService()
+ } else {
+ Skip("Only valid at remote test")
+ }
+ // Given
+ // Switch to temp dir and restore it afterwards
+ cwd, err := os.Getwd()
+ Expect(err).To(BeNil())
+
+ podmanTest.AddImageToRWStore(ALPINE)
+
+ // Write target and fake files
+ targetPath, err := CreateTempDirInTempDir()
+ Expect(err).To(BeNil())
+
+ containerfile := `FROM quay.io/libpod/alpine:latest
+ADD . /testfilter/
+RUN find /testfilter/`
+
+ containerfilePath := filepath.Join(targetPath, "Containerfile")
+ err = ioutil.WriteFile(containerfilePath, []byte(containerfile), 0644)
+ Expect(err).To(BeNil())
+
+ targetSubPath := filepath.Join(targetPath, "subdir")
+ err = os.Mkdir(targetSubPath, 0755)
+ Expect(err).To(BeNil())
+
+ dummyFile1 := filepath.Join(targetPath, "dummy1")
+ err = ioutil.WriteFile(dummyFile1, []byte("dummy1"), 0644)
+ Expect(err).To(BeNil())
+
+ dummyFile2 := filepath.Join(targetPath, "dummy2")
+ err = ioutil.WriteFile(dummyFile2, []byte("dummy2"), 0644)
+ Expect(err).To(BeNil())
+
+ dummyFile3 := filepath.Join(targetSubPath, "dummy3")
+ err = ioutil.WriteFile(dummyFile3, []byte("dummy3"), 0644)
+ Expect(err).To(BeNil())
+
+ defer func() {
+ Expect(os.Chdir(cwd)).To(BeNil())
+ Expect(os.RemoveAll(targetPath)).To(BeNil())
+ }()
+
+ // make cwd as context root path
+ Expect(os.Chdir(targetPath)).To(BeNil())
+
+ dockerignoreContent := `dummy1
+subdir**`
+ dockerignoreFile := filepath.Join(targetPath, ".dockerignore")
+
+ // test .dockerignore
+ By("Test .dockererignore")
+ err = ioutil.WriteFile(dockerignoreFile, []byte(dockerignoreContent), 0644)
+ Expect(err).To(BeNil())
+
+ session := podmanTest.Podman([]string{"build", "-t", "test", "."})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ ok, _ := session.GrepString("/testfilter/dummy1")
+ Expect(ok).NotTo(BeTrue())
+ ok, _ = session.GrepString("/testfilter/dummy2")
+ Expect(ok).To(BeTrue())
+ ok, _ = session.GrepString("/testfilter/subdir")
+ Expect(ok).NotTo(BeTrue()) //.dockerignore filters both subdir and inside subdir
+ ok, _ = session.GrepString("/testfilter/subdir/dummy3")
+ Expect(ok).NotTo(BeTrue())
+ })
+
+ It("podman remote test context dir contains empty dirs and symlinks", func() {
+ if IsRemote() {
+ podmanTest.StopRemoteService()
+ podmanTest.StartRemoteService()
+ } else {
+ Skip("Only valid at remote test")
+ }
+ // Given
+ // Switch to temp dir and restore it afterwards
+ cwd, err := os.Getwd()
+ Expect(err).To(BeNil())
+
+ podmanTest.AddImageToRWStore(ALPINE)
+
+ // Write target and fake files
+ targetPath, err := CreateTempDirInTempDir()
+ Expect(err).To(BeNil())
+ targetSubPath := filepath.Join(targetPath, "subdir")
+ err = os.Mkdir(targetSubPath, 0755)
+ Expect(err).To(BeNil())
+ dummyFile := filepath.Join(targetSubPath, "dummy")
+ err = ioutil.WriteFile(dummyFile, []byte("dummy"), 0644)
+ Expect(err).To(BeNil())
+
+ emptyDir := filepath.Join(targetSubPath, "emptyDir")
+ err = os.Mkdir(emptyDir, 0755)
+ Expect(err).To(BeNil())
+ Expect(os.Chdir(targetSubPath)).To(BeNil())
+ Expect(os.Symlink("dummy", "dummy-symlink")).To(BeNil())
+
+ containerfile := `FROM quay.io/libpod/alpine:latest
+ADD . /test
+RUN find /test
+RUN [[ -L /test/dummy-symlink ]] && echo SYMLNKOK || echo SYMLNKERR`
+
+ containerfilePath := filepath.Join(targetSubPath, "Containerfile")
+ err = ioutil.WriteFile(containerfilePath, []byte(containerfile), 0644)
+ Expect(err).To(BeNil())
+
+ defer func() {
+ Expect(os.Chdir(cwd)).To(BeNil())
+ Expect(os.RemoveAll(targetPath)).To(BeNil())
+ }()
+
+ // make cwd as context root path
+ Expect(os.Chdir(targetPath)).To(BeNil())
+
+ session := podmanTest.Podman([]string{"build", "-t", "test", targetSubPath})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ ok, _ := session.GrepString("/test/dummy")
+ Expect(ok).To(BeTrue())
+ ok, _ = session.GrepString("/test/emptyDir")
+ Expect(ok).To(BeTrue())
+ ok, _ = session.GrepString("/test/dummy-symlink")
+ Expect(ok).To(BeTrue())
+ ok, _ = session.GrepString("SYMLNKOK")
+ Expect(ok).To(BeTrue())
+ })
+
})