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