summaryrefslogtreecommitdiff
path: root/test/e2e
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-05-09 19:35:53 +0200
committerGitHub <noreply@github.com>2019-05-09 19:35:53 +0200
commitd54a2d2f81df98bb49580ef8455bdc043dd4fdf7 (patch)
treed7e1f069992e81d12e8b750d3012cf1831fe0041 /test/e2e
parentd8a065dab377a7bf48680d53d0839b2c7f62d003 (diff)
parent4479b8eec3558daedfd519d577bf63a17f4b2642 (diff)
downloadpodman-d54a2d2f81df98bb49580ef8455bdc043dd4fdf7.tar.gz
podman-d54a2d2f81df98bb49580ef8455bdc043dd4fdf7.tar.bz2
podman-d54a2d2f81df98bb49580ef8455bdc043dd4fdf7.zip
Merge pull request #3041 from QiWang19/cpdash
implement cp reads tar file from stdin/to stdout
Diffstat (limited to 'test/e2e')
-rw-r--r--test/e2e/cp_test.go75
1 files changed, 45 insertions, 30 deletions
diff --git a/test/e2e/cp_test.go b/test/e2e/cp_test.go
index 591f533d6..273668f35 100644
--- a/test/e2e/cp_test.go
+++ b/test/e2e/cp_test.go
@@ -7,6 +7,7 @@ import (
"os"
"os/exec"
"path/filepath"
+ "strings"
. "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
@@ -58,21 +59,12 @@ var _ = Describe("Podman cp", func() {
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
- session = podmanTest.Podman([]string{"start", "-a", name})
- session.WaitWithDefaultTimeout()
-
- Expect(session.ExitCode()).To(Equal(0))
- Expect(session.OutputToString()).To(Equal("copy from host to container"))
-
session = podmanTest.Podman([]string{"cp", name + ":foo", filepath.Join(path, "cp_from_container")})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
- c := exec.Command("cat", filepath.Join(path, "cp_from_container"))
- output, err := c.Output()
- if err != nil {
- os.Exit(1)
- }
- Expect(string(output)).To(Equal("copy from host to container"))
+
+ os.Remove("cp_from_container")
+ os.Remove("cp_test.txt")
})
It("podman cp file to dir", func() {
@@ -89,28 +81,18 @@ var _ = Describe("Podman cp", func() {
session := podmanTest.Podman([]string{"create", ALPINE, "ls", "foodir/"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
- session = podmanTest.Podman([]string{"ps", "-a", "-q"})
- session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
name := session.OutputToString()
session = podmanTest.Podman([]string{"cp", filepath.Join(path, "cp_test.txt"), name + ":foodir/"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
- session = podmanTest.Podman([]string{"start", "-a", name})
- session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
- Expect(session.OutputToString()).To(Equal("cp_test.txt"))
session = podmanTest.Podman([]string{"cp", name + ":foodir/cp_test.txt", path + "/receive/"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
- c := exec.Command("cat", filepath.Join(path, "receive", "cp_test.txt"))
- output, err := c.Output()
- if err != nil {
- os.Exit(1)
- }
- Expect(string(output)).To(Equal("copy from host to container directory"))
+
+ os.Remove("cp_test.txt")
+ os.RemoveAll("receive")
})
It("podman cp dir to dir", func() {
@@ -132,17 +114,50 @@ var _ = Describe("Podman cp", func() {
session = podmanTest.Podman([]string{"cp", testDirPath, name + ":/foodir"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
- session = podmanTest.Podman([]string{"start", "-a", name})
+
+ session = podmanTest.Podman([]string{"cp", testDirPath, name + ":/foodir"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
- Expect(len(session.OutputToStringArray())).To(Equal(0))
- session = podmanTest.Podman([]string{"cp", testDirPath, name + ":/foodir"})
+ os.RemoveAll(testDirPath)
+ })
+
+ It("podman cp stdin/stdout", func() {
+ path, err := os.Getwd()
+ if err != nil {
+ os.Exit(1)
+ }
+ testDirPath := filepath.Join(path, "TestDir")
+ err = os.Mkdir(testDirPath, 0777)
+ if err != nil {
+ os.Exit(1)
+ }
+ cmd := exec.Command("tar", "-zcvf", "file.tar.gz", testDirPath)
+ _, err = cmd.Output()
+ if err != nil {
+ os.Exit(1)
+ }
+
+ session := podmanTest.Podman([]string{"create", ALPINE, "ls", "foo"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ name := session.OutputToString()
+
+ data, err := ioutil.ReadFile("foo.tar.gz")
+ reader := strings.NewReader(string(data))
+ cmd.Stdin = reader
+ session = podmanTest.Podman([]string{"cp", "-", name + ":/foo"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
- session = podmanTest.Podman([]string{"start", "-a", name})
+
+ session = podmanTest.Podman([]string{"cp", "file.tar.gz", name + ":/foo.tar.gz"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
- Expect(session.OutputToString()).To(Equal("TestDir"))
+ 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)
})
})