docker_api_inspect_unix_test.go 1.1 KB

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