github.com/LazyboyChen7/engine@v17.12.1-ce-rc2+incompatible/integration-cli/docker_api_inspect_unix_test.go (about)

     1  // +build !windows
     2  
     3  package main
     4  
     5  import (
     6  	"encoding/json"
     7  
     8  	"github.com/docker/docker/integration-cli/checker"
     9  	"github.com/docker/docker/integration-cli/request"
    10  	"github.com/go-check/check"
    11  	"golang.org/x/net/context"
    12  )
    13  
    14  // #16665
    15  func (s *DockerSuite) TestInspectAPICpusetInConfigPre120(c *check.C) {
    16  	testRequires(c, DaemonIsLinux)
    17  	testRequires(c, cgroupCpuset)
    18  
    19  	name := "cpusetinconfig-pre120"
    20  	dockerCmd(c, "run", "--name", name, "--cpuset-cpus", "0", "busybox", "true")
    21  	cli, err := request.NewEnvClientWithVersion("v1.19")
    22  	c.Assert(err, checker.IsNil)
    23  	defer cli.Close()
    24  	_, body, err := cli.ContainerInspectWithRaw(context.Background(), name, false)
    25  	c.Assert(err, check.IsNil)
    26  
    27  	var inspectJSON map[string]interface{}
    28  	err = json.Unmarshal(body, &inspectJSON)
    29  	c.Assert(err, checker.IsNil, check.Commentf("unable to unmarshal body for version 1.19"))
    30  
    31  	config, ok := inspectJSON["Config"]
    32  	c.Assert(ok, checker.True, check.Commentf("Unable to find 'Config'"))
    33  	cfg := config.(map[string]interface{})
    34  	_, ok = cfg["Cpuset"]
    35  	c.Assert(ok, checker.True, check.Commentf("API version 1.19 expected to include Cpuset in 'Config'"))
    36  }