From 597b2ebfeaeb1c2aec6790d5e3351a8889e2dc46 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Tue, 23 Apr 2019 13:11:35 -0400 Subject: Enhance tests for stop to check results None of the stop tests actually verified that containers were in a stopped state after they finished. We shouldn't take a 0 exit code to indicate that things worked - verify that ps shows no running containers. Signed-off-by: Matthew Heon --- test/e2e/stop_test.go | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/test/e2e/stop_test.go b/test/e2e/stop_test.go index 61c3fedfd..259410736 100644 --- a/test/e2e/stop_test.go +++ b/test/e2e/stop_test.go @@ -48,6 +48,11 @@ var _ = Describe("Podman stop", func() { session = podmanTest.Podman([]string{"stop", cid}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) + + finalCtrs := podmanTest.Podman([]string("ps", "-q")) + finalCtrs.WaitWithDefaultTimeout() + Expect(finalCtrs.ExitCode()).To(Equal(0)) + Expect(finalCtrs.OutputToString()).To(Equal("")) }) It("podman stop container by name", func() { @@ -57,15 +62,25 @@ var _ = Describe("Podman stop", func() { session = podmanTest.Podman([]string{"stop", "test1"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) + + finalCtrs := podmanTest.Podman([]string("ps", "-q")) + finalCtrs.WaitWithDefaultTimeout() + Expect(finalCtrs.ExitCode()).To(Equal(0)) + Expect(finalCtrs.OutputToString()).To(Equal("")) }) - It("podman stop container by name", func() { + It("podman container stop by name", func() { session := podmanTest.RunTopContainer("test1") session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) session = podmanTest.Podman([]string{"container", "stop", "test1"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) + + finalCtrs := podmanTest.Podman([]string("ps", "-q")) + finalCtrs.WaitWithDefaultTimeout() + Expect(finalCtrs.ExitCode()).To(Equal(0)) + Expect(finalCtrs.OutputToString()).To(Equal("")) }) It("podman stop stopped container", func() { @@ -80,6 +95,11 @@ var _ = Describe("Podman stop", func() { session3 := podmanTest.Podman([]string{"stop", "test1"}) session3.WaitWithDefaultTimeout() Expect(session3.ExitCode()).To(Equal(0)) + + finalCtrs := podmanTest.Podman([]string("ps", "-q")) + finalCtrs.WaitWithDefaultTimeout() + Expect(finalCtrs.ExitCode()).To(Equal(0)) + Expect(finalCtrs.OutputToString()).To(Equal("")) }) It("podman stop all containers -t", func() { @@ -105,6 +125,11 @@ var _ = Describe("Podman stop", func() { Expect(output).To(ContainSubstring(cid1)) Expect(output).To(ContainSubstring(cid2)) Expect(output).To(ContainSubstring(cid3)) + + finalCtrs := podmanTest.Podman([]string("ps", "-q")) + finalCtrs.WaitWithDefaultTimeout() + Expect(finalCtrs.ExitCode()).To(Equal(0)) + Expect(finalCtrs.OutputToString()).To(Equal("")) }) It("podman stop container --time", func() { @@ -118,6 +143,11 @@ var _ = Describe("Podman stop", func() { Expect(session.ExitCode()).To(Equal(0)) output := session.OutputToString() Expect(output).To(ContainSubstring(cid1)) + + finalCtrs := podmanTest.Podman([]string("ps", "-q")) + finalCtrs.WaitWithDefaultTimeout() + Expect(finalCtrs.ExitCode()).To(Equal(0)) + Expect(finalCtrs.OutputToString()).To(Equal("")) }) It("podman stop container --timeout", func() { @@ -131,6 +161,11 @@ var _ = Describe("Podman stop", func() { Expect(session.ExitCode()).To(Equal(0)) output := session.OutputToString() Expect(output).To(ContainSubstring(cid1)) + + finalCtrs := podmanTest.Podman([]string("ps", "-q")) + finalCtrs.WaitWithDefaultTimeout() + Expect(finalCtrs.ExitCode()).To(Equal(0)) + Expect(finalCtrs.OutputToString()).To(Equal("")) }) It("podman stop latest containers", func() { @@ -140,6 +175,10 @@ var _ = Describe("Podman stop", func() { session = podmanTest.Podman([]string{"stop", "-l", "-t", "1"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) + finalCtrs := podmanTest.Podman([]string("ps", "-q")) + finalCtrs.WaitWithDefaultTimeout() + Expect(finalCtrs.ExitCode()).To(Equal(0)) + Expect(finalCtrs.OutputToString()).To(Equal("")) }) It("podman stop all containers with one stopped", func() { -- cgit v1.2.3-54-g00ecf