2015-04-11 01:26:30 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2017-08-21 18:50:40 -04:00
|
|
|
"encoding/json"
|
2015-04-11 01:26:30 +08:00
|
|
|
"net/http"
|
2015-04-22 11:44:54 -07:00
|
|
|
|
2017-06-10 03:07:21 +02:00
|
|
|
"github.com/docker/docker/api/types"
|
2016-12-30 18:23:00 +01:00
|
|
|
"github.com/docker/docker/integration-cli/checker"
|
2016-12-30 10:49:36 +01:00
|
|
|
"github.com/docker/docker/integration-cli/request"
|
2015-04-22 11:44:54 -07:00
|
|
|
"github.com/go-check/check"
|
2015-04-11 01:26:30 +08:00
|
|
|
)
|
|
|
|
|
[nit] integration-cli: obey Go's naming convention
No substantial code change.
- Api --> API
- Cli --> CLI
- Http, Https --> HTTP, HTTPS
- Id --> ID
- Uid,Gid,Pid --> UID,PID,PID
- Ipam --> IPAM
- Tls --> TLS (TestDaemonNoTlsCliTlsVerifyWithEnv --> TestDaemonTLSVerifyIssue13964)
Didn't touch in this commit:
- Git: because it is officially "Git": https://git-scm.com/
- Tar: because it is officially "Tar": https://www.gnu.org/software/tar/
- Cpu, Nat, Mac, Ipc, Shm: for keeping a consistency with existing production code (not changable, for compatibility)
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2016-09-28 01:50:12 +00:00
|
|
|
func (s *DockerSuite) TestInfoAPI(c *check.C) {
|
2015-04-11 01:26:30 +08:00
|
|
|
endpoint := "/info"
|
|
|
|
|
2016-12-30 10:49:36 +01:00
|
|
|
status, body, err := request.SockRequest("GET", endpoint, nil, daemonHost())
|
2015-11-19 02:15:38 +01:00
|
|
|
c.Assert(status, checker.Equals, http.StatusOK)
|
|
|
|
c.Assert(err, checker.IsNil)
|
2015-04-11 01:26:30 +08:00
|
|
|
|
|
|
|
// always shown fields
|
|
|
|
stringsToCheck := []string{
|
|
|
|
"ID",
|
|
|
|
"Containers",
|
2015-10-27 21:12:33 +01:00
|
|
|
"ContainersRunning",
|
|
|
|
"ContainersPaused",
|
|
|
|
"ContainersStopped",
|
2015-04-11 01:26:30 +08:00
|
|
|
"Images",
|
|
|
|
"LoggingDriver",
|
|
|
|
"OperatingSystem",
|
|
|
|
"NCPU",
|
2015-06-13 09:39:19 +02:00
|
|
|
"OSType",
|
|
|
|
"Architecture",
|
2015-04-11 01:26:30 +08:00
|
|
|
"MemTotal",
|
|
|
|
"KernelVersion",
|
2015-09-21 12:23:54 +08:00
|
|
|
"Driver",
|
2016-03-29 04:10:37 +00:00
|
|
|
"ServerVersion",
|
|
|
|
"SecurityOptions"}
|
2015-04-11 01:26:30 +08:00
|
|
|
|
|
|
|
out := string(body)
|
|
|
|
for _, linePrefix := range stringsToCheck {
|
2015-11-19 02:15:38 +01:00
|
|
|
c.Assert(out, checker.Contains, linePrefix)
|
2015-04-11 01:26:30 +08:00
|
|
|
}
|
|
|
|
}
|
2016-10-21 11:43:00 +02:00
|
|
|
|
2017-06-10 03:07:21 +02:00
|
|
|
// 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)
|
|
|
|
|
2017-08-21 18:50:40 -04:00
|
|
|
b, err := request.ReadBody(body)
|
2017-06-10 03:07:21 +02:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
2016-10-21 11:43:00 +02:00
|
|
|
func (s *DockerSuite) TestInfoAPIVersioned(c *check.C) {
|
2016-10-31 10:15:43 -07:00
|
|
|
testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later
|
2016-10-21 11:43:00 +02:00
|
|
|
endpoint := "/v1.20/info"
|
|
|
|
|
2016-12-30 10:49:36 +01:00
|
|
|
status, body, err := request.SockRequest("GET", endpoint, nil, daemonHost())
|
2016-10-21 11:43:00 +02:00
|
|
|
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")
|
|
|
|
}
|