소스 검색

Merge pull request #16312 from Microsoft/10662-startwindowscli

Windows: First part of CI tests (docker run)
Brian Goff 9 년 전
부모
커밋
04d76d898a

+ 5 - 5
integration-cli/docker_api_containers_test.go

@@ -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 - 1
integration-cli/docker_cli_restart_test.go

@@ -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")

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 224 - 62
integration-cli/docker_cli_run_test.go


+ 2 - 2
integration-cli/docker_cli_wait_test.go

@@ -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")
 	}
 	}
 
 

+ 13 - 0
integration-cli/docker_test_vars.go

@@ -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() {

+ 9 - 3
integration-cli/docker_utils.go

@@ -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 {
-	after := time.After(time.Duration(timeout) * time.Second)
+func waitInspect(name, expr, expected string, timeout time.Duration) error {
+	after := time.After(timeout)
 
 
 	for {
 	for {
 		cmd := exec.Command(dockerBinary, "inspect", "-f", expr, name)
 		cmd := exec.Command(dockerBinary, "inspect", "-f", expr, name)

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.