From 8d7dc94a2773cc3ad9a36f3318f987ccee097666 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Thu, 15 Mar 2018 11:03:30 -0400 Subject: Add extra E2E test for restarting containers Signed-off-by: Matthew Heon Closes: #482 Approved by: baude --- test/e2e/libpod_suite_test.go | 12 ++++++++++++ test/e2e/run_restart_test.go | 14 ++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/test/e2e/libpod_suite_test.go b/test/e2e/libpod_suite_test.go index 10247f428..4d4f2905c 100644 --- a/test/e2e/libpod_suite_test.go +++ b/test/e2e/libpod_suite_test.go @@ -166,6 +166,18 @@ func (p *PodmanTest) Podman(args []string) *PodmanSession { return &PodmanSession{session} } + +//WaitForContainer waits on a started container +func WaitForContainer(p *PodmanTest) bool { + for i := 0; i < 10; i++ { + if p.NumberOfContainers() == 1 { + return true + } + time.Sleep(1 * time.Second) + } + return false +} + // Cleanup cleans up the temporary store func (p *PodmanTest) Cleanup() { // Remove all containers diff --git a/test/e2e/run_restart_test.go b/test/e2e/run_restart_test.go index 8737cf4f8..c55dfa1d3 100644 --- a/test/e2e/run_restart_test.go +++ b/test/e2e/run_restart_test.go @@ -36,4 +36,18 @@ var _ = Describe("Podman run restart containers", func() { session2.WaitWithDefaultTimeout() Expect(session2.ExitCode()).To(Equal(0)) }) + + It("Podman start after signal kill", func() { + session := podmanTest.RunTopContainer("test1") + ok := WaitForContainer(&podmanTest) + Expect(ok).To(BeTrue()) + + killSession := podmanTest.Podman([]string{"kill", "-s", "9", "test1"}) + killSession.WaitWithDefaultTimeout() + Expect(killSession.ExitCode()).To(Equal(0)) + + session2 := podmanTest.Podman([]string{"start", "--attach", "test1"}) + session2.WaitWithDefaultTimeout() + Expect(session2.ExitCode()).To(Equal(0)) + }) }) -- cgit v1.2.3-54-g00ecf