info_test.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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.IsRemoteDaemon, "cannot run daemon when remote daemon")
  41. skip.If(t, testEnv.DaemonInfo.OSType == "windows", "FIXME")
  42. d := daemon.New(t)
  43. c := d.NewClientT(t)
  44. d.StartWithBusybox(t, "-H=0.0.0.0:23756", "-H="+d.Sock())
  45. defer d.Stop(t)
  46. info, err := c.Info(context.Background())
  47. assert.NilError(t, err)
  48. stringsToCheck := []string{
  49. "Access to the remote API is equivalent to root access",
  50. "http://0.0.0.0:23756",
  51. }
  52. out := fmt.Sprintf("%+v", info)
  53. for _, linePrefix := range stringsToCheck {
  54. assert.Check(t, is.Contains(out, linePrefix))
  55. }
  56. }