2014-02-25 16:17:48 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2015-09-10 23:12:00 +00:00
|
|
|
"fmt"
|
2015-10-26 00:12:22 +00:00
|
|
|
"net"
|
2015-04-18 16:46:47 +00:00
|
|
|
|
2015-09-10 23:12:00 +00:00
|
|
|
"github.com/docker/docker/pkg/integration/checker"
|
2015-05-21 17:48:36 +00:00
|
|
|
"github.com/docker/docker/utils"
|
2015-04-18 16:46:47 +00:00
|
|
|
"github.com/go-check/check"
|
2014-02-25 16:17:48 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// ensure docker info succeeds
|
2015-04-18 16:46:47 +00:00
|
|
|
func (s *DockerSuite) TestInfoEnsureSucceeds(c *check.C) {
|
2015-07-20 06:55:40 +00:00
|
|
|
out, _ := dockerCmd(c, "info")
|
2014-02-25 16:17:48 +00:00
|
|
|
|
2015-04-09 11:01:39 +00:00
|
|
|
// always shown fields
|
|
|
|
stringsToCheck := []string{
|
|
|
|
"ID:",
|
|
|
|
"Containers:",
|
|
|
|
"Images:",
|
|
|
|
"Execution Driver:",
|
2015-06-13 07:39:19 +00:00
|
|
|
"OSType:",
|
|
|
|
"Architecture:",
|
2015-04-09 11:01:39 +00:00
|
|
|
"Logging Driver:",
|
|
|
|
"Operating System:",
|
|
|
|
"CPUs:",
|
|
|
|
"Total Memory:",
|
|
|
|
"Kernel Version:",
|
2015-05-21 17:48:36 +00:00
|
|
|
"Storage Driver:",
|
2015-10-23 06:08:26 +00:00
|
|
|
"Volume:",
|
|
|
|
"Network:",
|
2015-05-21 17:48:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if utils.ExperimentalBuild() {
|
|
|
|
stringsToCheck = append(stringsToCheck, "Experimental: true")
|
|
|
|
}
|
2014-02-25 16:17:48 +00:00
|
|
|
|
|
|
|
for _, linePrefix := range stringsToCheck {
|
2015-10-20 05:38:55 +00:00
|
|
|
c.Assert(out, checker.Contains, linePrefix, check.Commentf("couldn't find string %v in output", linePrefix))
|
2014-02-25 16:17:48 +00:00
|
|
|
}
|
|
|
|
}
|
2015-09-10 23:12:00 +00:00
|
|
|
|
|
|
|
// TestInfoDiscoveryBackend verifies that a daemon run with `--cluster-advertise` and
|
|
|
|
// `--cluster-store` properly show the backend's endpoint in info output.
|
|
|
|
func (s *DockerSuite) TestInfoDiscoveryBackend(c *check.C) {
|
|
|
|
testRequires(c, SameHostDaemon)
|
|
|
|
|
|
|
|
d := NewDaemon(c)
|
|
|
|
discoveryBackend := "consul://consuladdr:consulport/some/path"
|
2015-10-26 00:12:22 +00:00
|
|
|
discoveryAdvertise := "1.1.1.1:2375"
|
|
|
|
err := d.Start(fmt.Sprintf("--cluster-store=%s", discoveryBackend), fmt.Sprintf("--cluster-advertise=%s", discoveryAdvertise))
|
2015-10-20 05:38:55 +00:00
|
|
|
c.Assert(err, checker.IsNil)
|
2015-09-10 23:12:00 +00:00
|
|
|
defer d.Stop()
|
|
|
|
|
|
|
|
out, err := d.Cmd("info")
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
c.Assert(out, checker.Contains, fmt.Sprintf("Cluster store: %s\n", discoveryBackend))
|
2015-10-26 00:12:22 +00:00
|
|
|
c.Assert(out, checker.Contains, fmt.Sprintf("Cluster advertise: %s\n", discoveryAdvertise))
|
|
|
|
}
|
|
|
|
|
|
|
|
// TestInfoDiscoveryInvalidAdvertise verifies that a daemon run with
|
|
|
|
// an invalid `--cluster-advertise` configuration
|
|
|
|
func (s *DockerSuite) TestInfoDiscoveryInvalidAdvertise(c *check.C) {
|
|
|
|
testRequires(c, SameHostDaemon)
|
|
|
|
|
|
|
|
d := NewDaemon(c)
|
|
|
|
discoveryBackend := "consul://consuladdr:consulport/some/path"
|
|
|
|
|
|
|
|
// --cluster-advertise with an invalid string is an error
|
|
|
|
err := d.Start(fmt.Sprintf("--cluster-store=%s", discoveryBackend), "--cluster-advertise=invalid")
|
|
|
|
c.Assert(err, checker.Not(checker.IsNil))
|
|
|
|
|
|
|
|
// --cluster-advertise without --cluster-store is also an error
|
|
|
|
err = d.Start("--cluster-advertise=1.1.1.1:2375")
|
|
|
|
c.Assert(err, checker.Not(checker.IsNil))
|
|
|
|
}
|
|
|
|
|
|
|
|
// TestInfoDiscoveryAdvertiseInterfaceName verifies that a daemon run with `--cluster-advertise`
|
|
|
|
// configured with interface name properly show the advertise ip-address in info output.
|
|
|
|
func (s *DockerSuite) TestInfoDiscoveryAdvertiseInterfaceName(c *check.C) {
|
2015-12-24 15:18:23 +00:00
|
|
|
testRequires(c, SameHostDaemon, Network)
|
2015-10-26 00:12:22 +00:00
|
|
|
|
|
|
|
d := NewDaemon(c)
|
|
|
|
discoveryBackend := "consul://consuladdr:consulport/some/path"
|
|
|
|
discoveryAdvertise := "eth0"
|
|
|
|
|
|
|
|
err := d.Start(fmt.Sprintf("--cluster-store=%s", discoveryBackend), fmt.Sprintf("--cluster-advertise=%s:2375", discoveryAdvertise))
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
defer d.Stop()
|
|
|
|
|
|
|
|
iface, err := net.InterfaceByName(discoveryAdvertise)
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
addrs, err := iface.Addrs()
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
c.Assert(len(addrs), checker.GreaterThan, 0)
|
|
|
|
ip, _, err := net.ParseCIDR(addrs[0].String())
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
|
|
|
|
out, err := d.Cmd("info")
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
c.Assert(out, checker.Contains, fmt.Sprintf("Cluster store: %s\n", discoveryBackend))
|
|
|
|
c.Assert(out, checker.Contains, fmt.Sprintf("Cluster advertise: %s:2375\n", ip.String()))
|
2015-09-10 23:12:00 +00:00
|
|
|
}
|