Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit e9f1795

Browse files
committed
fix some issues in test cases for hyper.sh
1 parent b6dc8e5 commit e9f1795

File tree

5 files changed

+65
-21
lines changed

5 files changed

+65
-21
lines changed

integration-cli/hyper_cli_logs_test.go

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -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
179194
func (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)

integration-cli/hyper_cli_pull_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func (s *DockerHubPullSuite) TestCliPullNonExistingImage(c *check.C) {
6363

6464
// pull -a on a nonexistent registry should fall back as well
6565
if !strings.ContainsRune(e.Alias, ':') {
66-
out, err := s.CmdWithError("pull", "-a", e.Alias)
66+
out, err := s.CmdWithError("pull", e.Alias)
6767
c.Assert(err, checker.NotNil, check.Commentf("expected non-zero exit status when pulling non-existing image: %s", out))
6868
c.Assert(out, checker.Contains, fmt.Sprintf("Error: image %s not found", e.Repo), check.Commentf("expected image not found error messages"))
6969
c.Assert(out, checker.Not(checker.Contains), "unauthorized", check.Commentf(`message should not contain "unauthorized"`))

integration-cli/hyper_cli_rename_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@ package main
22

33
import (
44
"strings"
5+
"time"
56

67
"github.com/docker/docker/pkg/integration/checker"
78
"github.com/docker/docker/pkg/stringid"
89
"github.com/go-check/check"
910
)
1011

1112
func (s *DockerSuite) TestCliRenameStoppedContainer(c *check.C) {
13+
printTestCaseName()
14+
defer printTestDuration(time.Now())
1215
pullImageIfNotExist("busybox")
1316
out, _ := dockerCmd(c, "run", "--name", "first-name", "-d", "busybox", "sh")
1417

@@ -25,6 +28,8 @@ func (s *DockerSuite) TestCliRenameStoppedContainer(c *check.C) {
2528
}
2629

2730
func (s *DockerSuite) TestCliRenameRunningContainer(c *check.C) {
31+
printTestCaseName()
32+
defer printTestDuration(time.Now())
2833
pullImageIfNotExist("busybox")
2934
out, _ := dockerCmd(c, "run", "--name", "first-name", "-d", "busybox", "sh")
3035

@@ -37,6 +42,8 @@ func (s *DockerSuite) TestCliRenameRunningContainer(c *check.C) {
3742
}
3843

3944
func (s *DockerSuite) TestCliRenameRunningContainerAndReuse(c *check.C) {
45+
printTestCaseName()
46+
defer printTestDuration(time.Now())
4047
pullImageIfNotExist("busybox")
4148
out, _ := runSleepingContainer(c, "--name", "first-name")
4249
c.Assert(waitRun("first-name"), check.IsNil)
@@ -56,6 +63,8 @@ func (s *DockerSuite) TestCliRenameRunningContainerAndReuse(c *check.C) {
5663
}
5764

5865
func (s *DockerSuite) TestCliRenameCheckNames(c *check.C) {
66+
printTestCaseName()
67+
defer printTestDuration(time.Now())
5968
dockerCmd(c, "run", "--name", "first-name", "-d", "busybox", "sh")
6069

6170
newName := "new-name" + stringid.GenerateNonCryptoID()[:32]
@@ -70,6 +79,8 @@ func (s *DockerSuite) TestCliRenameCheckNames(c *check.C) {
7079
}
7180

7281
func (s *DockerSuite) TestCliRenameInvalidName(c *check.C) {
82+
printTestCaseName()
83+
defer printTestDuration(time.Now())
7384
pullImageIfNotExist("busybox")
7485
runSleepingContainer(c, "--name", "myname")
7586

integration-cli/hyper_cli_restart_test.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import (
1111
)
1212

1313
func (s *DockerSuite) TestCliRestartStoppedContainer(c *check.C) {
14+
printTestCaseName()
15+
defer printTestDuration(time.Now())
1416
testRequires(c, DaemonIsLinux)
1517
pullImageIfNotExist("busybox")
1618
out, _ := dockerCmd(c, "run", "-d", "busybox", "echo", "foobar")
@@ -28,6 +30,8 @@ func (s *DockerSuite) TestCliRestartStoppedContainer(c *check.C) {
2830
}
2931

3032
func (s *DockerSuite) TestCliRestartRunningContainer(c *check.C) {
33+
printTestCaseName()
34+
defer printTestDuration(time.Now())
3135
testRequires(c, DaemonIsLinux)
3236
pullImageIfNotExist("busybox")
3337
out, _ := dockerCmd(c, "run", "-d", "busybox", "sh", "-c", "echo foobar && sleep 30 && echo 'should not print this'")
@@ -45,11 +49,13 @@ func (s *DockerSuite) TestCliRestartRunningContainer(c *check.C) {
4549

4650
c.Assert(waitRun(cleanedContainerID), checker.IsNil)
4751

48-
c.Assert(out, checker.Equals, "foobar\n")
52+
c.Assert(out, checker.Equals, "foobar\nfoobar\n")
4953
}
5054

5155
// Test that restarting a container with a volume does not create a new volume on restart. Regression test for #819.
5256
func (s *DockerSuite) TestCliRestartWithVolumes(c *check.C) {
57+
printTestCaseName()
58+
defer printTestDuration(time.Now())
5359
testRequires(c, DaemonIsLinux)
5460
pullImageIfNotExist("busybox")
5561
out, _ := dockerCmd(c, "run", "-d", "-v", "/test", "busybox", "top")
@@ -76,6 +82,8 @@ func (s *DockerSuite) TestCliRestartWithVolumes(c *check.C) {
7682
}
7783

7884
func (s *DockerSuite) TestCliRestartPolicyNO(c *check.C) {
85+
printTestCaseName()
86+
defer printTestDuration(time.Now())
7987
testRequires(c, DaemonIsLinux)
8088
pullImageIfNotExist("busybox")
8189
out, _ := dockerCmd(c, "run", "-d", "--restart=no", "busybox", "false")
@@ -86,6 +94,8 @@ func (s *DockerSuite) TestCliRestartPolicyNO(c *check.C) {
8694
}
8795

8896
func (s *DockerSuite) TestCliRestartPolicyAlways(c *check.C) {
97+
printTestCaseName()
98+
defer printTestDuration(time.Now())
8999
testRequires(c, DaemonIsLinux)
90100
pullImageIfNotExist("busybox")
91101
out, _ := dockerCmd(c, "run", "-d", "--restart=always", "busybox", "false")
@@ -101,6 +111,8 @@ func (s *DockerSuite) TestCliRestartPolicyAlways(c *check.C) {
101111
}
102112

103113
func (s *DockerSuite) TestCliRestartPolicyOnFailure(c *check.C) {
114+
printTestCaseName()
115+
defer printTestDuration(time.Now())
104116
testRequires(c, DaemonIsLinux)
105117
pullImageIfNotExist("busybox")
106118
out, _ := dockerCmd(c, "run", "-d", "--restart=on-failure:1", "busybox", "false")
@@ -114,6 +126,8 @@ func (s *DockerSuite) TestCliRestartPolicyOnFailure(c *check.C) {
114126
// a good container with --restart=on-failure:3
115127
// MaximumRetryCount!=0; RestartCount=0
116128
func (s *DockerSuite) TestCliRestartContainerRestartwithGoodContainer(c *check.C) {
129+
printTestCaseName()
130+
defer printTestDuration(time.Now())
117131
testRequires(c, DaemonIsLinux)
118132
pullImageIfNotExist("busybox")
119133
out, _ := dockerCmd(c, "run", "-d", "--restart=on-failure:3", "busybox", "true")
@@ -131,6 +145,8 @@ func (s *DockerSuite) TestCliRestartContainerRestartwithGoodContainer(c *check.C
131145
}
132146

133147
func (s *DockerSuite) TestCliRestartContainerRestartSuccess(c *check.C) {
148+
printTestCaseName()
149+
defer printTestDuration(time.Now())
134150
testRequires(c, DaemonIsLinux, SameHostDaemon)
135151

136152
pullImageIfNotExist("busybox")

integration-cli/hyper_cli_snapshot_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ func (s *DockerSuite) TestCliSnapshotRmBasedVol(c *check.C) {
204204

205205
out, _, err := dockerCmdWithError("volume", "rm", "test")
206206
c.Assert(err, checker.NotNil)
207-
c.Assert(out, checker.Contains, "Volume(test) has one or more snapshots")
207+
c.Assert(out, checker.Contains, "Volume(test) has (1) snapshots")
208208

209209
dockerCmd(c, "snapshot", "rm", "test-snap")
210210
_, _, err = dockerCmdWithError("volume", "rm", "test")

0 commit comments

Comments
 (0)