docker_cli_info_test.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package main
  2. import (
  3. "fmt"
  4. "github.com/docker/docker/pkg/integration/checker"
  5. "github.com/docker/docker/utils"
  6. "github.com/go-check/check"
  7. )
  8. // ensure docker info succeeds
  9. func (s *DockerSuite) TestInfoEnsureSucceeds(c *check.C) {
  10. out, _ := dockerCmd(c, "info")
  11. // always shown fields
  12. stringsToCheck := []string{
  13. "ID:",
  14. "Containers:",
  15. "Images:",
  16. "Execution Driver:",
  17. "Logging Driver:",
  18. "Operating System:",
  19. "CPUs:",
  20. "Total Memory:",
  21. "Kernel Version:",
  22. "Storage Driver:",
  23. }
  24. if utils.ExperimentalBuild() {
  25. stringsToCheck = append(stringsToCheck, "Experimental: true")
  26. }
  27. for _, linePrefix := range stringsToCheck {
  28. c.Assert(out, checker.Contains, linePrefix, check.Commentf("couldn't find string %v in output", linePrefix))
  29. }
  30. }
  31. // TestInfoDiscoveryBackend verifies that a daemon run with `--cluster-advertise` and
  32. // `--cluster-store` properly show the backend's endpoint in info output.
  33. func (s *DockerSuite) TestInfoDiscoveryBackend(c *check.C) {
  34. testRequires(c, SameHostDaemon)
  35. d := NewDaemon(c)
  36. discoveryBackend := "consul://consuladdr:consulport/some/path"
  37. err := d.Start(fmt.Sprintf("--cluster-store=%s", discoveryBackend), "--cluster-advertise=foo")
  38. c.Assert(err, checker.IsNil)
  39. defer d.Stop()
  40. out, err := d.Cmd("info")
  41. c.Assert(err, checker.IsNil)
  42. c.Assert(out, checker.Contains, fmt.Sprintf("Cluster store: %s\n", discoveryBackend))
  43. }