summaryrefslogtreecommitdiff
path: root/test/e2e
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2019-09-03 15:03:44 -0400
committerMatthew Heon <matthew.heon@pm.me>2019-09-05 17:12:27 -0400
commita760e325f3180638f9fedd0ee79d4c6695d8ba64 (patch)
tree7969ab74dfe2c41df7387fd0601014dcd9656052 /test/e2e
parent5a8a71ed817a4fa50fd9444846a50b76f25228d1 (diff)
downloadpodman-a760e325f3180638f9fedd0ee79d4c6695d8ba64.tar.gz
podman-a760e325f3180638f9fedd0ee79d4c6695d8ba64.tar.bz2
podman-a760e325f3180638f9fedd0ee79d4c6695d8ba64.zip
Add ability for volumes with options to mount/umount
When volume options and the local volume driver are specified, the volume is intended to be mounted using the 'mount' command. Supported options will be used to volume the volume before the first container using it starts, and unmount the volume after the last container using it dies. This should work for any local filesystem, though at present I've only tested with tmpfs and btrfs. Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'test/e2e')
-rw-r--r--test/e2e/run_volume_test.go59
-rw-r--r--test/e2e/volume_create_test.go6
2 files changed, 65 insertions, 0 deletions
diff --git a/test/e2e/run_volume_test.go b/test/e2e/run_volume_test.go
index 5bad6744b..551e86b93 100644
--- a/test/e2e/run_volume_test.go
+++ b/test/e2e/run_volume_test.go
@@ -5,11 +5,14 @@ package integration
import (
"fmt"
"os"
+ "os/exec"
"path/filepath"
+ "strings"
. "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
+ "github.com/onsi/gomega/gexec"
)
var _ = Describe("Podman run with volumes", func() {
@@ -190,4 +193,60 @@ var _ = Describe("Podman run with volumes", func() {
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Not(Equal(0)))
})
+
+ It("podman run with tmpfs named volume mounts and unmounts", func() {
+ SkipIfRootless()
+ volName := "testvol"
+ mkVolume := podmanTest.Podman([]string{"volume", "create", "--opt", "type=tmpfs", "--opt", "device=tmpfs", "--opt", "o=nodev", "testvol"})
+ mkVolume.WaitWithDefaultTimeout()
+ Expect(mkVolume.ExitCode()).To(Equal(0))
+
+ // Volume not mounted on create
+ mountCmd1, err := gexec.Start(exec.Command("mount"), GinkgoWriter, GinkgoWriter)
+ Expect(err).To(BeNil())
+ mountCmd1.Wait(90)
+ Expect(mountCmd1.ExitCode()).To(Equal(0))
+ os.Stdout.Sync()
+ os.Stderr.Sync()
+ mountOut1 := strings.Join(strings.Fields(fmt.Sprintf("%s", mountCmd1.Out.Contents())), " ")
+ fmt.Printf("Output: %s", mountOut1)
+ Expect(strings.Contains(mountOut1, volName)).To(BeFalse())
+
+ ctrName := "testctr"
+ podmanSession := podmanTest.Podman([]string{"run", "-d", "--name", ctrName, "-v", fmt.Sprintf("%s:/testvol", volName), ALPINE, "top"})
+ podmanSession.WaitWithDefaultTimeout()
+ Expect(podmanSession.ExitCode()).To(Equal(0))
+
+ // Volume now mounted as container is running
+ mountCmd2, err := gexec.Start(exec.Command("mount"), GinkgoWriter, GinkgoWriter)
+ Expect(err).To(BeNil())
+ mountCmd2.Wait(90)
+ Expect(mountCmd2.ExitCode()).To(Equal(0))
+ os.Stdout.Sync()
+ os.Stderr.Sync()
+ mountOut2 := strings.Join(strings.Fields(fmt.Sprintf("%s", mountCmd2.Out.Contents())), " ")
+ fmt.Printf("Output: %s", mountOut2)
+ Expect(strings.Contains(mountOut2, volName)).To(BeTrue())
+
+ // Stop the container to unmount
+ podmanStopSession := podmanTest.Podman([]string{"stop", "--timeout", "0", ctrName})
+ podmanStopSession.WaitWithDefaultTimeout()
+ Expect(podmanStopSession.ExitCode()).To(Equal(0))
+
+ // We have to force cleanup so the unmount happens
+ podmanCleanupSession := podmanTest.Podman([]string{"container", "cleanup", ctrName})
+ podmanCleanupSession.WaitWithDefaultTimeout()
+ Expect(podmanCleanupSession.ExitCode()).To(Equal(0))
+
+ // Ensure volume is unmounted
+ mountCmd3, err := gexec.Start(exec.Command("mount"), GinkgoWriter, GinkgoWriter)
+ Expect(err).To(BeNil())
+ mountCmd3.Wait(90)
+ Expect(mountCmd3.ExitCode()).To(Equal(0))
+ os.Stdout.Sync()
+ os.Stderr.Sync()
+ mountOut3 := strings.Join(strings.Fields(fmt.Sprintf("%s", mountCmd3.Out.Contents())), " ")
+ fmt.Printf("Output: %s", mountOut3)
+ Expect(strings.Contains(mountOut3, volName)).To(BeFalse())
+ })
})
diff --git a/test/e2e/volume_create_test.go b/test/e2e/volume_create_test.go
index 041a9e6f0..77e8abbd4 100644
--- a/test/e2e/volume_create_test.go
+++ b/test/e2e/volume_create_test.go
@@ -57,4 +57,10 @@ var _ = Describe("Podman volume create", func() {
Expect(match).To(BeTrue())
Expect(len(check.OutputToStringArray())).To(Equal(1))
})
+
+ It("podman create volume with bad volume option", func() {
+ session := podmanTest.Podman([]string{"volume", "create", "--opt", "badOpt=bad"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Not(Equal(0)))
+ })
})