1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #26172 from Microsoft/jjh/testinspect

Windows: Enable multiple TestInspect tests
This commit is contained in:
Vincent Demeester 2016-09-01 19:46:19 +02:00 committed by GitHub
commit a19bdec6f0

View file

@ -36,15 +36,12 @@ func (s *DockerSuite) TestInspectImage(c *check.C) {
}
func (s *DockerSuite) TestInspectInt64(c *check.C) {
testRequires(c, DaemonIsLinux)
dockerCmd(c, "run", "-d", "-m=300M", "--name", "inspectTest", "busybox", "true")
inspectOut := inspectField(c, "inspectTest", "HostConfig.Memory")
c.Assert(inspectOut, checker.Equals, "314572800")
}
func (s *DockerSuite) TestInspectDefault(c *check.C) {
testRequires(c, DaemonIsLinux)
//Both the container and image are named busybox. docker inspect will fetch the container JSON.
//If the container JSON is not available, it will go for the image JSON.
@ -56,14 +53,18 @@ func (s *DockerSuite) TestInspectDefault(c *check.C) {
}
func (s *DockerSuite) TestInspectStatus(c *check.C) {
if daemonPlatform != "windows" {
defer unpauseAllContainers()
testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-d", "busybox", "top")
}
out, _ := runSleepingContainer(c, "-d")
out = strings.TrimSpace(out)
inspectOut := inspectField(c, out, "State.Status")
c.Assert(inspectOut, checker.Equals, "running")
// Windows does not support pause/unpause on Windows Server Containers.
// (RS1 does for Hyper-V Containers, but production CI is not setup for that)
if daemonPlatform != "windows" {
dockerCmd(c, "pause", out)
inspectOut = inspectField(c, out, "State.Status")
c.Assert(inspectOut, checker.Equals, "paused")
@ -71,6 +72,7 @@ func (s *DockerSuite) TestInspectStatus(c *check.C) {
dockerCmd(c, "unpause", out)
inspectOut = inspectField(c, out, "State.Status")
c.Assert(inspectOut, checker.Equals, "running")
}
dockerCmd(c, "stop", out)
inspectOut = inspectField(c, out, "State.Status")
@ -79,11 +81,9 @@ func (s *DockerSuite) TestInspectStatus(c *check.C) {
}
func (s *DockerSuite) TestInspectTypeFlagContainer(c *check.C) {
testRequires(c, DaemonIsLinux)
//Both the container and image are named busybox. docker inspect will fetch container
//JSON State.Running field. If the field is true, it's a container.
dockerCmd(c, "run", "--name=busybox", "-d", "busybox", "top")
runSleepingContainer(c, "--name=busybox", "-d")
formatStr := "--format={{.State.Running}}"
out, _ := dockerCmd(c, "inspect", "--type=container", formatStr, "busybox")
@ -91,7 +91,6 @@ func (s *DockerSuite) TestInspectTypeFlagContainer(c *check.C) {
}
func (s *DockerSuite) TestInspectTypeFlagWithNoContainer(c *check.C) {
testRequires(c, DaemonIsLinux)
//Run this test on an image named busybox. docker inspect will try to fetch container
//JSON. Since there is no container named busybox and --type=container, docker inspect will
//not try to get the image JSON. It will throw an error.
@ -104,7 +103,6 @@ func (s *DockerSuite) TestInspectTypeFlagWithNoContainer(c *check.C) {
}
func (s *DockerSuite) TestInspectTypeFlagWithImage(c *check.C) {
testRequires(c, DaemonIsLinux)
//Both the container and image are named busybox. docker inspect will fetch image
//JSON as --type=image. if there is no image with name busybox, docker inspect
//will throw an error.
@ -116,7 +114,6 @@ func (s *DockerSuite) TestInspectTypeFlagWithImage(c *check.C) {
}
func (s *DockerSuite) TestInspectTypeFlagWithInvalidValue(c *check.C) {
testRequires(c, DaemonIsLinux)
//Both the container and image are named busybox. docker inspect will fail
//as --type=foobar is not a valid value for the flag.
@ -145,7 +142,6 @@ func (s *DockerSuite) TestInspectImageFilterInt(c *check.C) {
}
func (s *DockerSuite) TestInspectContainerFilterInt(c *check.C) {
testRequires(c, DaemonIsLinux)
runCmd := exec.Command(dockerBinary, "run", "-i", "-a", "stdin", "busybox", "cat")
runCmd.Stdin = strings.NewReader("blahblah")
out, _, _, err := runCommandWithStdoutStderr(runCmd)
@ -270,7 +266,6 @@ func (s *DockerSuite) TestInspectNamedMountPoint(c *check.C) {
// #14947
func (s *DockerSuite) TestInspectTimesAsRFC3339Nano(c *check.C) {
testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-d", "busybox", "true")
id := strings.TrimSpace(out)
startedAt := inspectField(c, id, "State.StartedAt")
@ -292,7 +287,6 @@ func (s *DockerSuite) TestInspectTimesAsRFC3339Nano(c *check.C) {
// #15633
func (s *DockerSuite) TestInspectLogConfigNoType(c *check.C) {
testRequires(c, DaemonIsLinux)
dockerCmd(c, "create", "--name=test", "--log-opt", "max-file=42", "busybox")
var logConfig container.LogConfig
@ -373,11 +367,9 @@ func (s *DockerSuite) TestInspectStopWhenNotFound(c *check.C) {
}
func (s *DockerSuite) TestInspectHistory(c *check.C) {
testRequires(c, DaemonIsLinux)
dockerCmd(c, "run", "--name=testcont", "-d", "busybox", "top")
dockerCmd(c, "run", "--name=testcont", "busybox", "echo", "hello")
dockerCmd(c, "commit", "-m", "test comment", "testcont", "testimg")
out, _, err := dockerCmdWithError("inspect", "--format='{{.Comment}}'", "testimg")
c.Assert(err, check.IsNil)
c.Assert(out, checker.Contains, "test comment")
}
@ -406,7 +398,6 @@ func (s *DockerSuite) TestInspectContainerNetworkCustom(c *check.C) {
}
func (s *DockerSuite) TestInspectRootFS(c *check.C) {
testRequires(c, DaemonIsLinux)
out, _, err := dockerCmdWithError("inspect", "busybox")
c.Assert(err, check.IsNil)