mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Windows: First part of CI tests (docker run)
Signed-off-by: John Howard <jhoward@microsoft.com>
This commit is contained in:
parent
7d5603e7cb
commit
8a5ab83df8
6 changed files with 381 additions and 107 deletions
|
@ -1028,7 +1028,7 @@ func (s *DockerSuite) TestContainerApiRestart(c *check.C) {
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
c.Assert(status, check.Equals, http.StatusNoContent)
|
c.Assert(status, check.Equals, http.StatusNoContent)
|
||||||
|
|
||||||
if err := waitInspect(name, "{{ .State.Restarting }} {{ .State.Running }}", "false true", 5); err != nil {
|
if err := waitInspect(name, "{{ .State.Restarting }} {{ .State.Running }}", "false true", 5*time.Second); err != nil {
|
||||||
c.Fatal(err)
|
c.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1044,7 +1044,7 @@ func (s *DockerSuite) TestContainerApiRestartNotimeoutParam(c *check.C) {
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
c.Assert(status, check.Equals, http.StatusNoContent)
|
c.Assert(status, check.Equals, http.StatusNoContent)
|
||||||
|
|
||||||
if err := waitInspect(name, "{{ .State.Restarting }} {{ .State.Running }}", "false true", 5); err != nil {
|
if err := waitInspect(name, "{{ .State.Restarting }} {{ .State.Running }}", "false true", 5*time.Second); err != nil {
|
||||||
c.Fatal(err)
|
c.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1082,7 +1082,7 @@ func (s *DockerSuite) TestContainerApiStop(c *check.C) {
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
c.Assert(status, check.Equals, http.StatusNoContent)
|
c.Assert(status, check.Equals, http.StatusNoContent)
|
||||||
|
|
||||||
if err := waitInspect(name, "{{ .State.Running }}", "false", 5); err != nil {
|
if err := waitInspect(name, "{{ .State.Running }}", "false", 5*time.Second); err != nil {
|
||||||
c.Fatal(err)
|
c.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1101,7 +1101,7 @@ func (s *DockerSuite) TestContainerApiWait(c *check.C) {
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
c.Assert(status, check.Equals, http.StatusOK)
|
c.Assert(status, check.Equals, http.StatusOK)
|
||||||
|
|
||||||
if err := waitInspect(name, "{{ .State.Running }}", "false", 5); err != nil {
|
if err := waitInspect(name, "{{ .State.Running }}", "false", 5*time.Second); err != nil {
|
||||||
c.Fatal(err)
|
c.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1347,7 +1347,7 @@ func (s *DockerSuite) TestPostContainerStop(c *check.C) {
|
||||||
// 204 No Content is expected, not 200
|
// 204 No Content is expected, not 200
|
||||||
c.Assert(statusCode, check.Equals, http.StatusNoContent)
|
c.Assert(statusCode, check.Equals, http.StatusNoContent)
|
||||||
|
|
||||||
if err := waitInspect(containerID, "{{ .State.Running }}", "false", 5); err != nil {
|
if err := waitInspect(containerID, "{{ .State.Running }}", "false", 5*time.Second); err != nil {
|
||||||
c.Fatal(err)
|
c.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/go-check/check"
|
"github.com/go-check/check"
|
||||||
)
|
)
|
||||||
|
@ -132,7 +133,7 @@ func (s *DockerSuite) TestContainerRestartwithGoodContainer(c *check.C) {
|
||||||
out, _ := dockerCmd(c, "run", "-d", "--restart=on-failure:3", "busybox", "true")
|
out, _ := dockerCmd(c, "run", "-d", "--restart=on-failure:3", "busybox", "true")
|
||||||
|
|
||||||
id := strings.TrimSpace(string(out))
|
id := strings.TrimSpace(string(out))
|
||||||
if err := waitInspect(id, "{{ .State.Restarting }} {{ .State.Running }}", "false false", 5); err != nil {
|
if err := waitInspect(id, "{{ .State.Restarting }} {{ .State.Running }}", "false false", 5*time.Second); err != nil {
|
||||||
c.Fatal(err)
|
c.Fatal(err)
|
||||||
}
|
}
|
||||||
count, err := inspectField(id, "RestartCount")
|
count, err := inspectField(id, "RestartCount")
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -15,7 +15,7 @@ func (s *DockerSuite) TestWaitNonBlockedExitZero(c *check.C) {
|
||||||
out, _ := dockerCmd(c, "run", "-d", "busybox", "sh", "-c", "true")
|
out, _ := dockerCmd(c, "run", "-d", "busybox", "sh", "-c", "true")
|
||||||
containerID := strings.TrimSpace(out)
|
containerID := strings.TrimSpace(out)
|
||||||
|
|
||||||
if err := waitInspect(containerID, "{{.State.Running}}", "false", 1); err != nil {
|
if err := waitInspect(containerID, "{{.State.Running}}", "false", 1*time.Second); err != nil {
|
||||||
c.Fatal("Container should have stopped by now")
|
c.Fatal("Container should have stopped by now")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ func (s *DockerSuite) TestWaitNonBlockedExitRandom(c *check.C) {
|
||||||
out, _ := dockerCmd(c, "run", "-d", "busybox", "sh", "-c", "exit 99")
|
out, _ := dockerCmd(c, "run", "-d", "busybox", "sh", "-c", "exit 99")
|
||||||
containerID := strings.TrimSpace(out)
|
containerID := strings.TrimSpace(out)
|
||||||
|
|
||||||
if err := waitInspect(containerID, "{{.State.Running}}", "false", 1); err != nil {
|
if err := waitInspect(containerID, "{{.State.Running}}", "false", 1*time.Second); err != nil {
|
||||||
c.Fatal("Container should have stopped by now")
|
c.Fatal("Container should have stopped by now")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,19 @@ var (
|
||||||
// of the daemon. This is initialised in docker_utils by sending
|
// of the daemon. This is initialised in docker_utils by sending
|
||||||
// a version call to the daemon and examining the response header.
|
// a version call to the daemon and examining the response header.
|
||||||
daemonPlatform string
|
daemonPlatform string
|
||||||
|
|
||||||
|
// daemonDefaultImage is the name of the default image to use when running
|
||||||
|
// tests. This is platform dependent.
|
||||||
|
daemonDefaultImage string
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// WindowsBaseImage is the name of the base image for Windows testing
|
||||||
|
WindowsBaseImage = "windowsservercore"
|
||||||
|
|
||||||
|
// DefaultImage is the name of the base image for the majority of tests that
|
||||||
|
// are run across suites
|
||||||
|
DefaultImage = "busybox"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
|
@ -1402,14 +1402,20 @@ func waitForContainer(contID string, args ...string) error {
|
||||||
|
|
||||||
// waitRun will wait for the specified container to be running, maximum 5 seconds.
|
// waitRun will wait for the specified container to be running, maximum 5 seconds.
|
||||||
func waitRun(contID string) error {
|
func waitRun(contID string) error {
|
||||||
return waitInspect(contID, "{{.State.Running}}", "true", 5)
|
return waitInspect(contID, "{{.State.Running}}", "true", 5*time.Second)
|
||||||
|
}
|
||||||
|
|
||||||
|
// waitExited will wait for the specified container to state exit, subject
|
||||||
|
// to a maximum time limit in seconds supplied by the caller
|
||||||
|
func waitExited(contID string, duration time.Duration) error {
|
||||||
|
return waitInspect(contID, "{{.State.Status}}", "exited", duration)
|
||||||
}
|
}
|
||||||
|
|
||||||
// waitInspect will wait for the specified container to have the specified string
|
// waitInspect will wait for the specified container to have the specified string
|
||||||
// in the inspect output. It will wait until the specified timeout (in seconds)
|
// in the inspect output. It will wait until the specified timeout (in seconds)
|
||||||
// is reached.
|
// is reached.
|
||||||
func waitInspect(name, expr, expected string, timeout int) error {
|
func waitInspect(name, expr, expected string, timeout time.Duration) error {
|
||||||
after := time.After(time.Duration(timeout) * time.Second)
|
after := time.After(timeout)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
cmd := exec.Command(dockerBinary, "inspect", "-f", expr, name)
|
cmd := exec.Command(dockerBinary, "inspect", "-f", expr, name)
|
||||||
|
|
Loading…
Add table
Reference in a new issue