summaryrefslogtreecommitdiff
path: root/test/e2e
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-08-22 19:08:08 +0200
committerGitHub <noreply@github.com>2019-08-22 19:08:08 +0200
commitb263dd9e81bcadd3be5c7420fca9e53ecc8aef7c (patch)
treea88e48dfe6c6893d793c2f35318907fe9418b1c4 /test/e2e
parent34002f92ffa2c71c3f5190b6b73617f14652d674 (diff)
parent56a65cffac2cee3132c950d49ea8a5b46eabbff1 (diff)
downloadpodman-b263dd9e81bcadd3be5c7420fca9e53ecc8aef7c.tar.gz
podman-b263dd9e81bcadd3be5c7420fca9e53ecc8aef7c.tar.bz2
podman-b263dd9e81bcadd3be5c7420fca9e53ecc8aef7c.zip
Merge pull request #3800 from vrothberg/generate-pod
generate systemd pod
Diffstat (limited to 'test/e2e')
-rw-r--r--test/e2e/generate_systemd_test.go110
1 files changed, 108 insertions, 2 deletions
diff --git a/test/e2e/generate_systemd_test.go b/test/e2e/generate_systemd_test.go
index 5bb040206..314743a92 100644
--- a/test/e2e/generate_systemd_test.go
+++ b/test/e2e/generate_systemd_test.go
@@ -3,10 +3,11 @@
package integration
import (
+ "os"
+
. "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
- "os"
)
var _ = Describe("Podman generate systemd", func() {
@@ -33,7 +34,7 @@ var _ = Describe("Podman generate systemd", func() {
})
- It("podman generate systemd on bogus container", func() {
+ It("podman generate systemd on bogus container/pod", func() {
session := podmanTest.Podman([]string{"generate", "systemd", "foobar"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Not(Equal(0)))
@@ -51,6 +52,19 @@ var _ = Describe("Podman generate systemd", func() {
Expect(session.ExitCode()).To(Not(Equal(0)))
})
+ It("podman generate systemd good timeout value", func() {
+ session := podmanTest.Podman([]string{"create", "--name", "foobar", "alpine", "top"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"generate", "systemd", "--timeout", "1234", "foobar"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ found, _ := session.GrepString(" stop -t 1234 ")
+ Expect(found).To(BeTrue())
+ })
+
It("podman generate systemd", func() {
n := podmanTest.Podman([]string{"run", "--name", "nginx", "-dt", nginx})
n.WaitWithDefaultTimeout()
@@ -61,6 +75,23 @@ var _ = Describe("Podman generate systemd", func() {
Expect(session.ExitCode()).To(Equal(0))
})
+ It("podman generate systemd --files --name", func() {
+ n := podmanTest.Podman([]string{"run", "--name", "nginx", "-dt", nginx})
+ n.WaitWithDefaultTimeout()
+ Expect(n.ExitCode()).To(Equal(0))
+
+ session := podmanTest.Podman([]string{"generate", "systemd", "--files", "--name", "nginx"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ for _, file := range session.OutputToStringArray() {
+ os.Remove(file)
+ }
+
+ found, _ := session.GrepString("/container-nginx.service")
+ Expect(found).To(BeTrue())
+ })
+
It("podman generate systemd with timeout", func() {
n := podmanTest.Podman([]string{"run", "--name", "nginx", "-dt", nginx})
n.WaitWithDefaultTimeout()
@@ -69,6 +100,81 @@ var _ = Describe("Podman generate systemd", func() {
session := podmanTest.Podman([]string{"generate", "systemd", "--timeout", "5", "nginx"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
+
+ found, _ := session.GrepString("podman stop -t 5")
+ Expect(found).To(BeTrue())
})
+ It("podman generate systemd pod --name", func() {
+ n := podmanTest.Podman([]string{"pod", "create", "--name", "foo"})
+ n.WaitWithDefaultTimeout()
+ Expect(n.ExitCode()).To(Equal(0))
+
+ n = podmanTest.Podman([]string{"create", "--pod", "foo", "--name", "foo-1", "alpine", "top"})
+ n.WaitWithDefaultTimeout()
+ Expect(n.ExitCode()).To(Equal(0))
+
+ n = podmanTest.Podman([]string{"create", "--pod", "foo", "--name", "foo-2", "alpine", "top"})
+ n.WaitWithDefaultTimeout()
+ Expect(n.ExitCode()).To(Equal(0))
+
+ session := podmanTest.Podman([]string{"generate", "systemd", "--timeout", "42", "--name", "foo"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ // Grepping the output (in addition to unit tests)
+ found, _ := session.GrepString("# pod-foo.service")
+ Expect(found).To(BeTrue())
+
+ found, _ = session.GrepString("Requires=container-foo-1.service container-foo-2.service")
+ Expect(found).To(BeTrue())
+
+ found, _ = session.GrepString("# container-foo-1.service")
+ Expect(found).To(BeTrue())
+
+ found, _ = session.GrepString(" start foo-1")
+ Expect(found).To(BeTrue())
+
+ found, _ = session.GrepString("-infra") // infra container
+ Expect(found).To(BeTrue())
+
+ found, _ = session.GrepString("# container-foo-2.service")
+ Expect(found).To(BeTrue())
+
+ found, _ = session.GrepString(" stop -t 42 foo-2")
+ Expect(found).To(BeTrue())
+
+ found, _ = session.GrepString("BindsTo=pod-foo.service")
+ Expect(found).To(BeTrue())
+
+ found, _ = session.GrepString("PIDFile=")
+ Expect(found).To(BeTrue())
+
+ found, _ = session.GrepString("/userdata/conmon.pid")
+ Expect(found).To(BeTrue())
+ })
+
+ It("podman generate systemd pod --name --files", func() {
+ n := podmanTest.Podman([]string{"pod", "create", "--name", "foo"})
+ n.WaitWithDefaultTimeout()
+ Expect(n.ExitCode()).To(Equal(0))
+
+ n = podmanTest.Podman([]string{"create", "--pod", "foo", "--name", "foo-1", "alpine", "top"})
+ n.WaitWithDefaultTimeout()
+ Expect(n.ExitCode()).To(Equal(0))
+
+ session := podmanTest.Podman([]string{"generate", "systemd", "--name", "--files", "foo"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ for _, file := range session.OutputToStringArray() {
+ os.Remove(file)
+ }
+
+ found, _ := session.GrepString("/pod-foo.service")
+ Expect(found).To(BeTrue())
+
+ found, _ = session.GrepString("/container-foo-1.service")
+ Expect(found).To(BeTrue())
+ })
})