2018-03-01 17:51:11 -05:00
|
|
|
package system // import "github.com/docker/docker/integration/system"
|
2018-02-07 13:23:31 -05:00
|
|
|
|
|
|
|
import (
|
2018-04-19 18:30:59 -04:00
|
|
|
"context"
|
2018-02-07 13:23:31 -05:00
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
|
2018-08-21 08:06:06 -04:00
|
|
|
"github.com/docker/docker/internal/test/daemon"
|
2018-06-11 09:32:11 -04:00
|
|
|
"gotest.tools/assert"
|
|
|
|
is "gotest.tools/assert/cmp"
|
2018-08-02 16:24:51 -04:00
|
|
|
"gotest.tools/skip"
|
2018-02-07 13:23:31 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestInfoAPI(t *testing.T) {
|
2019-01-02 08:16:25 -05:00
|
|
|
defer setupTest(t)()
|
|
|
|
client := testEnv.APIClient()
|
2018-02-07 13:23:31 -05:00
|
|
|
|
|
|
|
info, err := client.Info(context.Background())
|
2018-03-13 15:28:34 -04:00
|
|
|
assert.NilError(t, err)
|
2018-02-07 13:23:31 -05:00
|
|
|
|
|
|
|
// always shown fields
|
|
|
|
stringsToCheck := []string{
|
|
|
|
"ID",
|
|
|
|
"Containers",
|
|
|
|
"ContainersRunning",
|
|
|
|
"ContainersPaused",
|
|
|
|
"ContainersStopped",
|
|
|
|
"Images",
|
|
|
|
"LoggingDriver",
|
|
|
|
"OperatingSystem",
|
|
|
|
"NCPU",
|
|
|
|
"OSType",
|
|
|
|
"Architecture",
|
|
|
|
"MemTotal",
|
|
|
|
"KernelVersion",
|
|
|
|
"Driver",
|
|
|
|
"ServerVersion",
|
2019-03-13 19:18:46 -04:00
|
|
|
"SecurityOptions"}
|
2018-02-07 13:23:31 -05:00
|
|
|
|
|
|
|
out := fmt.Sprintf("%+v", info)
|
|
|
|
for _, linePrefix := range stringsToCheck {
|
2018-03-13 15:28:34 -04:00
|
|
|
assert.Check(t, is.Contains(out, linePrefix))
|
2018-02-07 13:23:31 -05:00
|
|
|
}
|
|
|
|
}
|
2018-08-21 08:06:06 -04:00
|
|
|
|
|
|
|
func TestInfoAPIWarnings(t *testing.T) {
|
2018-12-29 14:46:33 -05:00
|
|
|
skip.If(t, testEnv.IsRemoteDaemon, "cannot run daemon when remote daemon")
|
2018-08-02 16:24:51 -04:00
|
|
|
skip.If(t, testEnv.DaemonInfo.OSType == "windows", "FIXME")
|
2018-08-21 08:06:06 -04:00
|
|
|
d := daemon.New(t)
|
2018-12-22 09:53:02 -05:00
|
|
|
c := d.NewClientT(t)
|
2018-08-21 08:06:06 -04:00
|
|
|
|
2018-10-30 18:17:00 -04:00
|
|
|
d.StartWithBusybox(t, "-H=0.0.0.0:23756", "-H="+d.Sock())
|
2018-08-21 08:06:06 -04:00
|
|
|
defer d.Stop(t)
|
|
|
|
|
2018-12-22 09:53:02 -05:00
|
|
|
info, err := c.Info(context.Background())
|
2018-08-21 08:06:06 -04:00
|
|
|
assert.NilError(t, err)
|
|
|
|
|
|
|
|
stringsToCheck := []string{
|
|
|
|
"Access to the remote API is equivalent to root access",
|
|
|
|
"http://0.0.0.0:23756",
|
|
|
|
}
|
|
|
|
|
|
|
|
out := fmt.Sprintf("%+v", info)
|
|
|
|
for _, linePrefix := range stringsToCheck {
|
|
|
|
assert.Check(t, is.Contains(out, linePrefix))
|
|
|
|
}
|
|
|
|
}
|