summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2018-12-11 16:10:35 -0600
committerbaude <bbaude@redhat.com>2018-12-12 10:55:53 -0600
commit9786542620afea96d5eee2d05b7e1dec38a8235d (patch)
tree092e40048677955efe9a1e0d99c69c332d153726 /test
parent8645df84dbb21f5988b46e6646bb0dd04fdb2b51 (diff)
downloadpodman-9786542620afea96d5eee2d05b7e1dec38a8235d.tar.gz
podman-9786542620afea96d5eee2d05b7e1dec38a8235d.tar.bz2
podman-9786542620afea96d5eee2d05b7e1dec38a8235d.zip
failed containers with --rm should remove themselves
when starting or running a container that has --rm, if the starting container fails (like due to an invalid command), the container should get removed. Resolves: #1985 Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'test')
-rw-r--r--test/e2e/run_test.go27
-rw-r--r--test/e2e/start_test.go26
2 files changed, 53 insertions, 0 deletions
diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go
index 4a9bd4e46..2104991b2 100644
--- a/test/e2e/run_test.go
+++ b/test/e2e/run_test.go
@@ -639,4 +639,31 @@ USER mail`
match, _ := check.GrepString("foobar")
Expect(match).To(BeTrue())
})
+
+ It("podman run --rm should work", func() {
+ session := podmanTest.Podman([]string{"run", "--rm", ALPINE, "ls"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ numContainers := podmanTest.NumberOfContainers()
+ Expect(numContainers).To(Equal(0))
+ })
+
+ It("podman run --rm failed container should delete itself", func() {
+ session := podmanTest.Podman([]string{"run", "--rm", ALPINE, "foo"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Not(Equal(0)))
+
+ numContainers := podmanTest.NumberOfContainers()
+ Expect(numContainers).To(Equal(0))
+ })
+
+ It("podman run failed container should NOT delete itself", func() {
+ session := podmanTest.Podman([]string{"run", ALPINE, "foo"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Not(Equal(0)))
+
+ numContainers := podmanTest.NumberOfContainers()
+ Expect(numContainers).To(Equal(1))
+ })
})
diff --git a/test/e2e/start_test.go b/test/e2e/start_test.go
index c11511d1f..64245c609 100644
--- a/test/e2e/start_test.go
+++ b/test/e2e/start_test.go
@@ -89,4 +89,30 @@ var _ = Describe("Podman start", func() {
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(125))
})
+
+ It("podman failed to start with --rm should delete the container", func() {
+ session := podmanTest.Podman([]string{"create", "-it", "--rm", ALPINE, "foo"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ start := podmanTest.Podman([]string{"start", "-l"})
+ start.WaitWithDefaultTimeout()
+ Expect(start.ExitCode()).To(Not(Equal(0)))
+
+ numContainers := podmanTest.NumberOfContainers()
+ Expect(numContainers).To(BeZero())
+ })
+
+ It("podman failed to start without --rm should NOT delete the container", func() {
+ session := podmanTest.Podman([]string{"create", "-it", ALPINE, "foo"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ start := podmanTest.Podman([]string{"start", "-l"})
+ start.WaitWithDefaultTimeout()
+ Expect(start.ExitCode()).To(Not(Equal(0)))
+
+ numContainers := podmanTest.NumberOfContainers()
+ Expect(numContainers).To(Equal(1))
+ })
})