docker_api_inspect_unix_test.go 1.2 KB

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