docker_api_inspect_unix_test.go 1.1 KB

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