mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #18479 from aaronlehmann/flaky-logs-test
Fix flaky test TestLogsSince
This commit is contained in:
commit
adb19755e1
1 changed files with 4 additions and 3 deletions
|
@ -169,12 +169,13 @@ func (s *DockerSuite) TestLogsFollowStopped(c *check.C) {
|
||||||
func (s *DockerSuite) TestLogsSince(c *check.C) {
|
func (s *DockerSuite) TestLogsSince(c *check.C) {
|
||||||
testRequires(c, DaemonIsLinux)
|
testRequires(c, DaemonIsLinux)
|
||||||
name := "testlogssince"
|
name := "testlogssince"
|
||||||
out, _ := dockerCmd(c, "run", "--name="+name, "busybox", "/bin/sh", "-c", "for i in $(seq 1 3); do sleep 2; echo `date +%s` log$i; done")
|
dockerCmd(c, "run", "--name="+name, "busybox", "/bin/sh", "-c", "for i in $(seq 1 3); do sleep 2; echo log$i; done")
|
||||||
|
out, _ := dockerCmd(c, "logs", "-t", name)
|
||||||
|
|
||||||
log2Line := strings.Split(strings.Split(out, "\n")[1], " ")
|
log2Line := strings.Split(strings.Split(out, "\n")[1], " ")
|
||||||
t, err := strconv.ParseInt(log2Line[0], 10, 64) // the timestamp log2 is written
|
t, err := time.Parse(time.RFC3339Nano, log2Line[0]) // the timestamp log2 is written
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
since := t + 1 // add 1s so log1 & log2 doesn't show up
|
since := t.Unix() + 1 // add 1s so log1 & log2 doesn't show up
|
||||||
out, _ = dockerCmd(c, "logs", "-t", fmt.Sprintf("--since=%v", since), name)
|
out, _ = dockerCmd(c, "logs", "-t", fmt.Sprintf("--since=%v", since), name)
|
||||||
|
|
||||||
// Skip 2 seconds
|
// Skip 2 seconds
|
||||||
|
|
Loading…
Add table
Reference in a new issue