docker_cli_info_test.go 1.4 KB

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