docker_api_inspect_unix_test.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // +build !windows
  2. package main
  3. import (
  4. "encoding/json"
  5. "fmt"
  6. "net/http"
  7. "github.com/docker/docker/integration-cli/checker"
  8. "github.com/docker/docker/integration-cli/request"
  9. "github.com/go-check/check"
  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. status, body, err := request.SockRequest("GET", fmt.Sprintf("/v1.19/containers/%s/json", name), nil, daemonHost())
  18. c.Assert(status, check.Equals, http.StatusOK)
  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. }