info_test.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package system // import "github.com/docker/docker/integration/system"
  2. import (
  3. "context"
  4. "fmt"
  5. "testing"
  6. "github.com/docker/docker/internal/test/daemon"
  7. "gotest.tools/assert"
  8. is "gotest.tools/assert/cmp"
  9. "gotest.tools/skip"
  10. )
  11. func TestInfoAPI(t *testing.T) {
  12. defer setupTest(t)()
  13. client := testEnv.APIClient()
  14. info, err := client.Info(context.Background())
  15. assert.NilError(t, err)
  16. // always shown fields
  17. stringsToCheck := []string{
  18. "ID",
  19. "Containers",
  20. "ContainersRunning",
  21. "ContainersPaused",
  22. "ContainersStopped",
  23. "Images",
  24. "LoggingDriver",
  25. "OperatingSystem",
  26. "NCPU",
  27. "OSType",
  28. "Architecture",
  29. "MemTotal",
  30. "KernelVersion",
  31. "Driver",
  32. "ServerVersion",
  33. "SecurityOptions"}
  34. out := fmt.Sprintf("%+v", info)
  35. for _, linePrefix := range stringsToCheck {
  36. assert.Check(t, is.Contains(out, linePrefix))
  37. }
  38. }
  39. func TestInfoAPIWarnings(t *testing.T) {
  40. skip.If(t, testEnv.DaemonInfo.OSType == "windows", "FIXME")
  41. d := daemon.New(t)
  42. c := d.NewClientT(t)
  43. d.StartWithBusybox(t, "-H=0.0.0.0:23756", "-H="+d.Sock())
  44. defer d.Stop(t)
  45. info, err := c.Info(context.Background())
  46. assert.NilError(t, err)
  47. stringsToCheck := []string{
  48. "Access to the remote API is equivalent to root access",
  49. "http://0.0.0.0:23756",
  50. }
  51. out := fmt.Sprintf("%+v", info)
  52. for _, linePrefix := range stringsToCheck {
  53. assert.Check(t, is.Contains(out, linePrefix))
  54. }
  55. }