@@ -69,9 +69,11 @@ func (s *DockerSuite) TestCliLogsTimestamps(c *check.C) {
6969 testLen := 100
7070 pullImageIfNotExist ("busybox" )
7171 out , _ := dockerCmd (c , "run" , "-d" , "busybox" , "sh" , "-c" , fmt .Sprintf ("for i in $(seq 1 %d); do echo =; done;" , testLen ))
72+ time .Sleep (5 * time .Second )
7273
7374 id := strings .TrimSpace (out )
7475 dockerCmd (c , "stop" , id )
76+ time .Sleep (5 * time .Second )
7577
7678 out , _ = dockerCmd (c , "logs" , "-t" , id )
7779
@@ -99,9 +101,11 @@ func (s *DockerSuite) TestCliLogsSeparateStderr(c *check.C) {
99101 pullImageIfNotExist ("busybox" )
100102 msg := "stderr_log"
101103 out , _ := dockerCmd (c , "run" , "-d" , "busybox" , "sh" , "-c" , fmt .Sprintf ("echo %s 1>&2" , msg ))
104+ time .Sleep (5 * time .Second )
102105
103106 id := strings .TrimSpace (out )
104107 dockerCmd (c , "stop" , id )
108+ time .Sleep (5 * time .Second )
105109
106110 stdout , stderr , _ := dockerCmdWithStdoutStderr (c , "logs" , id )
107111
@@ -120,9 +124,11 @@ func (s *DockerSuite) TestCliLogsStderrInStdout(c *check.C) {
120124 pullImageIfNotExist ("busybox" )
121125 msg := "stderr_log"
122126 out , _ := dockerCmd (c , "run" , "-d" , "-t" , "busybox" , "sh" , "-c" , fmt .Sprintf ("echo %s 1>&2" , msg ))
127+ time .Sleep (5 * time .Second )
123128
124129 id := strings .TrimSpace (out )
125130 dockerCmd (c , "stop" , id )
131+ time .Sleep (5 * time .Second )
126132
127133 stdout , stderr , _ := dockerCmdWithStdoutStderr (c , "logs" , id )
128134 c .Assert (stderr , checker .Equals , "" )
@@ -139,9 +145,11 @@ func (s *DockerSuite) TestCliLogsTail(c *check.C) {
139145 testLen := 100
140146 pullImageIfNotExist ("busybox" )
141147 out , _ := dockerCmd (c , "run" , "-d" , "busybox" , "sh" , "-c" , fmt .Sprintf ("for i in $(seq 1 %d); do echo =; done;" , testLen ))
148+ time .Sleep (5 * time .Second )
142149
143150 id := strings .TrimSpace (out )
144151 dockerCmd (c , "stop" , id )
152+ time .Sleep (5 * time .Second )
145153
146154 out , _ = dockerCmd (c , "logs" , "--tail" , "5" , id )
147155
@@ -169,9 +177,11 @@ func (s *DockerSuite) TestCliLogsFollowStopped(c *check.C) {
169177 testRequires (c , DaemonIsLinux )
170178 pullImageIfNotExist ("busybox" )
171179 out , _ := dockerCmd (c , "run" , "-d" , "busybox" , "echo" , "hello" )
180+ time .Sleep (5 * time .Second )
172181
173182 id := strings .TrimSpace (out )
174183 dockerCmd (c , "stop" , id )
184+ time .Sleep (5 * time .Second )
175185
176186 logsCmd := exec .Command (dockerBinary , "logs" , "-f" , id )
177187 c .Assert (logsCmd .Start (), checker .IsNil )
@@ -198,7 +208,8 @@ func (s *DockerSuite) TestCliLogsSince(c *check.C) {
198208 pullImageIfNotExist ("busybox" )
199209 name := "testlogssince"
200210 dockerCmd (c , "run" , "--name=" + name , "-d" , "busybox" , "/bin/sh" , "-c" , "for i in $(seq 1 30); do sleep 2; echo log$i; done" )
201- time .Sleep (5 * time .Second )
211+ time .Sleep (10 * time .Second )
212+
202213 out , _ := dockerCmd (c , "logs" , "-t" , name )
203214
204215 log2Line := strings .Split (strings .Split (out , "\n " )[1 ], " " )
@@ -238,17 +249,19 @@ func (s *DockerSuite) TestCliLogsSinceFutureFollow(c *check.C) {
238249 testRequires (c , DaemonIsLinux )
239250 pullImageIfNotExist ("busybox" )
240251 out , _ := dockerCmd (c , "run" , "-d" , "busybox" , "/bin/sh" , "-c" , `for i in $(seq 1 50); do date +%s; sleep 1; done` )
252+ time .Sleep (5 * time .Second )
241253 id := strings .TrimSpace (out )
242254
243255 now := daemonTime (c ).Unix ()
244256 since := now - 5
257+
245258 out , _ = dockerCmd (c , "logs" , "-f" , fmt .Sprintf ("--since=%v" , since ), id )
246259 lines := strings .Split (strings .TrimSpace (out ), "\n " )
247260 c .Assert (lines , checker .Not (checker .HasLen ), 0 )
248261 for _ , v := range lines {
249262 ts , err := strconv .ParseInt (v , 10 , 64 )
250263 c .Assert (err , checker .IsNil , check .Commentf ("cannot parse timestamp output from log: '%v'\n out=%s" , v , out ))
251- c .Assert (ts >= since , checker .Equals , true , check .Commentf ("earlier log found. since=%v logdate=%v" , since , ts ))
264+ c .Assert ( ( ts + 1 ) >= since , checker .Equals , true , check .Commentf ("earlier log found. since=%v logdate=%v" , since , ts ))
252265 }
253266}
254267
@@ -260,13 +273,14 @@ func (s *DockerSuite) TestCliLogsFollowSlowStdoutConsumer(c *check.C) {
260273 testRequires (c , DaemonIsLinux )
261274 pullImageIfNotExist ("busybox" )
262275 out , _ := dockerCmd (c , "run" , "-d" , "busybox" , "/bin/sh" , "-c" , `usleep 600000;yes X | head -c 200000` )
263-
276+ time . Sleep ( 5 * time . Second )
264277 id := strings .TrimSpace (out )
265278
266279 stopSlowRead := make (chan bool )
267280
268281 go func () {
269282 exec .Command (dockerBinary , "stop" , id ).Run ()
283+ time .Sleep (5 * time .Second )
270284 stopSlowRead <- true
271285 }()
272286
0 commit comments