7d193ef1f3
Use `pkg/discovery` to provide nodes discovery between daemon instances. The functionality is driven by two different command-line flags: the experimental `--cluster-store` (previously `--kv-store`) and `--cluster-advertise`. It can be used in two ways by interested components: 1. Externally by calling the `/info` API and examining the cluster store field. The `pkg/discovery` package can then be used to hit the same endpoint and watch for appearing or disappearing nodes. That is the method that will for example be used by Swarm. 2. Internally by using the `Daemon.discoveryWatcher` instance. That is the method that will for example be used by libnetwork. Signed-off-by: Arnaud Porterie <arnaud.porterie@docker.com>
56 lines
1.4 KiB
Go
56 lines
1.4 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/docker/docker/pkg/integration/checker"
|
|
"github.com/docker/docker/utils"
|
|
"github.com/go-check/check"
|
|
)
|
|
|
|
// ensure docker info succeeds
|
|
func (s *DockerSuite) TestInfoEnsureSucceeds(c *check.C) {
|
|
out, _ := dockerCmd(c, "info")
|
|
|
|
// always shown fields
|
|
stringsToCheck := []string{
|
|
"ID:",
|
|
"Containers:",
|
|
"Images:",
|
|
"Execution Driver:",
|
|
"Logging Driver:",
|
|
"Operating System:",
|
|
"CPUs:",
|
|
"Total Memory:",
|
|
"Kernel Version:",
|
|
"Storage Driver:",
|
|
}
|
|
|
|
if utils.ExperimentalBuild() {
|
|
stringsToCheck = append(stringsToCheck, "Experimental: true")
|
|
}
|
|
|
|
for _, linePrefix := range stringsToCheck {
|
|
if !strings.Contains(out, linePrefix) {
|
|
c.Errorf("couldn't find string %v in output", linePrefix)
|
|
}
|
|
}
|
|
}
|
|
|
|
// 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"
|
|
if err := d.Start(fmt.Sprintf("--cluster-store=%s", discoveryBackend), "--cluster-advertise=foo"); err != nil {
|
|
c.Fatal(err)
|
|
}
|
|
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))
|
|
}
|