summaryrefslogtreecommitdiff
path: root/test/e2e
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2021-06-08 13:44:49 +0200
committerValentin Rothberg <rothberg@redhat.com>2021-06-08 16:14:13 +0200
commit84b55eec27967d1a528c4f49f100393668638e1a (patch)
treeeda35001bf81abaa90fe132c007046b2887f3443 /test/e2e
parentb64e20a53d3f5de262f2c475be490b35977d5f32 (diff)
downloadpodman-84b55eec27967d1a528c4f49f100393668638e1a.tar.gz
podman-84b55eec27967d1a528c4f49f100393668638e1a.tar.bz2
podman-84b55eec27967d1a528c4f49f100393668638e1a.zip
logs: k8s-file: fix race
Fix a race in the k8s-file logs driver. When "following" the logs, Podman will print the container's logs until the end. Previously, Podman logged until the state transitioned into something non-running which opened up a race with the container still running, possibly in the "stopping" state. To fix the race, log until we've seen the wait event for the specific container. In that case, conmon will have finished writing all logs to the file, and Podman will read it until EOF. Further tweak the integration tests for testing `logs -f` on a running container. Previously, the test only checked for one of two lines stating that there was a race. Indeed the race was in using `run --rm` where a log file may be removed before we could fully read it. Fixes: #10596 Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'test/e2e')
-rw-r--r--test/e2e/logs_test.go14
1 files changed, 8 insertions, 6 deletions
diff --git a/test/e2e/logs_test.go b/test/e2e/logs_test.go
index 4d9cbb48b..b576fa072 100644
--- a/test/e2e/logs_test.go
+++ b/test/e2e/logs_test.go
@@ -173,9 +173,9 @@ var _ = Describe("Podman logs", func() {
})
It("streaming output: "+log, func() {
- containerName := "logs-f-rm"
+ containerName := "logs-f"
- logc := podmanTest.Podman([]string{"run", "--log-driver", log, "--rm", "--name", containerName, "-dt", ALPINE, "sh", "-c", "echo podman; sleep 1; echo podman"})
+ logc := podmanTest.Podman([]string{"run", "--log-driver", log, "--name", containerName, "-dt", ALPINE, "sh", "-c", "echo podman-1; sleep 1; echo podman-2"})
logc.WaitWithDefaultTimeout()
Expect(logc).To(Exit(0))
@@ -183,10 +183,8 @@ var _ = Describe("Podman logs", func() {
results.WaitWithDefaultTimeout()
Expect(results).To(Exit(0))
- // TODO: we should actually check for two podman lines,
- // but as of 2020-06-17 there's a race condition in which
- // 'logs -f' may not catch all output from a container
- Expect(results.OutputToString()).To(ContainSubstring("podman"))
+ Expect(results.OutputToString()).To(ContainSubstring("podman-1"))
+ Expect(results.OutputToString()).To(ContainSubstring("podman-2"))
// Container should now be terminatING or terminatED, but we
// have no guarantee of which: 'logs -f' does not necessarily
@@ -199,6 +197,10 @@ var _ = Describe("Podman logs", func() {
} else {
Expect(inspect.ErrorToString()).To(ContainSubstring("no such container"))
}
+
+ results = podmanTest.Podman([]string{"rm", "-f", containerName})
+ results.WaitWithDefaultTimeout()
+ Expect(results).To(Exit(0))
})
It("follow output stopped container: "+log, func() {