2014-02-25 16:17:48 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
2015-04-18 16:46:47 +00:00
|
|
|
|
2015-10-09 03:10:09 +00:00
|
|
|
"github.com/docker/docker/pkg/integration/checker"
|
2015-04-18 16:46:47 +00:00
|
|
|
"github.com/go-check/check"
|
2014-02-25 16:17:48 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// ensure docker version works
|
2015-04-18 16:46:47 +00:00
|
|
|
func (s *DockerSuite) TestVersionEnsureSucceeds(c *check.C) {
|
2015-07-20 06:44:22 +00:00
|
|
|
out, _ := dockerCmd(c, "version")
|
2015-06-19 17:03:13 +00:00
|
|
|
stringsToCheck := map[string]int{
|
|
|
|
"Client:": 1,
|
|
|
|
"Server:": 1,
|
|
|
|
" Version:": 2,
|
|
|
|
" API version:": 2,
|
|
|
|
" Go version:": 2,
|
|
|
|
" Git commit:": 2,
|
|
|
|
" OS/Arch:": 2,
|
|
|
|
" Built:": 2,
|
2014-04-02 00:30:02 +00:00
|
|
|
}
|
2014-02-25 16:17:48 +00:00
|
|
|
|
2015-06-19 17:03:13 +00:00
|
|
|
for k, v := range stringsToCheck {
|
2015-10-09 03:10:09 +00:00
|
|
|
c.Assert(strings.Count(out, k), checker.Equals, v, check.Commentf("The count of %v in %s does not match excepted", k, out))
|
2014-02-25 16:17:48 +00:00
|
|
|
}
|
|
|
|
}
|
2015-08-27 22:08:00 +00:00
|
|
|
|
|
|
|
// ensure the Windows daemon return the correct platform string
|
|
|
|
func (s *DockerSuite) TestVersionPlatform_w(c *check.C) {
|
|
|
|
testRequires(c, DaemonIsWindows)
|
|
|
|
testVersionPlatform(c, "windows/amd64")
|
|
|
|
}
|
|
|
|
|
|
|
|
// ensure the Linux daemon return the correct platform string
|
|
|
|
func (s *DockerSuite) TestVersionPlatform_l(c *check.C) {
|
|
|
|
testRequires(c, DaemonIsLinux)
|
2015-02-24 18:33:18 +00:00
|
|
|
testVersionPlatform(c, "linux")
|
2015-08-27 22:08:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func testVersionPlatform(c *check.C, platform string) {
|
|
|
|
out, _ := dockerCmd(c, "version")
|
|
|
|
expected := "OS/Arch: " + platform
|
|
|
|
|
|
|
|
split := strings.Split(out, "\n")
|
2015-10-09 03:10:09 +00:00
|
|
|
c.Assert(len(split) >= 14, checker.Equals, true, check.Commentf("got %d lines from version", len(split)))
|
2015-08-27 22:08:00 +00:00
|
|
|
|
|
|
|
// Verify the second 'OS/Arch' matches the platform. Experimental has
|
|
|
|
// more lines of output than 'regular'
|
|
|
|
bFound := false
|
|
|
|
for i := 14; i < len(split); i++ {
|
|
|
|
if strings.Contains(split[i], expected) {
|
|
|
|
bFound = true
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
2015-10-09 03:10:09 +00:00
|
|
|
c.Assert(bFound, checker.Equals, true, check.Commentf("Could not find server '%s' in '%s'", expected, out))
|
2015-08-27 22:08:00 +00:00
|
|
|
}
|