From 78dd4f2ecb9f85fda87e581b9b2800618223154f Mon Sep 17 00:00:00 2001 From: jgallucci32 Date: Sat, 20 Jun 2020 09:45:18 -0700 Subject: Stop following logs using timers This incorporates code from PR #6591 and #6614 but does not use event channels to detect container state and rather uses timers with a defined wait duration before calling t.StopAtEOF() to ensure the last log entry is output before a container exits. The polling interval is set to 250 milliseconds based on polling interval defined in hpcloud/tail here: https://github.com/hpcloud/tail/blob/v1.0.0/watch/polling.go#L117 Co-authored-by: Qi Wang Signed-off-by: jgallucci32 --- test/e2e/logs_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test') diff --git a/test/e2e/logs_test.go b/test/e2e/logs_test.go index a4a59acb2..fc0739d3d 100644 --- a/test/e2e/logs_test.go +++ b/test/e2e/logs_test.go @@ -311,4 +311,16 @@ var _ = Describe("Podman logs", func() { logs.WaitWithDefaultTimeout() Expect(logs).To(Not(Exit(0))) }) + + It("follow output stopped container", func() { + containerName := "logs-f" + + logc := podmanTest.Podman([]string{"run", "--name", containerName, "-d", ALPINE}) + logc.WaitWithDefaultTimeout() + Expect(logc).To(Exit(0)) + + results := podmanTest.Podman([]string{"logs", "-f", containerName}) + results.WaitWithDefaultTimeout() + Expect(results).To(Exit(0)) + }) }) -- cgit v1.2.3-54-g00ecf From 173d08637411629a271ab162d917f6ccee438dae Mon Sep 17 00:00:00 2001 From: jgallucci32 Date: Mon, 22 Jun 2020 06:38:53 -0700 Subject: Add explicit command to alpine container in test case. Signed-off-by: jgallucci32 --- test/e2e/logs_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/e2e/logs_test.go b/test/e2e/logs_test.go index fc0739d3d..cf69cbd3e 100644 --- a/test/e2e/logs_test.go +++ b/test/e2e/logs_test.go @@ -315,7 +315,7 @@ var _ = Describe("Podman logs", func() { It("follow output stopped container", func() { containerName := "logs-f" - logc := podmanTest.Podman([]string{"run", "--name", containerName, "-d", ALPINE}) + logc := podmanTest.Podman([]string{"run", "--name", containerName, "-d", ALPINE, "true"}) logc.WaitWithDefaultTimeout() Expect(logc).To(Exit(0)) -- cgit v1.2.3-54-g00ecf