1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/integration-cli/docker_api_info_test.go
Sebastiaan van Stijn 6400ce8f0a
Fix missing "--version" argument
Commit 858b4b44c8 added
support for obtaining the runtime version
if a custom path was set, but accidentally
removed the "--version" flag.

This patch restores the flag, and adds an integration
test to verify the behavior..

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2017-06-11 23:31:47 +02:00

76 lines
2 KiB
Go

package main
import (
"net/http"
"encoding/json"
"github.com/docker/docker/api/types"
"github.com/docker/docker/integration-cli/checker"
"github.com/docker/docker/integration-cli/request"
"github.com/docker/docker/pkg/testutil"
"github.com/go-check/check"
)
func (s *DockerSuite) TestInfoAPI(c *check.C) {
endpoint := "/info"
status, body, err := request.SockRequest("GET", endpoint, nil, daemonHost())
c.Assert(status, checker.Equals, http.StatusOK)
c.Assert(err, checker.IsNil)
// always shown fields
stringsToCheck := []string{
"ID",
"Containers",
"ContainersRunning",
"ContainersPaused",
"ContainersStopped",
"Images",
"LoggingDriver",
"OperatingSystem",
"NCPU",
"OSType",
"Architecture",
"MemTotal",
"KernelVersion",
"Driver",
"ServerVersion",
"SecurityOptions"}
out := string(body)
for _, linePrefix := range stringsToCheck {
c.Assert(out, checker.Contains, linePrefix)
}
}
// TestInfoAPIRuncCommit tests that dockerd is able to obtain RunC version
// information, and that the version matches the expected version
func (s *DockerSuite) TestInfoAPIRuncCommit(c *check.C) {
testRequires(c, DaemonIsLinux) // Windows does not have RunC version information
res, body, err := request.Get("/v1.30/info")
c.Assert(res.StatusCode, checker.Equals, http.StatusOK)
c.Assert(err, checker.IsNil)
b, err := testutil.ReadBody(body)
c.Assert(err, checker.IsNil)
var i types.Info
c.Assert(json.Unmarshal(b, &i), checker.IsNil)
c.Assert(i.RuncCommit.ID, checker.Not(checker.Equals), "N/A")
c.Assert(i.RuncCommit.ID, checker.Equals, i.RuncCommit.Expected)
}
func (s *DockerSuite) TestInfoAPIVersioned(c *check.C) {
testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later
endpoint := "/v1.20/info"
status, body, err := request.SockRequest("GET", endpoint, nil, daemonHost())
c.Assert(status, checker.Equals, http.StatusOK)
c.Assert(err, checker.IsNil)
out := string(body)
c.Assert(out, checker.Contains, "ExecutionDriver")
c.Assert(out, checker.Contains, "not supported")
}