summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2019-05-22 10:07:28 -0400
committerMatthew Heon <matthew.heon@pm.me>2019-05-23 16:30:11 -0400
commit0b571ede7886c8114419f592afe9264243c10e7d (patch)
tree4a2a9fa5a58aa0704c63d27eb76c5f1ac1a58430 /test
parent773b9ac9d059a66280ac50163a17bc705bde0a60 (diff)
downloadpodman-0b571ede7886c8114419f592afe9264243c10e7d.tar.gz
podman-0b571ede7886c8114419f592afe9264243c10e7d.tar.bz2
podman-0b571ede7886c8114419f592afe9264243c10e7d.zip
Fix a potential flake in the tests for podman cp
Instead of using the working directory, use a subdirectory of the temporary directory created for the individual test, to prevent a potential EEXIST for shared working directory. Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'test')
-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)
})
})