summaryrefslogtreecommitdiff
path: root/test/e2e
diff options
context:
space:
mode:
authorLuap99 <paul.holzinger@web.de>2020-05-21 17:36:41 +0200
committerLuap99 <paul.holzinger@web.de>2020-05-22 18:38:39 +0200
commite704f1362abc416786076a932d8e2ca930b9fa2e (patch)
tree97fe00322c0fc8023451ff5334b9867924712d5f /test/e2e
parent72e880351a88ae54b69046ab14a9a4a52c51c78b (diff)
downloadpodman-e704f1362abc416786076a932d8e2ca930b9fa2e.tar.gz
podman-e704f1362abc416786076a932d8e2ca930b9fa2e.tar.bz2
podman-e704f1362abc416786076a932d8e2ca930b9fa2e.zip
Added new flags to 'podman generate systemd' to change the unit name prefix
--container-prefix <string> - default 'container' Systemd unit name prefix for containers --pod-prefix <string> - default 'pod' Systemd unit name prefix for pods --separator <string> - default '-' Systemd unit name seperator between name/id and prefix Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
Diffstat (limited to 'test/e2e')
-rw-r--r--test/e2e/generate_systemd_test.go92
1 files changed, 92 insertions, 0 deletions
diff --git a/test/e2e/generate_systemd_test.go b/test/e2e/generate_systemd_test.go
index abfca4db9..d5ae441e2 100644
--- a/test/e2e/generate_systemd_test.go
+++ b/test/e2e/generate_systemd_test.go
@@ -233,4 +233,96 @@ var _ = Describe("Podman generate systemd", func() {
Expect(session.ExitCode()).To(Equal(125))
})
+ It("podman generate systemd --container-prefix con", func() {
+ n := podmanTest.Podman([]string{"create", "--name", "foo", "alpine", "top"})
+ n.WaitWithDefaultTimeout()
+ Expect(n.ExitCode()).To(Equal(0))
+
+ session := podmanTest.Podman([]string{"generate", "systemd", "--name", "--container-prefix", "con", "foo"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ // Grepping the output (in addition to unit tests)
+ found, _ := session.GrepString("# con-foo.service")
+ Expect(found).To(BeTrue())
+ })
+
+ It("podman generate systemd --separator _", func() {
+ n := podmanTest.Podman([]string{"create", "--name", "foo", "alpine", "top"})
+ n.WaitWithDefaultTimeout()
+ Expect(n.ExitCode()).To(Equal(0))
+
+ session := podmanTest.Podman([]string{"generate", "systemd", "--name", "--separator", "_", "foo"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ // Grepping the output (in addition to unit tests)
+ found, _ := session.GrepString("# container_foo.service")
+ Expect(found).To(BeTrue())
+ })
+
+ It("podman generate systemd pod --pod-prefix p", 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", "--pod-prefix", "p", "--name", "foo"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ // Grepping the output (in addition to unit tests)
+ found, _ := session.GrepString("# p-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("BindsTo=p-foo.service")
+ Expect(found).To(BeTrue())
+ })
+
+ It("podman generate systemd pod --pod-prefix p --container-prefix con --separator _ change all prefixes/separator", 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", "--container-prefix", "con", "--pod-prefix", "p", "--separator", "_", "--name", "foo"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ // Grepping the output (in addition to unit tests)
+ found, _ := session.GrepString("# p_foo.service")
+ Expect(found).To(BeTrue())
+
+ found, _ = session.GrepString("Requires=con_foo-1.service con_foo-2.service")
+ Expect(found).To(BeTrue())
+
+ found, _ = session.GrepString("# con_foo-1.service")
+ Expect(found).To(BeTrue())
+
+ found, _ = session.GrepString("# con_foo-2.service")
+ Expect(found).To(BeTrue())
+
+ found, _ = session.GrepString("BindsTo=p_foo.service")
+ Expect(found).To(BeTrue())
+ })
})