diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/e2e/images_test.go | 4 | ||||
-rw-r--r-- | test/e2e/mount_test.go | 2 | ||||
-rw-r--r-- | test/e2e/play_kube_test.go | 46 | ||||
-rw-r--r-- | test/e2e/port_test.go | 4 | ||||
-rw-r--r-- | test/e2e/rmi_test.go | 3 | ||||
-rw-r--r-- | test/e2e/run_cpu_test.go | 4 | ||||
-rw-r--r-- | test/e2e/run_volume_test.go | 59 | ||||
-rw-r--r-- | test/e2e/volume_create_test.go | 6 |
8 files changed, 108 insertions, 20 deletions
diff --git a/test/e2e/images_test.go b/test/e2e/images_test.go index 4eadc77e7..8203e4273 100644 --- a/test/e2e/images_test.go +++ b/test/e2e/images_test.go @@ -155,13 +155,13 @@ var _ = Describe("Podman images", func() { retapline.WaitWithDefaultTimeout() Expect(retapline.ExitCode()).To(Equal(0)) Expect(len(retapline.OutputToStringArray())).To(Equal(2)) - Expect(retapline.LineInOutputContains("alpine")) + Expect(retapline.LineInOutputContains("alpine")).To(BeTrue()) retapline = podmanTest.PodmanNoCache([]string{"images", "-f", "reference=alpine"}) retapline.WaitWithDefaultTimeout() Expect(retapline.ExitCode()).To(Equal(0)) Expect(len(retapline.OutputToStringArray())).To(Equal(2)) - Expect(retapline.LineInOutputContains("alpine")) + Expect(retapline.LineInOutputContains("alpine")).To(BeTrue()) retnone := podmanTest.PodmanNoCache([]string{"images", "-q", "-f", "reference=bogus"}) retnone.WaitWithDefaultTimeout() diff --git a/test/e2e/mount_test.go b/test/e2e/mount_test.go index 61abdf6fc..3197aa655 100644 --- a/test/e2e/mount_test.go +++ b/test/e2e/mount_test.go @@ -77,7 +77,7 @@ var _ = Describe("Podman mount", func() { j := podmanTest.Podman([]string{"mount", "--format=json"}) j.WaitWithDefaultTimeout() Expect(j.ExitCode()).To(Equal(0)) - Expect(j.IsJSONOutputValid()) + Expect(j.IsJSONOutputValid()).To(BeTrue()) umount := podmanTest.Podman([]string{"umount", cid}) umount.WaitWithDefaultTimeout() diff --git a/test/e2e/play_kube_test.go b/test/e2e/play_kube_test.go index af3cab379..5d59f0eb0 100644 --- a/test/e2e/play_kube_test.go +++ b/test/e2e/play_kube_test.go @@ -40,6 +40,7 @@ spec: image: {{ .Image }} name: {{ .Name }} resources: {} + {{ if .SecurityContext }} securityContext: allowPrivilegeEscalation: true {{ if .Caps }} @@ -60,6 +61,7 @@ spec: privileged: false readOnlyRootFilesystem: false workingDir: / + {{ end }} {{ end }} {{ end }} status: {} @@ -72,12 +74,13 @@ type Pod struct { } type Container struct { - Cmd []string - Image string - Name string - Caps bool - CapAdd []string - CapDrop []string + Cmd []string + Image string + Name string + SecurityContext bool + Caps bool + CapAdd []string + CapDrop []string } func generateKubeYaml(name string, hostname string, ctrs []Container, fileName string) error { @@ -126,7 +129,7 @@ var _ = Describe("Podman generate kube", func() { It("podman play kube test correct command", func() { ctrName := "testCtr" ctrCmd := []string{"top"} - testContainer := Container{ctrCmd, ALPINE, ctrName, false, nil, nil} + testContainer := Container{ctrCmd, ALPINE, ctrName, true, false, nil, nil} tempFile := filepath.Join(podmanTest.TempDir, "kube.yaml") err := generateKubeYaml("test", "", []Container{testContainer}, tempFile) @@ -145,7 +148,7 @@ var _ = Describe("Podman generate kube", func() { It("podman play kube test correct output", func() { ctrName := "testCtr" ctrCmd := []string{"echo", "hello"} - testContainer := Container{ctrCmd, ALPINE, ctrName, false, nil, nil} + testContainer := Container{ctrCmd, ALPINE, ctrName, true, false, nil, nil} tempFile := filepath.Join(podmanTest.TempDir, "kube.yaml") err := generateKubeYaml("test", "", []Container{testContainer}, tempFile) @@ -170,7 +173,7 @@ var _ = Describe("Podman generate kube", func() { podName := "test" ctrName := "testCtr" ctrCmd := []string{"top"} - testContainer := Container{ctrCmd, ALPINE, ctrName, false, nil, nil} + testContainer := Container{ctrCmd, ALPINE, ctrName, true, false, nil, nil} tempFile := filepath.Join(podmanTest.TempDir, "kube.yaml") err := generateKubeYaml(podName, "", []Container{testContainer}, tempFile) @@ -190,7 +193,7 @@ var _ = Describe("Podman generate kube", func() { hostname := "myhostname" ctrName := "testCtr" ctrCmd := []string{"top"} - testContainer := Container{ctrCmd, ALPINE, ctrName, false, nil, nil} + testContainer := Container{ctrCmd, ALPINE, ctrName, true, false, nil, nil} tempFile := filepath.Join(podmanTest.TempDir, "kube.yaml") err := generateKubeYaml("test", hostname, []Container{testContainer}, tempFile) @@ -210,7 +213,7 @@ var _ = Describe("Podman generate kube", func() { ctrName := "testCtr" ctrCmd := []string{"cat", "/proc/self/status"} capAdd := "CAP_SYS_ADMIN" - testContainer := Container{ctrCmd, ALPINE, ctrName, true, []string{capAdd}, nil} + testContainer := Container{ctrCmd, ALPINE, ctrName, true, true, []string{capAdd}, nil} tempFile := filepath.Join(podmanTest.TempDir, "kube.yaml") err := generateKubeYaml("test", "", []Container{testContainer}, tempFile) @@ -230,7 +233,7 @@ var _ = Describe("Podman generate kube", func() { ctrName := "testCtr" ctrCmd := []string{"cat", "/proc/self/status"} capDrop := "CAP_SYS_ADMIN" - testContainer := Container{ctrCmd, ALPINE, ctrName, true, []string{capDrop}, nil} + testContainer := Container{ctrCmd, ALPINE, ctrName, true, true, []string{capDrop}, nil} tempFile := filepath.Join(podmanTest.TempDir, "kube.yaml") err := generateKubeYaml("test", "", []Container{testContainer}, tempFile) @@ -245,4 +248,23 @@ var _ = Describe("Podman generate kube", func() { Expect(inspect.ExitCode()).To(Equal(0)) Expect(inspect.OutputToString()).To(ContainSubstring(capDrop)) }) + + It("podman play kube no security context", func() { + // expect play kube to not fail if no security context is specified + ctrName := "testCtr" + ctrCmd := "ls" + testContainer := Container{[]string{ctrCmd}, ALPINE, ctrName, false, false, nil, nil} + tempFile := filepath.Join(podmanTest.TempDir, "kube.yaml") + + err := generateKubeYaml("test", "", []Container{testContainer}, tempFile) + Expect(err).To(BeNil()) + + kube := podmanTest.Podman([]string{"play", "kube", tempFile}) + kube.WaitWithDefaultTimeout() + Expect(kube.ExitCode()).To(Equal(0)) + + inspect := podmanTest.Podman([]string{"inspect", ctrName}) + inspect.WaitWithDefaultTimeout() + Expect(inspect.ExitCode()).To(Equal(0)) + }) }) diff --git a/test/e2e/port_test.go b/test/e2e/port_test.go index b15d8e133..53fc33a01 100644 --- a/test/e2e/port_test.go +++ b/test/e2e/port_test.go @@ -135,12 +135,12 @@ var _ = Describe("Podman port", func() { result1 := podmanTest.Podman([]string{"port", "-l", "5000"}) result1.WaitWithDefaultTimeout() Expect(result1.ExitCode()).To(BeZero()) - Expect(result1.LineInOuputStartsWith("0.0.0.0:5000")) + Expect(result1.LineInOuputStartsWith("0.0.0.0:5000")).To(BeTrue()) // Check that the second port was honored result2 := podmanTest.Podman([]string{"port", "-l", "5001"}) result2.WaitWithDefaultTimeout() Expect(result2.ExitCode()).To(BeZero()) - Expect(result2.LineInOuputStartsWith("0.0.0.0:5001")) + Expect(result2.LineInOuputStartsWith("0.0.0.0:5001")).To(BeTrue()) }) }) diff --git a/test/e2e/rmi_test.go b/test/e2e/rmi_test.go index d4e2407ec..506adee7e 100644 --- a/test/e2e/rmi_test.go +++ b/test/e2e/rmi_test.go @@ -282,6 +282,7 @@ RUN find $LOCAL session := podmanTest.PodmanNoCache([]string{"image", "rm"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(125)) - Expect(session.LineInOutputContains("image name or ID must be specified")) + match, _ := session.ErrorGrepString("image name or ID must be specified") + Expect(match).To(BeTrue()) }) }) diff --git a/test/e2e/run_cpu_test.go b/test/e2e/run_cpu_test.go index 4be9da3d2..42f17985c 100644 --- a/test/e2e/run_cpu_test.go +++ b/test/e2e/run_cpu_test.go @@ -60,7 +60,7 @@ var _ = Describe("Podman run cpu", func() { } result.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(0)) - Expect(result.LineInOutputContains("5000")) + Expect(result.LineInOutputContains("5000")).To(BeTrue()) }) It("podman run cpu-quota", func() { @@ -78,7 +78,7 @@ var _ = Describe("Podman run cpu", func() { } result.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(0)) - Expect(result.LineInOutputContains("5000")) + Expect(result.LineInOutputContains("5000")).To(BeTrue()) }) It("podman run cpus", func() { 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))) + }) }) |