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

Commit dbb0fa2

Browse files
committed
[integration-test] optimize test case: TestCliLogsSinceFutureFollow and TestCliRunRestartMaxRetries
1 parent e9239ab commit dbb0fa2

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

integration-cli/hyper_cli_logs_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,18 +249,19 @@ func (s *DockerSuite) TestCliLogsSinceFutureFollow(c *check.C) {
249249
testRequires(c, DaemonIsLinux)
250250
pullImageIfNotExist("busybox")
251251
out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", `for i in $(seq 1 50); do date +%s; sleep 1; done`)
252-
time.Sleep(20 * time.Second)
252+
time.Sleep(5 * time.Second)
253253
id := strings.TrimSpace(out)
254254

255255
now := daemonTime(c).Unix()
256256
since := now - 5
257+
257258
out, _ = dockerCmd(c, "logs", "-f", fmt.Sprintf("--since=%v", since), id)
258259
lines := strings.Split(strings.TrimSpace(out), "\n")
259260
c.Assert(lines, checker.Not(checker.HasLen), 0)
260261
for _, v := range lines {
261262
ts, err := strconv.ParseInt(v, 10, 64)
262263
c.Assert(err, checker.IsNil, check.Commentf("cannot parse timestamp output from log: '%v'\nout=%s", v, out))
263-
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))
264265
}
265266
}
266267

integration-cli/hyper_cli_run_test.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,23 +1110,22 @@ func (s *DockerSuite) TestCliRunRestartMaxRetries(c *check.C) {
11101110
printTestCaseName()
11111111
defer printTestDuration(time.Now())
11121112
pullImageIfNotExist("busybox")
1113-
out, _ := dockerCmd(c, "run", "-d", "--restart=on-failure:3", "busybox", "sh", "-c", "sleep 20; false")
1114-
timeout := 100 * time.Second
1115-
if daemonPlatform == "windows" {
1116-
timeout = 45 * time.Second
1117-
}
1113+
1114+
RETRY_COUNT := "3"
1115+
out, _ := dockerCmd(c, "run", "-d", "--restart=on-failure:" + RETRY_COUNT, "busybox", "sh", "-c", "sleep 35; false")
1116+
timeout := 120 * time.Second
11181117

11191118
time.Sleep(timeout)
11201119
id := strings.TrimSpace(string(out))
11211120

11221121
count := inspectField(c, id, "RestartCount")
1123-
if count != "3" {
1124-
c.Fatalf("Container was restarted %s times, expected %d", count, 3)
1122+
if count != RETRY_COUNT {
1123+
c.Fatalf("Container was restarted %s times, expected %d", count, RETRY_COUNT)
11251124
}
11261125

11271126
MaximumRetryCount := inspectField(c, id, "HostConfig.RestartPolicy.MaximumRetryCount")
1128-
if MaximumRetryCount != "3" {
1129-
c.Fatalf("Container Maximum Retry Count is %s, expected %s", MaximumRetryCount, "3")
1127+
if MaximumRetryCount != RETRY_COUNT {
1128+
c.Fatalf("Container Maximum Retry Count is %s, expected %s", MaximumRetryCount, RETRY_COUNT)
11301129
}
11311130
}
11321131

0 commit comments

Comments
 (0)