@@ -6,13 +6,13 @@ import (
66 //"io"
77 "os"
88 "os/exec"
9- // "regexp"
9+ "regexp"
1010 "strconv"
1111 "strings"
1212 "time"
1313
1414 "github.com/docker/docker/pkg/integration/checker"
15- // "github.com/docker/docker/pkg/jsonlog"
15+ "github.com/docker/docker/pkg/jsonlog"
1616 "github.com/go-check/check"
1717)
1818
@@ -62,9 +62,12 @@ func (s *DockerSuite) TestCliLogsContainerMuchBiggerThanPage(c *check.C) {
6262}*/
6363
6464//TODO: get exited container log
65- /*func (s *DockerSuite) TestCliLogsTimestamps(c *check.C) {
65+ func (s * DockerSuite ) TestCliLogsTimestamps (c * check.C ) {
66+ printTestCaseName ()
67+ defer printTestDuration (time .Now ())
6668 testRequires (c , DaemonIsLinux )
6769 testLen := 100
70+ pullImageIfNotExist ("busybox" )
6871 out , _ := dockerCmd (c , "run" , "-d" , "busybox" , "sh" , "-c" , fmt .Sprintf ("for i in $(seq 1 %d); do echo =; done;" , testLen ))
6972
7073 id := strings .TrimSpace (out )
@@ -86,11 +89,14 @@ func (s *DockerSuite) TestCliLogsContainerMuchBiggerThanPage(c *check.C) {
8689 c .Assert (l [29 ], checker .Equals , uint8 ('Z' ))
8790 }
8891 }
89- }*/
92+ }
9093
9194//TODO: get exited container log
92- /*func (s *DockerSuite) TestCliLogsSeparateStderr(c *check.C) {
95+ func (s * DockerSuite ) TestCliLogsSeparateStderr (c * check.C ) {
96+ printTestCaseName ()
97+ defer printTestDuration (time .Now ())
9398 testRequires (c , DaemonIsLinux )
99+ pullImageIfNotExist ("busybox" )
94100 msg := "stderr_log"
95101 out , _ := dockerCmd (c , "run" , "-d" , "busybox" , "sh" , "-c" , fmt .Sprintf ("echo %s 1>&2" , msg ))
96102
@@ -104,11 +110,14 @@ func (s *DockerSuite) TestCliLogsContainerMuchBiggerThanPage(c *check.C) {
104110 stderr = strings .TrimSpace (stderr )
105111
106112 c .Assert (stderr , checker .Equals , msg )
107- }*/
113+ }
108114
109115//TODO: get exited container log
110- /*func (s *DockerSuite) TestCliLogsStderrInStdout(c *check.C) {
116+ func (s * DockerSuite ) TestCliLogsStderrInStdout (c * check.C ) {
117+ printTestCaseName ()
118+ defer printTestDuration (time .Now ())
111119 testRequires (c , DaemonIsLinux )
120+ pullImageIfNotExist ("busybox" )
112121 msg := "stderr_log"
113122 out , _ := dockerCmd (c , "run" , "-d" , "-t" , "busybox" , "sh" , "-c" , fmt .Sprintf ("echo %s 1>&2" , msg ))
114123
@@ -120,12 +129,15 @@ func (s *DockerSuite) TestCliLogsContainerMuchBiggerThanPage(c *check.C) {
120129
121130 stdout = strings .TrimSpace (stdout )
122131 c .Assert (stdout , checker .Equals , msg )
123- }*/
132+ }
124133
125134//TODO: get exited container log
126- /*func (s *DockerSuite) TestCliLogsTail(c *check.C) {
135+ func (s * DockerSuite ) TestCliLogsTail (c * check.C ) {
136+ printTestCaseName ()
137+ defer printTestDuration (time .Now ())
127138 testRequires (c , DaemonIsLinux )
128139 testLen := 100
140+ pullImageIfNotExist ("busybox" )
129141 out , _ := dockerCmd (c , "run" , "-d" , "busybox" , "sh" , "-c" , fmt .Sprintf ("for i in $(seq 1 %d); do echo =; done;" , testLen ))
130142
131143 id := strings .TrimSpace (out )
@@ -148,11 +160,14 @@ func (s *DockerSuite) TestCliLogsContainerMuchBiggerThanPage(c *check.C) {
148160 lines = strings .Split (out , "\n " )
149161
150162 c .Assert (lines , checker .HasLen , testLen + 1 )
151- }*/
163+ }
152164
153165//TODO: get exited container log
154- /*func (s *DockerSuite) TestCliLogsFollowStopped(c *check.C) {
166+ func (s * DockerSuite ) TestCliLogsFollowStopped (c * check.C ) {
167+ printTestCaseName ()
168+ defer printTestDuration (time .Now ())
155169 testRequires (c , DaemonIsLinux )
170+ pullImageIfNotExist ("busybox" )
156171 out , _ := dockerCmd (c , "run" , "-d" , "busybox" , "echo" , "hello" )
157172
158173 id := strings .TrimSpace (out )
@@ -170,22 +185,20 @@ func (s *DockerSuite) TestCliLogsContainerMuchBiggerThanPage(c *check.C) {
170185 select {
171186 case err := <- errChan :
172187 c .Assert (err , checker .IsNil )
173- case <-time.After(1 * time.Second):
188+ case <- time .After (10 * time .Second ):
174189 c .Fatal ("Following logs is hanged" )
175190 }
176- }*/
191+ }
177192
178193//TODO: fix #46
179194func (s * DockerSuite ) TestCliLogsSince (c * check.C ) {
180195 printTestCaseName ()
181196 defer printTestDuration (time .Now ())
182-
183197 testRequires (c , DaemonIsLinux )
184198 pullImageIfNotExist ("busybox" )
185199 name := "testlogssince"
186200 dockerCmd (c , "run" , "--name=" + name , "-d" , "busybox" , "/bin/sh" , "-c" , "for i in $(seq 1 30); do sleep 2; echo log$i; done" )
187- //wait for container running
188- time .Sleep (5 * time .Second )
201+ time .Sleep (5 * time .Second )
189202 out , _ := dockerCmd (c , "logs" , "-t" , name )
190203
191204 log2Line := strings .Split (strings .Split (out , "\n " )[1 ], " " )
@@ -241,8 +254,11 @@ func (s *DockerSuite) TestCliLogsSinceFutureFollow(c *check.C) {
241254
242255//TODO: get exited container log
243256// Regression test for #8832
244- /*func (s *DockerSuite) TestCliLogsFollowSlowStdoutConsumer(c *check.C) {
257+ func (s * DockerSuite ) TestCliLogsFollowSlowStdoutConsumer (c * check.C ) {
258+ printTestCaseName ()
259+ defer printTestDuration (time .Now ())
245260 testRequires (c , DaemonIsLinux )
261+ pullImageIfNotExist ("busybox" )
246262 out , _ := dockerCmd (c , "run" , "-d" , "busybox" , "/bin/sh" , "-c" , `usleep 600000;yes X | head -c 200000` )
247263
248264 id := strings .TrimSpace (out )
@@ -270,7 +286,7 @@ func (s *DockerSuite) TestCliLogsSinceFutureFollow(c *check.C) {
270286 actual := bytes1 + bytes2
271287 expected := 200000
272288 c .Assert (actual , checker .Equals , expected )
273- }*/
289+ }
274290
275291//TODO: fix Goroutine in multi-tenancy environment
276292/*func (s *DockerSuite) TestCliLogsFollowGoroutinesWithStdout(c *check.C) {
@@ -333,6 +349,7 @@ func (s *DockerSuite) TestCliLogsFollowGoroutinesNoOutput(c *check.C) {
333349 defer printTestDuration(time.Now())
334350
335351 testRequires(c, DaemonIsLinux)
352+ pullImageIfNotExist("busybox")
336353 out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "while true; do sleep 2; done")
337354 id := strings.TrimSpace(out)
338355 c.Assert(waitRun(id), checker.IsNil)
0 commit comments