docker_api_inspect_unix_test.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // +build !windows
  2. package main
  3. import (
  4. "encoding/json"
  5. "fmt"
  6. "net/http"
  7. "github.com/docker/docker/pkg/integration/checker"
  8. "github.com/go-check/check"
  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. status, body, err := sockRequest("GET", fmt.Sprintf("/v1.19/containers/%s/json", name), nil)
  17. c.Assert(status, check.Equals, http.StatusOK)
  18. c.Assert(err, check.IsNil)
  19. var inspectJSON map[string]interface{}
  20. err = json.Unmarshal(body, &inspectJSON)
  21. c.Assert(err, checker.IsNil, check.Commentf("unable to unmarshal body for version 1.19"))
  22. config, ok := inspectJSON["Config"]
  23. c.Assert(ok, checker.True, check.Commentf("Unable to find 'Config'"))
  24. cfg := config.(map[string]interface{})
  25. _, ok = cfg["Cpuset"]
  26. c.Assert(ok, checker.True, check.Commentf("Api version 1.19 expected to include Cpuset in 'Config'"))
  27. }