aboutsummaryrefslogtreecommitdiff
path: root/test/e2e
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-05-25 12:20:08 +0200
committerGitHub <noreply@github.com>2019-05-25 12:20:08 +0200
commit3c85122faa8f5697d41cb704c76468349cf97cb8 (patch)
tree771c69a9e4f15b43dac8d686d0b08262310411f2 /test/e2e
parent1ac06d8469295c24a2a629b8926bcd66805c6054 (diff)
parent0b571ede7886c8114419f592afe9264243c10e7d (diff)
downloadpodman-3c85122faa8f5697d41cb704c76468349cf97cb8.tar.gz
podman-3c85122faa8f5697d41cb704c76468349cf97cb8.tar.bz2
podman-3c85122faa8f5697d41cb704c76468349cf97cb8.zip
Merge pull request #3185 from mheon/fix_cp_test
Fix a potential flake in the tests for podman cp
Diffstat (limited to 'test/e2e')
-rw-r--r--test/e2e/cp_test.go44
1 files changed, 16 insertions, 28 deletions
diff --git a/test/e2e/cp_test.go b/test/e2e/cp_test.go
index 1dfa8f50d..71fc064a5 100644
--- a/test/e2e/cp_test.go
+++ b/test/e2e/cp_test.go
@@ -39,11 +39,10 @@ var _ = Describe("Podman cp", func() {
})
It("podman cp file", func() {
- path, err := os.Getwd()
- Expect(err).To(BeNil())
- filePath := filepath.Join(path, "cp_test.txt")
+ srcPath := filepath.Join(podmanTest.RunRoot, "cp_test.txt")
+ dstPath := filepath.Join(podmanTest.RunRoot, "cp_from_container")
fromHostToContainer := []byte("copy from host to container")
- err = ioutil.WriteFile(filePath, fromHostToContainer, 0644)
+ err := ioutil.WriteFile(srcPath, fromHostToContainer, 0644)
Expect(err).To(BeNil())
session := podmanTest.Podman([]string{"create", ALPINE, "cat", "foo"})
@@ -51,24 +50,22 @@ var _ = Describe("Podman cp", func() {
Expect(session.ExitCode()).To(Equal(0))
name := session.OutputToString()
- session = podmanTest.Podman([]string{"cp", filepath.Join(path, "cp_test.txt"), name + ":foo"})
+ session = podmanTest.Podman([]string{"cp", srcPath, name + ":foo"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
- session = podmanTest.Podman([]string{"cp", name + ":foo", filepath.Join(path, "cp_from_container")})
+ session = podmanTest.Podman([]string{"cp", name + ":foo", dstPath})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
-
- os.Remove("cp_from_container")
- os.Remove("cp_test.txt")
})
It("podman cp file to dir", func() {
- path, err := os.Getwd()
- Expect(err).To(BeNil())
- filePath := filepath.Join(path, "cp_test.txt")
+ srcPath := filepath.Join(podmanTest.RunRoot, "cp_test.txt")
+ dstDir := filepath.Join(podmanTest.RunRoot, "receive")
fromHostToContainer := []byte("copy from host to container directory")
- err = ioutil.WriteFile(filePath, fromHostToContainer, 0644)
+ err := ioutil.WriteFile(srcPath, fromHostToContainer, 0644)
+ Expect(err).To(BeNil())
+ err = os.Mkdir(dstDir, 0755)
Expect(err).To(BeNil())
session := podmanTest.Podman([]string{"create", ALPINE, "ls", "foodir/"})
@@ -76,11 +73,11 @@ var _ = Describe("Podman cp", func() {
Expect(session.ExitCode()).To(Equal(0))
name := session.OutputToString()
- session = podmanTest.Podman([]string{"cp", filepath.Join(path, "cp_test.txt"), name + ":foodir/"})
+ session = podmanTest.Podman([]string{"cp", srcPath, name + ":foodir/"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
- session = podmanTest.Podman([]string{"cp", name + ":foodir/cp_test.txt", path + "/receive/"})
+ session = podmanTest.Podman([]string{"cp", name + ":foodir/cp_test.txt", dstDir})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
@@ -89,10 +86,8 @@ var _ = Describe("Podman cp", func() {
})
It("podman cp dir to dir", func() {
- path, err := os.Getwd()
- Expect(err).To(BeNil())
- testDirPath := filepath.Join(path, "TestDir")
- err = os.Mkdir(testDirPath, 0777)
+ testDirPath := filepath.Join(podmanTest.RunRoot, "TestDir")
+ err := os.Mkdir(testDirPath, 0755)
Expect(err).To(BeNil())
session := podmanTest.Podman([]string{"create", ALPINE, "ls", "/foodir"})
@@ -107,15 +102,11 @@ var _ = Describe("Podman cp", func() {
session = podmanTest.Podman([]string{"cp", testDirPath, name + ":/foodir"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
-
- os.RemoveAll(testDirPath)
})
It("podman cp stdin/stdout", func() {
- path, err := os.Getwd()
- Expect(err).To(BeNil())
- testDirPath := filepath.Join(path, "TestDir")
- err = os.Mkdir(testDirPath, 0777)
+ testDirPath := filepath.Join(podmanTest.RunRoot, "TestDir")
+ err := os.Mkdir(testDirPath, 0755)
Expect(err).To(BeNil())
cmd := exec.Command("tar", "-zcvf", "file.tar.gz", testDirPath)
_, err = cmd.Output()
@@ -139,8 +130,5 @@ var _ = Describe("Podman cp", func() {
session = podmanTest.Podman([]string{"cp", name + ":/foo.tar.gz", "-"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
-
- os.Remove("file.tar.gz")
- os.RemoveAll(testDirPath)
})
})