@@ -69,9 +69,11 @@ func (s *DockerSuite) TestCliLogsTimestamps(c *check.C) {
69
69
testLen := 100
70
70
pullImageIfNotExist ("busybox" )
71
71
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 )
72
73
73
74
id := strings .TrimSpace (out )
74
75
dockerCmd (c , "stop" , id )
76
+ time .Sleep (5 * time .Second )
75
77
76
78
out , _ = dockerCmd (c , "logs" , "-t" , id )
77
79
@@ -99,9 +101,11 @@ func (s *DockerSuite) TestCliLogsSeparateStderr(c *check.C) {
99
101
pullImageIfNotExist ("busybox" )
100
102
msg := "stderr_log"
101
103
out , _ := dockerCmd (c , "run" , "-d" , "busybox" , "sh" , "-c" , fmt .Sprintf ("echo %s 1>&2" , msg ))
104
+ time .Sleep (5 * time .Second )
102
105
103
106
id := strings .TrimSpace (out )
104
107
dockerCmd (c , "stop" , id )
108
+ time .Sleep (5 * time .Second )
105
109
106
110
stdout , stderr , _ := dockerCmdWithStdoutStderr (c , "logs" , id )
107
111
@@ -120,9 +124,11 @@ func (s *DockerSuite) TestCliLogsStderrInStdout(c *check.C) {
120
124
pullImageIfNotExist ("busybox" )
121
125
msg := "stderr_log"
122
126
out , _ := dockerCmd (c , "run" , "-d" , "-t" , "busybox" , "sh" , "-c" , fmt .Sprintf ("echo %s 1>&2" , msg ))
127
+ time .Sleep (5 * time .Second )
123
128
124
129
id := strings .TrimSpace (out )
125
130
dockerCmd (c , "stop" , id )
131
+ time .Sleep (5 * time .Second )
126
132
127
133
stdout , stderr , _ := dockerCmdWithStdoutStderr (c , "logs" , id )
128
134
c .Assert (stderr , checker .Equals , "" )
@@ -139,9 +145,11 @@ func (s *DockerSuite) TestCliLogsTail(c *check.C) {
139
145
testLen := 100
140
146
pullImageIfNotExist ("busybox" )
141
147
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 )
142
149
143
150
id := strings .TrimSpace (out )
144
151
dockerCmd (c , "stop" , id )
152
+ time .Sleep (5 * time .Second )
145
153
146
154
out , _ = dockerCmd (c , "logs" , "--tail" , "5" , id )
147
155
@@ -169,9 +177,11 @@ func (s *DockerSuite) TestCliLogsFollowStopped(c *check.C) {
169
177
testRequires (c , DaemonIsLinux )
170
178
pullImageIfNotExist ("busybox" )
171
179
out , _ := dockerCmd (c , "run" , "-d" , "busybox" , "echo" , "hello" )
180
+ time .Sleep (5 * time .Second )
172
181
173
182
id := strings .TrimSpace (out )
174
183
dockerCmd (c , "stop" , id )
184
+ time .Sleep (5 * time .Second )
175
185
176
186
logsCmd := exec .Command (dockerBinary , "logs" , "-f" , id )
177
187
c .Assert (logsCmd .Start (), checker .IsNil )
@@ -198,7 +208,8 @@ func (s *DockerSuite) TestCliLogsSince(c *check.C) {
198
208
pullImageIfNotExist ("busybox" )
199
209
name := "testlogssince"
200
210
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
+
202
213
out , _ := dockerCmd (c , "logs" , "-t" , name )
203
214
204
215
log2Line := strings .Split (strings .Split (out , "\n " )[1 ], " " )
@@ -238,17 +249,19 @@ func (s *DockerSuite) TestCliLogsSinceFutureFollow(c *check.C) {
238
249
testRequires (c , DaemonIsLinux )
239
250
pullImageIfNotExist ("busybox" )
240
251
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 )
241
253
id := strings .TrimSpace (out )
242
254
243
255
now := daemonTime (c ).Unix ()
244
256
since := now - 5
257
+
245
258
out , _ = dockerCmd (c , "logs" , "-f" , fmt .Sprintf ("--since=%v" , since ), id )
246
259
lines := strings .Split (strings .TrimSpace (out ), "\n " )
247
260
c .Assert (lines , checker .Not (checker .HasLen ), 0 )
248
261
for _ , v := range lines {
249
262
ts , err := strconv .ParseInt (v , 10 , 64 )
250
263
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 ))
252
265
}
253
266
}
254
267
@@ -260,13 +273,14 @@ func (s *DockerSuite) TestCliLogsFollowSlowStdoutConsumer(c *check.C) {
260
273
testRequires (c , DaemonIsLinux )
261
274
pullImageIfNotExist ("busybox" )
262
275
out , _ := dockerCmd (c , "run" , "-d" , "busybox" , "/bin/sh" , "-c" , `usleep 600000;yes X | head -c 200000` )
263
-
276
+ time . Sleep ( 5 * time . Second )
264
277
id := strings .TrimSpace (out )
265
278
266
279
stopSlowRead := make (chan bool )
267
280
268
281
go func () {
269
282
exec .Command (dockerBinary , "stop" , id ).Run ()
283
+ time .Sleep (5 * time .Second )
270
284
stopSlowRead <- true
271
285
}()
272
286
0 commit comments