summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2020-01-09 12:27:24 +0100
committerValentin Rothberg <rothberg@redhat.com>2020-01-09 16:12:12 +0100
commit816e50ba02837946afade83e3cad06dd44d213ec (patch)
tree67834eb73ab890cb4c9fba8d37f68e3fdec9dcd6 /test
parentf3fc10feb42930def6922fc050096ea38bafed7a (diff)
downloadpodman-816e50ba02837946afade83e3cad06dd44d213ec.tar.gz
podman-816e50ba02837946afade83e3cad06dd44d213ec.tar.bz2
podman-816e50ba02837946afade83e3cad06dd44d213ec.zip
podman-generate-systemd --new
Add a --new flag to podman-generate-systemd to create a new container via podman-run instead of starting an existing container. Creating a new container presents the challenge to find a reverse mapping from a container to the CLI flags it can be created with. We are doing this via `(Container).Config.CreateCommand` field, which includes a copy of the process' command from procFS at creating time. This field may not be useful when the container was not created via the Podman CLI (e.g., via a Python script). Hence, we do not guarantee the correctness of the generated files. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'test')
-rw-r--r--test/e2e/generate_systemd_test.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/e2e/generate_systemd_test.go b/test/e2e/generate_systemd_test.go
index 91072b023..f0fef41a4 100644
--- a/test/e2e/generate_systemd_test.go
+++ b/test/e2e/generate_systemd_test.go
@@ -177,4 +177,32 @@ var _ = Describe("Podman generate systemd", func() {
found, _ = session.GrepString("/container-foo-1.service")
Expect(found).To(BeTrue())
})
+
+ It("podman generate systemd --new", func() {
+ n := podmanTest.Podman([]string{"create", "--name", "foo", "alpine", "top"})
+ n.WaitWithDefaultTimeout()
+ Expect(n.ExitCode()).To(Equal(0))
+
+ session := podmanTest.Podman([]string{"generate", "systemd", "--timeout", "42", "--name", "--new", "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())
+
+ found, _ = session.GrepString("stop --cidfile /%t/%n-cid -t 42")
+ Expect(found).To(BeTrue())
+ })
+
+ It("podman generate systemd --new pod", func() {
+ n := podmanTest.Podman([]string{"pod", "create", "--name", "foo"})
+ n.WaitWithDefaultTimeout()
+ Expect(n.ExitCode()).To(Equal(0))
+
+ session := podmanTest.Podman([]string{"generate", "systemd", "--timeout", "42", "--name", "--new", "foo"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(125))
+ })
+
})