summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-08-26 09:33:08 -0400
committerGitHub <noreply@github.com>2021-08-26 09:33:08 -0400
commitcb235592702550c94bdc526a033ca2cebecb7337 (patch)
treeabde046696a2597ffa4d7d9c9faf75955ce8d20f /test
parent6f1faf36da9482c1cc99814772d16125fe9a4e36 (diff)
parentd5507704e9de0a4c0835f66668985eaf67ab3a72 (diff)
downloadpodman-cb235592702550c94bdc526a033ca2cebecb7337.tar.gz
podman-cb235592702550c94bdc526a033ca2cebecb7337.tar.bz2
podman-cb235592702550c94bdc526a033ca2cebecb7337.zip
Merge pull request #11307 from flouthoc/volume-import-external
volumes: Add support for `volume import` which allows importing contents of external tarballs into podman volumes.
Diffstat (limited to 'test')
-rw-r--r--test/e2e/volume_create_test.go44
-rw-r--r--test/system/160-volumes.bats16
2 files changed, 60 insertions, 0 deletions
diff --git a/test/e2e/volume_create_test.go b/test/e2e/volume_create_test.go
index d9c805f46..3be1486d8 100644
--- a/test/e2e/volume_create_test.go
+++ b/test/e2e/volume_create_test.go
@@ -79,6 +79,50 @@ var _ = Describe("Podman volume create", func() {
Expect(check.OutputToString()).To(ContainSubstring("hello"))
})
+ It("podman create and import volume", func() {
+ if podmanTest.RemoteTest {
+ Skip("Volume export check does not work with a remote client")
+ }
+
+ session := podmanTest.Podman([]string{"volume", "create", "my_vol"})
+ session.WaitWithDefaultTimeout()
+ volName := session.OutputToString()
+ Expect(session).Should(Exit(0))
+
+ session = podmanTest.Podman([]string{"run", "--volume", volName + ":/data", ALPINE, "sh", "-c", "echo hello >> " + "/data/test"})
+ session.WaitWithDefaultTimeout()
+ Expect(session).Should(Exit(0))
+
+ session = podmanTest.Podman([]string{"volume", "export", volName, "--output=hello.tar"})
+ session.WaitWithDefaultTimeout()
+ Expect(session).Should(Exit(0))
+
+ session = podmanTest.Podman([]string{"volume", "create", "my_vol2"})
+ session.WaitWithDefaultTimeout()
+ volName = session.OutputToString()
+ Expect(session).Should(Exit(0))
+
+ session = podmanTest.Podman([]string{"volume", "import", "my_vol2", "hello.tar"})
+ session.WaitWithDefaultTimeout()
+ volName = session.OutputToString()
+ Expect(session).Should(Exit(0))
+
+ session = podmanTest.Podman([]string{"run", "--volume", "my_vol2:/data", ALPINE, "cat", "/data/test"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.OutputToString()).To(ContainSubstring("hello"))
+ })
+
+ It("podman import volume should fail", func() {
+ // try import on volume or source which does not exists
+ if podmanTest.RemoteTest {
+ Skip("Volume export check does not work with a remote client")
+ }
+
+ session := podmanTest.Podman([]string{"volume", "import", "notfound", "notfound.tar"})
+ session.WaitWithDefaultTimeout()
+ Expect(session).To(ExitWithError())
+ })
+
It("podman create volume with bad volume option", func() {
session := podmanTest.Podman([]string{"volume", "create", "--opt", "badOpt=bad"})
session.WaitWithDefaultTimeout()
diff --git a/test/system/160-volumes.bats b/test/system/160-volumes.bats
index 9a852db89..f6dc3f0af 100644
--- a/test/system/160-volumes.bats
+++ b/test/system/160-volumes.bats
@@ -186,6 +186,22 @@ EOF
}
+# Podman volume import test
+@test "podman volume import test" {
+ skip_if_remote "volumes import is not applicable on podman-remote"
+ run_podman volume create my_vol
+ run_podman run --rm -v my_vol:/data $IMAGE sh -c "echo hello >> /data/test"
+ run_podman volume create my_vol2
+ run_podman volume export my_vol --output=hello.tar
+ # we want to use `run_podman volume export my_vol` but run_podman is wrapping EOF
+ cat hello.tar | run_podman volume import my_vol2 -
+ run_podman run --rm -v my_vol2:/data $IMAGE sh -c "cat /data/test"
+ is "$output" "hello" "output from second container"
+ run_podman volume rm my_vol
+ run_podman volume rm my_vol2
+}
+
+
# Confirm that container sees the correct id
@test "podman volume with --userns=keep-id" {
is_rootless || skip "only meaningful when run rootless"