summaryrefslogtreecommitdiff
path: root/test/e2e
diff options
context:
space:
mode:
authoresendjer <esendjer@gmail.com>2022-01-19 14:56:37 +0500
committeresendjer <esendjer@gmail.com>2022-01-19 21:46:16 +0500
commitb9a2d8698a22c4b267e252caad56d8b31fcadd38 (patch)
treef5506687b939bdc29e2324b1335d3f9c4632f340 /test/e2e
parent094b11cbcb528a7d120c31402a1bcd9c82d84938 (diff)
downloadpodman-b9a2d8698a22c4b267e252caad56d8b31fcadd38.tar.gz
podman-b9a2d8698a22c4b267e252caad56d8b31fcadd38.tar.bz2
podman-b9a2d8698a22c4b267e252caad56d8b31fcadd38.zip
Handlers for `generate systemd` with custom dependencies
This commit includes: * Handlers for generate systemd unit with manually defined dependencies such as: Wants=, After= and Requires= * The new unit and e2e tests for checking generated systemd units for container and pod with custom dependencies * Documented descriptions for custom dependencies options Signed-off-by: Eugene (Evgenii) Shubin <esendjer@gmail.com>
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 976048886..55b9a8037 100644
--- a/test/e2e/generate_systemd_test.go
+++ b/test/e2e/generate_systemd_test.go
@@ -159,6 +159,50 @@ var _ = Describe("Podman generate systemd", func() {
Expect(session.OutputToString()).To(ContainSubstring("podman stop -t 5"))
})
+ It("podman generate systemd with user-defined dependencies", func() {
+ n := podmanTest.Podman([]string{"run", "--name", "nginx", "-dt", nginx})
+ n.WaitWithDefaultTimeout()
+ Expect(n).Should(Exit(0))
+
+ session := podmanTest.Podman([]string{"generate", "systemd", "--wants", "foobar.service", "nginx"})
+ session.WaitWithDefaultTimeout()
+ Expect(session).Should(Exit(0))
+
+ // The generated systemd unit should contain the User-defined Wants option
+ Expect(session.OutputToString()).To(ContainSubstring("# User-defined dependencies"))
+ Expect(session.OutputToString()).To(ContainSubstring("Wants=foobar.service"))
+
+ session = podmanTest.Podman([]string{"generate", "systemd", "--after", "foobar.service", "nginx"})
+ session.WaitWithDefaultTimeout()
+ Expect(session).Should(Exit(0))
+
+ // The generated systemd unit should contain the User-defined After option
+ Expect(session.OutputToString()).To(ContainSubstring("# User-defined dependencies"))
+ Expect(session.OutputToString()).To(ContainSubstring("After=foobar.service"))
+
+ session = podmanTest.Podman([]string{"generate", "systemd", "--requires", "foobar.service", "nginx"})
+ session.WaitWithDefaultTimeout()
+ Expect(session).Should(Exit(0))
+
+ // The generated systemd unit should contain the User-defined Requires option
+ Expect(session.OutputToString()).To(ContainSubstring("# User-defined dependencies"))
+ Expect(session.OutputToString()).To(ContainSubstring("Requires=foobar.service"))
+
+ session = podmanTest.Podman([]string{
+ "generate", "systemd",
+ "--wants", "foobar.service", "--wants", "barfoo.service",
+ "--after", "foobar.service", "--after", "barfoo.service",
+ "--requires", "foobar.service", "--requires", "barfoo.service", "nginx"})
+ session.WaitWithDefaultTimeout()
+ Expect(session).Should(Exit(0))
+
+ // The generated systemd unit should contain the User-defined Want, After, Requires options
+ Expect(session.OutputToString()).To(ContainSubstring("# User-defined dependencies"))
+ Expect(session.OutputToString()).To(ContainSubstring("Wants=foobar.service barfoo.service"))
+ Expect(session.OutputToString()).To(ContainSubstring("After=foobar.service barfoo.service"))
+ Expect(session.OutputToString()).To(ContainSubstring("Requires=foobar.service barfoo.service"))
+ })
+
It("podman generate systemd pod --name", func() {
n := podmanTest.Podman([]string{"pod", "create", "--name", "foo"})
n.WaitWithDefaultTimeout()
@@ -213,6 +257,54 @@ var _ = Describe("Podman generate systemd", func() {
Expect(session.OutputToString()).To(ContainSubstring("/container-foo-1.service"))
})
+ It("podman generate systemd pod with user-defined dependencies", func() {
+ n := podmanTest.Podman([]string{"pod", "create", "--name", "foo"})
+ n.WaitWithDefaultTimeout()
+ Expect(n).Should(Exit(0))
+
+ n = podmanTest.Podman([]string{"create", "--pod", "foo", "--name", "foo-1", "alpine", "top"})
+ n.WaitWithDefaultTimeout()
+ Expect(n).Should(Exit(0))
+
+ session := podmanTest.Podman([]string{"generate", "systemd", "--name", "--wants", "foobar.service", "foo"})
+ session.WaitWithDefaultTimeout()
+ Expect(session).Should(Exit(0))
+
+ // The generated systemd unit should contain the User-defined Wants option
+ Expect(session.OutputToString()).To(ContainSubstring("# User-defined dependencies"))
+ Expect(session.OutputToString()).To(ContainSubstring("Wants=foobar.service"))
+
+ session = podmanTest.Podman([]string{"generate", "systemd", "--name", "--after", "foobar.service", "foo"})
+ session.WaitWithDefaultTimeout()
+ Expect(session).Should(Exit(0))
+
+ // The generated systemd unit should contain the User-defined After option
+ Expect(session.OutputToString()).To(ContainSubstring("# User-defined dependencies"))
+ Expect(session.OutputToString()).To(ContainSubstring("After=foobar.service"))
+
+ session = podmanTest.Podman([]string{"generate", "systemd", "--name", "--requires", "foobar.service", "foo"})
+ session.WaitWithDefaultTimeout()
+ Expect(session).Should(Exit(0))
+
+ // The generated systemd unit should contain the User-defined Requires option
+ Expect(session.OutputToString()).To(ContainSubstring("# User-defined dependencies"))
+ Expect(session.OutputToString()).To(ContainSubstring("Requires=foobar.service"))
+
+ session = podmanTest.Podman([]string{
+ "generate", "systemd", "--name",
+ "--wants", "foobar.service", "--wants", "barfoo.service",
+ "--after", "foobar.service", "--after", "barfoo.service",
+ "--requires", "foobar.service", "--requires", "barfoo.service", "foo"})
+ session.WaitWithDefaultTimeout()
+ Expect(session).Should(Exit(0))
+
+ // The generated systemd unit should contain the User-defined Want, After, Requires options
+ Expect(session.OutputToString()).To(ContainSubstring("# User-defined dependencies"))
+ Expect(session.OutputToString()).To(ContainSubstring("Wants=foobar.service barfoo.service"))
+ Expect(session.OutputToString()).To(ContainSubstring("After=foobar.service barfoo.service"))
+ Expect(session.OutputToString()).To(ContainSubstring("Requires=foobar.service barfoo.service"))
+ })
+
It("podman generate systemd --new --name foo", func() {
n := podmanTest.Podman([]string{"create", "--name", "foo", "alpine", "top"})
n.WaitWithDefaultTimeout()