docker_api_inspect_unix_test.go 942 B

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