diff options
author | baude <bbaude@redhat.com> | 2018-02-06 09:07:51 -0600 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-02-09 15:27:52 +0000 |
commit | fa9658cbfaa94fd5d0425041404e498c01db1aa3 (patch) | |
tree | 3cacae5b613692387780209a5d41b10c2edc0940 /test/e2e | |
parent | 75914199f331a10eb7ed44de68c738515bdd5b2d (diff) | |
download | podman-fa9658cbfaa94fd5d0425041404e498c01db1aa3.tar.gz podman-fa9658cbfaa94fd5d0425041404e498c01db1aa3.tar.bz2 podman-fa9658cbfaa94fd5d0425041404e498c01db1aa3.zip |
podman logs: fix tailing
Fix issues with tailing of container logs as described
in issue #16. Also add in the ability to use a duration or
known time stamp formats for the --since flag.
Signed-off-by: baude <bbaude@redhat.com>
Closes: #317
Approved by: mheon
Diffstat (limited to 'test/e2e')
-rw-r--r-- | test/e2e/logs_test.go | 69 |
1 files changed, 59 insertions, 10 deletions
diff --git a/test/e2e/logs_test.go b/test/e2e/logs_test.go index d8fc440c0..74e31016c 100644 --- a/test/e2e/logs_test.go +++ b/test/e2e/logs_test.go @@ -28,33 +28,82 @@ var _ = Describe("Podman logs", func() { }) + //sudo bin/podman run -it --rm fedora-minimal bash -c 'for a in `seq 5`; do echo hello; done' It("podman logs for container", func() { - _, ec, cid := podmanTest.RunLsContainer("") - Expect(ec).To(Equal(0)) + podmanTest.RestoreArtifact(fedoraMinimal) + logc := podmanTest.Podman([]string{"run", "-dt", ALPINE, "sh", "-c", "echo podman; echo podman; echo podman"}) + logc.WaitWithDefaultTimeout() + Expect(logc.ExitCode()).To(Equal(0)) + cid := logc.OutputToString() results := podmanTest.Podman([]string{"logs", cid}) results.WaitWithDefaultTimeout() Expect(results.ExitCode()).To(Equal(0)) + Expect(len(results.OutputToStringArray())).To(Equal(4)) }) - It("podman logs tail three lines", func() { - Skip("Tail is not working correctly") - _, ec, cid := podmanTest.RunLsContainer("") - Expect(ec).To(Equal(0)) + It("podman logs tail two lines", func() { + podmanTest.RestoreArtifact(fedoraMinimal) + logc := podmanTest.Podman([]string{"run", "-dt", ALPINE, "sh", "-c", "echo podman; echo podman; echo podman"}) + logc.WaitWithDefaultTimeout() + Expect(logc.ExitCode()).To(Equal(0)) + cid := logc.OutputToString() - results := podmanTest.Podman([]string{"logs", "--tail", "3", cid}) + results := podmanTest.Podman([]string{"logs", "--tail", "2", cid}) results.WaitWithDefaultTimeout() Expect(results.ExitCode()).To(Equal(0)) Expect(len(results.OutputToStringArray())).To(Equal(3)) }) - It("podman logs since a given time", func() { - _, ec, cid := podmanTest.RunLsContainer("") - Expect(ec).To(Equal(0)) + It("podman logs tail 99 lines", func() { + podmanTest.RestoreArtifact(fedoraMinimal) + logc := podmanTest.Podman([]string{"run", "-dt", ALPINE, "sh", "-c", "echo podman; echo podman; echo podman"}) + logc.WaitWithDefaultTimeout() + Expect(logc.ExitCode()).To(Equal(0)) + cid := logc.OutputToString() + + results := podmanTest.Podman([]string{"logs", "--tail", "99", cid}) + results.WaitWithDefaultTimeout() + Expect(results.ExitCode()).To(Equal(0)) + Expect(len(results.OutputToStringArray())).To(Equal(4)) + }) + + It("podman logs tail 2 lines with timestamps", func() { + podmanTest.RestoreArtifact(fedoraMinimal) + logc := podmanTest.Podman([]string{"run", "-dt", ALPINE, "sh", "-c", "echo podman; echo podman; echo podman"}) + logc.WaitWithDefaultTimeout() + Expect(logc.ExitCode()).To(Equal(0)) + cid := logc.OutputToString() + + results := podmanTest.Podman([]string{"logs", "--tail", "2", "-t", cid}) + results.WaitWithDefaultTimeout() + Expect(results.ExitCode()).To(Equal(0)) + Expect(len(results.OutputToStringArray())).To(Equal(3)) + }) + + It("podman logs latest with since time", func() { + podmanTest.RestoreArtifact(fedoraMinimal) + logc := podmanTest.Podman([]string{"run", "-dt", ALPINE, "sh", "-c", "echo podman; echo podman; echo podman"}) + logc.WaitWithDefaultTimeout() + Expect(logc.ExitCode()).To(Equal(0)) + cid := logc.OutputToString() results := podmanTest.Podman([]string{"logs", "--since", "2017-08-07T10:10:09.056611202-04:00", cid}) results.WaitWithDefaultTimeout() Expect(results.ExitCode()).To(Equal(0)) + Expect(len(results.OutputToStringArray())).To(Equal(4)) }) + It("podman logs latest with since duration", func() { + podmanTest.RestoreArtifact(fedoraMinimal) + logc := podmanTest.Podman([]string{"run", "-dt", ALPINE, "sh", "-c", "echo podman; echo podman; echo podman"}) + logc.WaitWithDefaultTimeout() + Expect(logc.ExitCode()).To(Equal(0)) + cid := logc.OutputToString() + + results := podmanTest.Podman([]string{"logs", "--since", "10m", cid}) + results.WaitWithDefaultTimeout() + Expect(results.ExitCode()).To(Equal(0)) + Expect(len(results.OutputToStringArray())).To(Equal(4)) + }) }) |