summaryrefslogtreecommitdiff
path: root/test/e2e
diff options
context:
space:
mode:
authorDebarshi Ray <rishi@fedoraproject.org>2019-03-13 20:19:31 +0100
committerDebarshi Ray <rishi@fedoraproject.org>2019-03-15 18:28:47 +0100
commit082d792693504848e186a29db717ce20c7ff7774 (patch)
treed552982bc6501d6f3d74d9d7e244f5663aefd268 /test/e2e
parent8aed32acea9bb35898abcee58fc9aa2a03ef264a (diff)
downloadpodman-082d792693504848e186a29db717ce20c7ff7774.tar.gz
podman-082d792693504848e186a29db717ce20c7ff7774.tar.bz2
podman-082d792693504848e186a29db717ce20c7ff7774.zip
Make 'podman rm' exit with 125 if it had a bogus & a running container
Getting a list of containers, and then deleting them are two separate fallible steps that can run into different sets of errors. eg., in the case of a bogus missing container and a container that's running or paused, the first step will only trigger libpod.ErrNoSuchCtr. At this point it might appear that the exit code ought to be 1. However, when attempting the deletion, it will fail once more due to the status of the running or paused container. Since libpod.ErrNoSuchCtr is no longer the only error encountered, the exit code should be reset to 125. This problem is currently masked for rootless usage due to commit 35432ecaae4a8372 ("rootless: fix rm when uid in the container != 0"). Fixes: 85db895012bead6b ("rm: set exit code to 1 if a specified ...") e41279b902a334e5 ("Change exit code to 1 on podman rm ...") Signed-off-by: Debarshi Ray <rishi@fedoraproject.org>
Diffstat (limited to 'test/e2e')
-rw-r--r--test/e2e/rm_test.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/e2e/rm_test.go b/test/e2e/rm_test.go
index 1f67780da..9bf742a63 100644
--- a/test/e2e/rm_test.go
+++ b/test/e2e/rm_test.go
@@ -139,9 +139,23 @@ var _ = Describe("Podman rm", func() {
Expect(podmanTest.NumberOfContainers()).To(Equal(1))
})
+
It("podman rm bogus container", func() {
session := podmanTest.Podman([]string{"rm", "bogus"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(1))
})
+ It("podman rm bogus container and a running container", func() {
+ session := podmanTest.RunTopContainer("test1")
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"rm", "bogus", "test1"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(125))
+
+ session = podmanTest.Podman([]string{"rm", "test1", "bogus"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(125))
+ })
})