Merge pull request #36854 from vdemeester/integration-swarm-more-in-internal

[test/integration] Small daemon refactoring and add swarm init/join helpers
This commit is contained in:
Anusha Ragunathan 2018-04-16 12:49:49 -07:00 committed by GitHub
commit c65d365eb3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 129 additions and 167 deletions

View File

@ -13,7 +13,6 @@ import (
"testing" "testing"
"time" "time"
"github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/checker"
"github.com/docker/docker/integration-cli/cli" "github.com/docker/docker/integration-cli/cli"
"github.com/docker/docker/integration-cli/cli/build/fakestorage" "github.com/docker/docker/integration-cli/cli/build/fakestorage"
@ -129,9 +128,7 @@ func (s *DockerRegistrySuite) SetUpTest(c *check.C) {
testRequires(c, DaemonIsLinux, RegistryHosting, SameHostDaemon) testRequires(c, DaemonIsLinux, RegistryHosting, SameHostDaemon)
s.reg = registry.NewV2(c) s.reg = registry.NewV2(c)
s.reg.WaitReady(c) s.reg.WaitReady(c)
s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
Experimental: testEnv.DaemonInfo.ExperimentalBuild,
})
} }
func (s *DockerRegistrySuite) TearDownTest(c *check.C) { func (s *DockerRegistrySuite) TearDownTest(c *check.C) {
@ -164,9 +161,7 @@ func (s *DockerSchema1RegistrySuite) SetUpTest(c *check.C) {
testRequires(c, DaemonIsLinux, RegistryHosting, NotArm64, SameHostDaemon) testRequires(c, DaemonIsLinux, RegistryHosting, NotArm64, SameHostDaemon)
s.reg = registry.NewV2(c, registry.Schema1) s.reg = registry.NewV2(c, registry.Schema1)
s.reg.WaitReady(c) s.reg.WaitReady(c)
s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
Experimental: testEnv.DaemonInfo.ExperimentalBuild,
})
} }
func (s *DockerSchema1RegistrySuite) TearDownTest(c *check.C) { func (s *DockerSchema1RegistrySuite) TearDownTest(c *check.C) {
@ -199,9 +194,7 @@ func (s *DockerRegistryAuthHtpasswdSuite) SetUpTest(c *check.C) {
testRequires(c, DaemonIsLinux, RegistryHosting, SameHostDaemon) testRequires(c, DaemonIsLinux, RegistryHosting, SameHostDaemon)
s.reg = registry.NewV2(c, registry.Htpasswd) s.reg = registry.NewV2(c, registry.Htpasswd)
s.reg.WaitReady(c) s.reg.WaitReady(c)
s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
Experimental: testEnv.DaemonInfo.ExperimentalBuild,
})
} }
func (s *DockerRegistryAuthHtpasswdSuite) TearDownTest(c *check.C) { func (s *DockerRegistryAuthHtpasswdSuite) TearDownTest(c *check.C) {
@ -234,9 +227,7 @@ func (s *DockerRegistryAuthTokenSuite) OnTimeout(c *check.C) {
func (s *DockerRegistryAuthTokenSuite) SetUpTest(c *check.C) { func (s *DockerRegistryAuthTokenSuite) SetUpTest(c *check.C) {
testRequires(c, DaemonIsLinux, RegistryHosting, SameHostDaemon) testRequires(c, DaemonIsLinux, RegistryHosting, SameHostDaemon)
s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
Experimental: testEnv.DaemonInfo.ExperimentalBuild,
})
} }
func (s *DockerRegistryAuthTokenSuite) TearDownTest(c *check.C) { func (s *DockerRegistryAuthTokenSuite) TearDownTest(c *check.C) {
@ -276,9 +267,7 @@ func (s *DockerDaemonSuite) OnTimeout(c *check.C) {
func (s *DockerDaemonSuite) SetUpTest(c *check.C) { func (s *DockerDaemonSuite) SetUpTest(c *check.C) {
testRequires(c, DaemonIsLinux, SameHostDaemon) testRequires(c, DaemonIsLinux, SameHostDaemon)
s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
Experimental: testEnv.DaemonInfo.ExperimentalBuild,
})
} }
func (s *DockerDaemonSuite) TearDownTest(c *check.C) { func (s *DockerDaemonSuite) TearDownTest(c *check.C) {
@ -333,26 +322,18 @@ func (s *DockerSwarmSuite) SetUpTest(c *check.C) {
} }
func (s *DockerSwarmSuite) AddDaemon(c *check.C, joinSwarm, manager bool) *daemon.Daemon { func (s *DockerSwarmSuite) AddDaemon(c *check.C, joinSwarm, manager bool) *daemon.Daemon {
d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ d := daemon.New(c, dockerBinary, dockerdBinary,
Experimental: testEnv.DaemonInfo.ExperimentalBuild, testdaemon.WithEnvironment(testEnv.Execution),
}, testdaemon.WithSwarmPort(defaultSwarmPort+s.portIndex)) testdaemon.WithSwarmPort(defaultSwarmPort+s.portIndex),
args := []string{"--iptables=false", "--swarm-default-advertise-addr=lo"} // avoid networking conflicts )
d.StartWithBusybox(c, args...)
if joinSwarm { if joinSwarm {
if len(s.daemons) > 0 { if len(s.daemons) > 0 {
tokens := s.daemons[0].JoinTokens(c) d.StartAndSwarmJoin(c, s.daemons[0].Daemon, manager)
token := tokens.Worker
if manager {
token = tokens.Manager
}
d.SwarmJoin(c, swarm.JoinRequest{
RemoteAddrs: []string{s.daemons[0].SwarmListenAddr()},
JoinToken: token,
})
} else { } else {
d.SwarmInit(c, swarm.InitRequest{}) d.StartAndSwarmInit(c)
} }
} else {
d.StartWithBusybox(c, "--iptables=false", "--swarm-default-advertise-addr=lo")
} }
s.portIndex++ s.portIndex++

View File

@ -30,21 +30,12 @@ type Daemon struct {
dockerBinary string dockerBinary string
} }
// Config holds docker daemon integration configuration
type Config struct {
Experimental bool
}
// New returns a Daemon instance to be used for testing. // New returns a Daemon instance to be used for testing.
// This will create a directory such as d123456789 in the folder specified by $DOCKER_INTEGRATION_DAEMON_DEST or $DEST. // This will create a directory such as d123456789 in the folder specified by $DOCKER_INTEGRATION_DAEMON_DEST or $DEST.
// The daemon will not automatically start. // The daemon will not automatically start.
func New(t testingT, dockerBinary string, dockerdBinary string, config Config, ops ...func(*daemon.Daemon)) *Daemon { func New(t testingT, dockerBinary string, dockerdBinary string, ops ...func(*daemon.Daemon)) *Daemon {
ops = append(ops, daemon.WithDockerdBinary(dockerdBinary)) ops = append(ops, daemon.WithDockerdBinary(dockerdBinary))
if config.Experimental {
ops = append(ops, daemon.WithExperimental)
}
d := daemon.New(t, ops...) d := daemon.New(t, ops...)
return &Daemon{ return &Daemon{
Daemon: d, Daemon: d,
dockerBinary: dockerBinary, dockerBinary: dockerBinary,

View File

@ -32,6 +32,7 @@ import (
"github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/checker"
"github.com/docker/docker/integration-cli/cli" "github.com/docker/docker/integration-cli/cli"
"github.com/docker/docker/integration-cli/daemon" "github.com/docker/docker/integration-cli/daemon"
testdaemon "github.com/docker/docker/internal/test/daemon"
"github.com/docker/docker/opts" "github.com/docker/docker/opts"
"github.com/docker/docker/pkg/mount" "github.com/docker/docker/pkg/mount"
"github.com/docker/docker/pkg/stringid" "github.com/docker/docker/pkg/stringid"
@ -1432,9 +1433,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithSocketAsVolume(c *check.C) {
// os.Kill should kill daemon ungracefully, leaving behind container mounts. // os.Kill should kill daemon ungracefully, leaving behind container mounts.
// A subsequent daemon restart should clean up said mounts. // A subsequent daemon restart should clean up said mounts.
func (s *DockerDaemonSuite) TestCleanupMountsAfterDaemonAndContainerKill(c *check.C) { func (s *DockerDaemonSuite) TestCleanupMountsAfterDaemonAndContainerKill(c *check.C) {
d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
Experimental: testEnv.DaemonInfo.ExperimentalBuild,
})
d.StartWithBusybox(c) d.StartWithBusybox(c)
out, err := d.Cmd("run", "-d", "busybox", "top") out, err := d.Cmd("run", "-d", "busybox", "top")
@ -1472,9 +1471,7 @@ func (s *DockerDaemonSuite) TestCleanupMountsAfterDaemonAndContainerKill(c *chec
// os.Interrupt should perform a graceful daemon shutdown and hence cleanup mounts. // os.Interrupt should perform a graceful daemon shutdown and hence cleanup mounts.
func (s *DockerDaemonSuite) TestCleanupMountsAfterGracefulShutdown(c *check.C) { func (s *DockerDaemonSuite) TestCleanupMountsAfterGracefulShutdown(c *check.C) {
d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
Experimental: testEnv.DaemonInfo.ExperimentalBuild,
})
d.StartWithBusybox(c) d.StartWithBusybox(c)
out, err := d.Cmd("run", "-d", "busybox", "top") out, err := d.Cmd("run", "-d", "busybox", "top")
@ -1693,9 +1690,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartLocalVolumes(c *check.C) {
// FIXME(vdemeester) should be a unit test // FIXME(vdemeester) should be a unit test
func (s *DockerDaemonSuite) TestDaemonCorruptedLogDriverAddress(c *check.C) { func (s *DockerDaemonSuite) TestDaemonCorruptedLogDriverAddress(c *check.C) {
d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
Experimental: testEnv.DaemonInfo.ExperimentalBuild,
})
c.Assert(d.StartWithError("--log-driver=syslog", "--log-opt", "syslog-address=corrupted:42"), check.NotNil) c.Assert(d.StartWithError("--log-driver=syslog", "--log-opt", "syslog-address=corrupted:42"), check.NotNil)
expected := "syslog-address should be in form proto://address" expected := "syslog-address should be in form proto://address"
icmd.RunCommand("grep", expected, d.LogFileName()).Assert(c, icmd.Success) icmd.RunCommand("grep", expected, d.LogFileName()).Assert(c, icmd.Success)
@ -1703,9 +1698,7 @@ func (s *DockerDaemonSuite) TestDaemonCorruptedLogDriverAddress(c *check.C) {
// FIXME(vdemeester) should be a unit test // FIXME(vdemeester) should be a unit test
func (s *DockerDaemonSuite) TestDaemonCorruptedFluentdAddress(c *check.C) { func (s *DockerDaemonSuite) TestDaemonCorruptedFluentdAddress(c *check.C) {
d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
Experimental: testEnv.DaemonInfo.ExperimentalBuild,
})
c.Assert(d.StartWithError("--log-driver=fluentd", "--log-opt", "fluentd-address=corrupted:c"), check.NotNil) c.Assert(d.StartWithError("--log-driver=fluentd", "--log-opt", "fluentd-address=corrupted:c"), check.NotNil)
expected := "invalid fluentd-address corrupted:c: " expected := "invalid fluentd-address corrupted:c: "
icmd.RunCommand("grep", expected, d.LogFileName()).Assert(c, icmd.Success) icmd.RunCommand("grep", expected, d.LogFileName()).Assert(c, icmd.Success)
@ -3080,9 +3073,7 @@ func (s *DockerDaemonSuite) TestDaemonIpcModeShareableFromConfig(c *check.C) {
} }
func testDaemonStartIpcMode(c *check.C, from, mode string, valid bool) { func testDaemonStartIpcMode(c *check.C, from, mode string, valid bool) {
d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
Experimental: testEnv.DaemonInfo.ExperimentalBuild,
})
c.Logf("Checking IpcMode %s set from %s\n", mode, from) c.Logf("Checking IpcMode %s set from %s\n", mode, from)
var serr error var serr error
switch from { switch from {
@ -3183,7 +3174,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartIpcMode(c *check.C) {
// the daemon from starting // the daemon from starting
func (s *DockerDaemonSuite) TestFailedPluginRemove(c *check.C) { func (s *DockerDaemonSuite) TestFailedPluginRemove(c *check.C) {
testRequires(c, DaemonIsLinux, IsAmd64, SameHostDaemon) testRequires(c, DaemonIsLinux, IsAmd64, SameHostDaemon)
d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{}) d := daemon.New(c, dockerBinary, dockerdBinary)
d.Start(c) d.Start(c)
cli, err := client.NewClient(d.Sock(), api.DefaultVersion, nil, nil) cli, err := client.NewClient(d.Sock(), api.DefaultVersion, nil, nil)
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)

View File

@ -15,6 +15,7 @@ import (
"github.com/docker/docker/daemon/graphdriver" "github.com/docker/docker/daemon/graphdriver"
"github.com/docker/docker/daemon/graphdriver/vfs" "github.com/docker/docker/daemon/graphdriver/vfs"
"github.com/docker/docker/integration-cli/daemon" "github.com/docker/docker/integration-cli/daemon"
testdaemon "github.com/docker/docker/internal/test/daemon"
"github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/archive"
"github.com/docker/docker/pkg/plugins" "github.com/docker/docker/pkg/plugins"
"github.com/go-check/check" "github.com/go-check/check"
@ -52,9 +53,7 @@ type graphEventsCounter struct {
} }
func (s *DockerExternalGraphdriverSuite) SetUpTest(c *check.C) { func (s *DockerExternalGraphdriverSuite) SetUpTest(c *check.C) {
s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
Experimental: testEnv.DaemonInfo.ExperimentalBuild,
})
} }
func (s *DockerExternalGraphdriverSuite) OnTimeout(c *check.C) { func (s *DockerExternalGraphdriverSuite) OnTimeout(c *check.C) {

View File

@ -18,6 +18,7 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/checker"
"github.com/docker/docker/integration-cli/daemon" "github.com/docker/docker/integration-cli/daemon"
testdaemon "github.com/docker/docker/internal/test/daemon"
"github.com/docker/docker/pkg/stringid" "github.com/docker/docker/pkg/stringid"
"github.com/docker/docker/volume" "github.com/docker/docker/volume"
"github.com/go-check/check" "github.com/go-check/check"
@ -51,9 +52,7 @@ type DockerExternalVolumeSuite struct {
func (s *DockerExternalVolumeSuite) SetUpTest(c *check.C) { func (s *DockerExternalVolumeSuite) SetUpTest(c *check.C) {
testRequires(c, SameHostDaemon) testRequires(c, SameHostDaemon)
s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
Experimental: testEnv.DaemonInfo.ExperimentalBuild,
})
s.ec = &eventCounter{} s.ec = &eventCounter{}
} }

View File

@ -8,6 +8,7 @@ import (
"github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/checker"
"github.com/docker/docker/integration-cli/daemon" "github.com/docker/docker/integration-cli/daemon"
testdaemon "github.com/docker/docker/internal/test/daemon"
"github.com/go-check/check" "github.com/go-check/check"
) )
@ -71,9 +72,7 @@ func (s *DockerSuite) TestInfoFormat(c *check.C) {
func (s *DockerSuite) TestInfoDiscoveryBackend(c *check.C) { func (s *DockerSuite) TestInfoDiscoveryBackend(c *check.C) {
testRequires(c, SameHostDaemon, DaemonIsLinux) testRequires(c, SameHostDaemon, DaemonIsLinux)
d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
Experimental: testEnv.DaemonInfo.ExperimentalBuild,
})
discoveryBackend := "consul://consuladdr:consulport/some/path" discoveryBackend := "consul://consuladdr:consulport/some/path"
discoveryAdvertise := "1.1.1.1:2375" discoveryAdvertise := "1.1.1.1:2375"
d.Start(c, fmt.Sprintf("--cluster-store=%s", discoveryBackend), fmt.Sprintf("--cluster-advertise=%s", discoveryAdvertise)) d.Start(c, fmt.Sprintf("--cluster-store=%s", discoveryBackend), fmt.Sprintf("--cluster-advertise=%s", discoveryAdvertise))
@ -90,9 +89,7 @@ func (s *DockerSuite) TestInfoDiscoveryBackend(c *check.C) {
func (s *DockerSuite) TestInfoDiscoveryInvalidAdvertise(c *check.C) { func (s *DockerSuite) TestInfoDiscoveryInvalidAdvertise(c *check.C) {
testRequires(c, SameHostDaemon, DaemonIsLinux) testRequires(c, SameHostDaemon, DaemonIsLinux)
d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
Experimental: testEnv.DaemonInfo.ExperimentalBuild,
})
discoveryBackend := "consul://consuladdr:consulport/some/path" discoveryBackend := "consul://consuladdr:consulport/some/path"
// --cluster-advertise with an invalid string is an error // --cluster-advertise with an invalid string is an error
@ -109,9 +106,7 @@ func (s *DockerSuite) TestInfoDiscoveryInvalidAdvertise(c *check.C) {
func (s *DockerSuite) TestInfoDiscoveryAdvertiseInterfaceName(c *check.C) { func (s *DockerSuite) TestInfoDiscoveryAdvertiseInterfaceName(c *check.C) {
testRequires(c, SameHostDaemon, Network, DaemonIsLinux) testRequires(c, SameHostDaemon, Network, DaemonIsLinux)
d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
Experimental: testEnv.DaemonInfo.ExperimentalBuild,
})
discoveryBackend := "consul://consuladdr:consulport/some/path" discoveryBackend := "consul://consuladdr:consulport/some/path"
discoveryAdvertise := "eth0" discoveryAdvertise := "eth0"
@ -182,9 +177,7 @@ func (s *DockerSuite) TestInfoDisplaysStoppedContainers(c *check.C) {
func (s *DockerSuite) TestInfoDebug(c *check.C) { func (s *DockerSuite) TestInfoDebug(c *check.C) {
testRequires(c, SameHostDaemon, DaemonIsLinux) testRequires(c, SameHostDaemon, DaemonIsLinux)
d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
Experimental: testEnv.DaemonInfo.ExperimentalBuild,
})
d.Start(c, "--debug") d.Start(c, "--debug")
defer d.Stop(c) defer d.Stop(c)
@ -205,9 +198,7 @@ func (s *DockerSuite) TestInsecureRegistries(c *check.C) {
registryCIDR := "192.168.1.0/24" registryCIDR := "192.168.1.0/24"
registryHost := "insecurehost.com:5000" registryHost := "insecurehost.com:5000"
d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
Experimental: testEnv.DaemonInfo.ExperimentalBuild,
})
d.Start(c, "--insecure-registry="+registryCIDR, "--insecure-registry="+registryHost) d.Start(c, "--insecure-registry="+registryCIDR, "--insecure-registry="+registryHost)
defer d.Stop(c) defer d.Stop(c)

View File

@ -18,6 +18,7 @@ import (
"github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/checker"
"github.com/docker/docker/integration-cli/cli" "github.com/docker/docker/integration-cli/cli"
"github.com/docker/docker/integration-cli/daemon" "github.com/docker/docker/integration-cli/daemon"
testdaemon "github.com/docker/docker/internal/test/daemon"
"github.com/docker/docker/pkg/stringid" "github.com/docker/docker/pkg/stringid"
"github.com/docker/docker/runconfig" "github.com/docker/docker/runconfig"
"github.com/docker/libnetwork/driverapi" "github.com/docker/libnetwork/driverapi"
@ -49,9 +50,7 @@ type DockerNetworkSuite struct {
} }
func (s *DockerNetworkSuite) SetUpTest(c *check.C) { func (s *DockerNetworkSuite) SetUpTest(c *check.C) {
s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
Experimental: testEnv.DaemonInfo.ExperimentalBuild,
})
} }
func (s *DockerNetworkSuite) TearDownTest(c *check.C) { func (s *DockerNetworkSuite) TearDownTest(c *check.C) {

View File

@ -473,7 +473,7 @@ func (s *DockerSuite) TestPluginUpgrade(c *check.C) {
func (s *DockerSuite) TestPluginMetricsCollector(c *check.C) { func (s *DockerSuite) TestPluginMetricsCollector(c *check.C) {
testRequires(c, DaemonIsLinux, Network, SameHostDaemon, IsAmd64) testRequires(c, DaemonIsLinux, Network, SameHostDaemon, IsAmd64)
d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{}) d := daemon.New(c, dockerBinary, dockerdBinary)
d.Start(c) d.Start(c)
defer d.Stop(c) defer d.Stop(c)

View File

@ -7,6 +7,7 @@ import (
"github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/checker"
"github.com/docker/docker/integration-cli/daemon" "github.com/docker/docker/integration-cli/daemon"
testdaemon "github.com/docker/docker/internal/test/daemon"
"github.com/go-check/check" "github.com/go-check/check"
) )
@ -40,9 +41,7 @@ func newDockerHubPullSuite() *DockerHubPullSuite {
// SetUpSuite starts the suite daemon. // SetUpSuite starts the suite daemon.
func (s *DockerHubPullSuite) SetUpSuite(c *check.C) { func (s *DockerHubPullSuite) SetUpSuite(c *check.C) {
testRequires(c, DaemonIsLinux, SameHostDaemon) testRequires(c, DaemonIsLinux, SameHostDaemon)
s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{ s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
Experimental: testEnv.DaemonInfo.ExperimentalBuild,
})
s.d.Start(c) s.d.Start(c)
} }

View File

@ -9,8 +9,8 @@ import (
dclient "github.com/docker/docker/client" dclient "github.com/docker/docker/client"
"github.com/docker/docker/integration-cli/cli/build/fakecontext" "github.com/docker/docker/integration-cli/cli/build/fakecontext"
"github.com/docker/docker/integration-cli/daemon"
"github.com/docker/docker/integration-cli/request" "github.com/docker/docker/integration-cli/request"
"github.com/docker/docker/internal/test/daemon"
"github.com/gotestyourself/gotestyourself/assert" "github.com/gotestyourself/gotestyourself/assert"
is "github.com/gotestyourself/gotestyourself/assert/cmp" is "github.com/gotestyourself/gotestyourself/assert/cmp"
"github.com/moby/buildkit/session" "github.com/moby/buildkit/session"
@ -19,9 +19,7 @@ import (
) )
func TestBuildWithSession(t *testing.T) { func TestBuildWithSession(t *testing.T) {
d := daemon.New(t, "", "dockerd", daemon.Config{ d := daemon.New(t, daemon.WithExperimental)
Experimental: true,
})
d.StartWithBusybox(t) d.StartWithBusybox(t)
defer d.Stop(t) defer d.Stop(t)

View File

@ -10,17 +10,15 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/integration-cli/cli/build/fakecontext" "github.com/docker/docker/integration-cli/cli/build/fakecontext"
"github.com/docker/docker/integration-cli/daemon"
"github.com/docker/docker/integration/internal/container" "github.com/docker/docker/integration/internal/container"
"github.com/docker/docker/internal/test/daemon"
"github.com/docker/docker/pkg/stdcopy" "github.com/docker/docker/pkg/stdcopy"
"github.com/gotestyourself/gotestyourself/assert" "github.com/gotestyourself/gotestyourself/assert"
is "github.com/gotestyourself/gotestyourself/assert/cmp" is "github.com/gotestyourself/gotestyourself/assert/cmp"
) )
func TestBuildSquashParent(t *testing.T) { func TestBuildSquashParent(t *testing.T) {
d := daemon.New(t, "", "dockerd", daemon.Config{ d := daemon.New(t, daemon.WithExperimental)
Experimental: true,
})
d.StartWithBusybox(t) d.StartWithBusybox(t)
defer d.Stop(t) defer d.Stop(t)

View File

@ -26,8 +26,8 @@ func TestConfigList(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
d := swarm.NewSwarm(t, testEnv) d := swarm.NewSwarm(t, testEnv)
defer d.Stop(t) defer d.Stop(t)
client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) client := d.NewClientT(t)
assert.NilError(t, err) defer client.Close()
ctx := context.Background() ctx := context.Background()
@ -117,8 +117,8 @@ func TestConfigsCreateAndDelete(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
d := swarm.NewSwarm(t, testEnv) d := swarm.NewSwarm(t, testEnv)
defer d.Stop(t) defer d.Stop(t)
client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) client := d.NewClientT(t)
assert.NilError(t, err) defer client.Close()
ctx := context.Background() ctx := context.Background()
@ -145,8 +145,8 @@ func TestConfigsUpdate(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
d := swarm.NewSwarm(t, testEnv) d := swarm.NewSwarm(t, testEnv)
defer d.Stop(t) defer d.Stop(t)
client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) client := d.NewClientT(t)
assert.NilError(t, err) defer client.Close()
ctx := context.Background() ctx := context.Background()
@ -196,9 +196,9 @@ func TestConfigsUpdate(t *testing.T) {
func TestTemplatedConfig(t *testing.T) { func TestTemplatedConfig(t *testing.T) {
d := swarm.NewSwarm(t, testEnv) d := swarm.NewSwarm(t, testEnv)
defer d.Stop(t) defer d.Stop(t)
client := d.NewClientT(t)
defer client.Close()
ctx := context.Background() ctx := context.Background()
client := swarm.GetClient(t, d)
referencedSecretName := "referencedsecret-" + t.Name() referencedSecretName := "referencedsecret-" + t.Name()
referencedSecretSpec := swarmtypes.SecretSpec{ referencedSecretSpec := swarmtypes.SecretSpec{
@ -338,8 +338,8 @@ func TestConfigInspect(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
d := swarm.NewSwarm(t, testEnv) d := swarm.NewSwarm(t, testEnv)
defer d.Stop(t) defer d.Stop(t)
client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) client := d.NewClientT(t)
assert.NilError(t, err) defer client.Close()
ctx := context.Background() ctx := context.Background()

View File

@ -9,7 +9,6 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
swarmtypes "github.com/docker/docker/api/types/swarm" swarmtypes "github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/client"
"github.com/docker/docker/internal/test/daemon" "github.com/docker/docker/internal/test/daemon"
"github.com/docker/docker/internal/test/environment" "github.com/docker/docker/internal/test/environment"
"github.com/gotestyourself/gotestyourself/assert" "github.com/gotestyourself/gotestyourself/assert"
@ -55,11 +54,7 @@ func NewSwarm(t *testing.T, testEnv *environment.Execution, ops ...func(*daemon.
ops = append(ops, daemon.WithExperimental) ops = append(ops, daemon.WithExperimental)
} }
d := daemon.New(t, ops...) d := daemon.New(t, ops...)
// avoid networking conflicts d.StartAndSwarmInit(t)
args := []string{"--iptables=false", "--swarm-default-advertise-addr=lo"}
d.StartWithBusybox(t, args...)
d.SwarmInit(t, swarmtypes.InitRequest{})
return d return d
} }
@ -73,7 +68,8 @@ func CreateService(t *testing.T, d *daemon.Daemon, opts ...ServiceSpecOpt) strin
o(&spec) o(&spec)
} }
client := GetClient(t, d) client := d.NewClientT(t)
defer client.Close()
resp, err := client.ServiceCreate(context.Background(), spec, types.ServiceCreateOptions{}) resp, err := client.ServiceCreate(context.Background(), spec, types.ServiceCreateOptions{})
assert.NilError(t, err, "error creating service") assert.NilError(t, err, "error creating service")
@ -140,7 +136,8 @@ func ServiceWithName(name string) ServiceSpecOpt {
// GetRunningTasks gets the list of running tasks for a service // GetRunningTasks gets the list of running tasks for a service
func GetRunningTasks(t *testing.T, d *daemon.Daemon, serviceID string) []swarmtypes.Task { func GetRunningTasks(t *testing.T, d *daemon.Daemon, serviceID string) []swarmtypes.Task {
client := GetClient(t, d) client := d.NewClientT(t)
defer client.Close()
filterArgs := filters.NewArgs() filterArgs := filters.NewArgs()
filterArgs.Add("desired-state", "running") filterArgs.Add("desired-state", "running")
@ -156,7 +153,8 @@ func GetRunningTasks(t *testing.T, d *daemon.Daemon, serviceID string) []swarmty
// ExecTask runs the passed in exec config on the given task // ExecTask runs the passed in exec config on the given task
func ExecTask(t *testing.T, d *daemon.Daemon, task swarmtypes.Task, config types.ExecConfig) types.HijackedResponse { func ExecTask(t *testing.T, d *daemon.Daemon, task swarmtypes.Task, config types.ExecConfig) types.HijackedResponse {
client := GetClient(t, d) client := d.NewClientT(t)
defer client.Close()
ctx := context.Background() ctx := context.Background()
resp, err := client.ContainerExecCreate(ctx, task.Status.ContainerStatus.ContainerID, config) resp, err := client.ContainerExecCreate(ctx, task.Status.ContainerStatus.ContainerID, config)
@ -173,10 +171,3 @@ func ensureContainerSpec(spec *swarmtypes.ServiceSpec) {
spec.TaskTemplate.ContainerSpec = &swarmtypes.ContainerSpec{} spec.TaskTemplate.ContainerSpec = &swarmtypes.ContainerSpec{}
} }
} }
// GetClient creates a new client for the passed in swarm daemon.
func GetClient(t *testing.T, d *daemon.Daemon) client.APIClient {
client, err := client.NewClientWithOpts(client.WithHost((d.Sock())))
assert.NilError(t, err)
return client
}

View File

@ -20,8 +20,8 @@ func TestInspectNetwork(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
d := swarm.NewSwarm(t, testEnv) d := swarm.NewSwarm(t, testEnv)
defer d.Stop(t) defer d.Stop(t)
client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) client := d.NewClientT(t)
assert.NilError(t, err) defer client.Close()
overlayName := "overlay1" overlayName := "overlay1"
networkCreate := types.NetworkCreate{ networkCreate := types.NetworkCreate{

View File

@ -8,9 +8,9 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/network"
dclient "github.com/docker/docker/client" dclient "github.com/docker/docker/client"
"github.com/docker/docker/integration-cli/daemon"
"github.com/docker/docker/integration/internal/container" "github.com/docker/docker/integration/internal/container"
n "github.com/docker/docker/integration/network" n "github.com/docker/docker/integration/network"
"github.com/docker/docker/internal/test/daemon"
"github.com/gotestyourself/gotestyourself/assert" "github.com/gotestyourself/gotestyourself/assert"
"github.com/gotestyourself/gotestyourself/skip" "github.com/gotestyourself/gotestyourself/skip"
"golang.org/x/net/context" "golang.org/x/net/context"
@ -22,9 +22,7 @@ func TestDockerNetworkIpvlanPersistance(t *testing.T) {
skip.If(t, testEnv.IsRemoteDaemon()) skip.If(t, testEnv.IsRemoteDaemon())
skip.If(t, !ipvlanKernelSupport(), "Kernel doesn't support ipvlan") skip.If(t, !ipvlanKernelSupport(), "Kernel doesn't support ipvlan")
d := daemon.New(t, "", "dockerd", daemon.Config{ d := daemon.New(t, daemon.WithExperimental)
Experimental: true,
})
d.StartWithBusybox(t) d.StartWithBusybox(t)
defer d.Stop(t) defer d.Stop(t)
@ -88,9 +86,7 @@ func TestDockerNetworkIpvlan(t *testing.T) {
test: testIpvlanAddressing, test: testIpvlanAddressing,
}, },
} { } {
d := daemon.New(t, "", "dockerd", daemon.Config{ d := daemon.New(t, daemon.WithExperimental)
Experimental: true,
})
d.StartWithBusybox(t) d.StartWithBusybox(t)
client, err := d.NewClient() client, err := d.NewClient()

View File

@ -17,8 +17,8 @@ func TestServiceWithPredefinedNetwork(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
d := swarm.NewSwarm(t, testEnv) d := swarm.NewSwarm(t, testEnv)
defer d.Stop(t) defer d.Stop(t)
client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) client := d.NewClientT(t)
assert.NilError(t, err) defer client.Close()
hostName := "host" hostName := "host"
var instances uint64 = 1 var instances uint64 = 1
@ -47,9 +47,8 @@ func TestServiceRemoveKeepsIngressNetwork(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
d := swarm.NewSwarm(t, testEnv) d := swarm.NewSwarm(t, testEnv)
defer d.Stop(t) defer d.Stop(t)
client := d.NewClientT(t)
client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) defer client.Close()
assert.NilError(t, err)
poll.WaitOn(t, swarmIngressReady(client), swarm.NetworkPoll) poll.WaitOn(t, swarmIngressReady(client), swarm.NetworkPoll)

View File

@ -25,8 +25,8 @@ func TestSecretInspect(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
d := swarm.NewSwarm(t, testEnv) d := swarm.NewSwarm(t, testEnv)
defer d.Stop(t) defer d.Stop(t)
client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) client := d.NewClientT(t)
assert.NilError(t, err) defer client.Close()
ctx := context.Background() ctx := context.Background()
@ -48,9 +48,8 @@ func TestSecretList(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
d := swarm.NewSwarm(t, testEnv) d := swarm.NewSwarm(t, testEnv)
defer d.Stop(t) defer d.Stop(t)
client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) client := d.NewClientT(t)
assert.NilError(t, err) defer client.Close()
ctx := context.Background() ctx := context.Background()
testName0 := "test0" testName0 := "test0"
@ -135,16 +134,15 @@ func TestSecretsCreateAndDelete(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
d := swarm.NewSwarm(t, testEnv) d := swarm.NewSwarm(t, testEnv)
defer d.Stop(t) defer d.Stop(t)
client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) client := d.NewClientT(t)
assert.NilError(t, err) defer client.Close()
ctx := context.Background() ctx := context.Background()
testName := "test_secret" testName := "test_secret"
secretID := createSecret(ctx, t, client, testName, []byte("TESTINGDATA"), nil) secretID := createSecret(ctx, t, client, testName, []byte("TESTINGDATA"), nil)
// create an already existin secret, daemon should return a status code of 409 // create an already existin secret, daemon should return a status code of 409
_, err = client.SecretCreate(ctx, swarmtypes.SecretSpec{ _, err := client.SecretCreate(ctx, swarmtypes.SecretSpec{
Annotations: swarmtypes.Annotations{ Annotations: swarmtypes.Annotations{
Name: testName, Name: testName,
}, },
@ -183,14 +181,12 @@ func TestSecretsUpdate(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
d := swarm.NewSwarm(t, testEnv) d := swarm.NewSwarm(t, testEnv)
defer d.Stop(t) defer d.Stop(t)
client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) client := d.NewClientT(t)
assert.NilError(t, err) defer client.Close()
ctx := context.Background() ctx := context.Background()
testName := "test_secret" testName := "test_secret"
secretID := createSecret(ctx, t, client, testName, []byte("TESTINGDATA"), nil) secretID := createSecret(ctx, t, client, testName, []byte("TESTINGDATA"), nil)
assert.NilError(t, err)
insp, _, err := client.SecretInspectWithRaw(ctx, secretID) insp, _, err := client.SecretInspectWithRaw(ctx, secretID)
assert.NilError(t, err) assert.NilError(t, err)
@ -233,9 +229,9 @@ func TestSecretsUpdate(t *testing.T) {
func TestTemplatedSecret(t *testing.T) { func TestTemplatedSecret(t *testing.T) {
d := swarm.NewSwarm(t, testEnv) d := swarm.NewSwarm(t, testEnv)
defer d.Stop(t) defer d.Stop(t)
client := d.NewClientT(t)
defer client.Close()
ctx := context.Background() ctx := context.Background()
client := swarm.GetClient(t, d)
referencedSecretSpec := swarmtypes.SecretSpec{ referencedSecretSpec := swarmtypes.SecretSpec{
Annotations: swarmtypes.Annotations{ Annotations: swarmtypes.Annotations{

View File

@ -20,8 +20,8 @@ func TestCreateServiceMultipleTimes(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
d := swarm.NewSwarm(t, testEnv) d := swarm.NewSwarm(t, testEnv)
defer d.Stop(t) defer d.Stop(t)
client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) client := d.NewClientT(t)
assert.NilError(t, err) defer client.Close()
overlayName := "overlay1" overlayName := "overlay1"
networkCreate := types.NetworkCreate{ networkCreate := types.NetworkCreate{
@ -78,8 +78,8 @@ func TestCreateWithDuplicateNetworkNames(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
d := swarm.NewSwarm(t, testEnv) d := swarm.NewSwarm(t, testEnv)
defer d.Stop(t) defer d.Stop(t)
client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) client := d.NewClientT(t)
assert.NilError(t, err) defer client.Close()
name := "foo" name := "foo"
networkCreate := types.NetworkCreate{ networkCreate := types.NetworkCreate{
@ -140,8 +140,8 @@ func TestCreateServiceSecretFileMode(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
d := swarm.NewSwarm(t, testEnv) d := swarm.NewSwarm(t, testEnv)
defer d.Stop(t) defer d.Stop(t)
client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) client := d.NewClientT(t)
assert.NilError(t, err) defer client.Close()
ctx := context.Background() ctx := context.Background()
secretResp, err := client.SecretCreate(ctx, swarmtypes.SecretSpec{ secretResp, err := client.SecretCreate(ctx, swarmtypes.SecretSpec{
@ -221,8 +221,8 @@ func TestCreateServiceConfigFileMode(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
d := swarm.NewSwarm(t, testEnv) d := swarm.NewSwarm(t, testEnv)
defer d.Stop(t) defer d.Stop(t)
client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) client := d.NewClientT(t)
assert.NilError(t, err) defer client.Close()
ctx := context.Background() ctx := context.Background()
configResp, err := client.ConfigCreate(ctx, swarmtypes.ConfigSpec{ configResp, err := client.ConfigCreate(ctx, swarmtypes.ConfigSpec{

View File

@ -23,8 +23,8 @@ func TestInspect(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
d := swarm.NewSwarm(t, testEnv) d := swarm.NewSwarm(t, testEnv)
defer d.Stop(t) defer d.Stop(t)
client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) client := d.NewClientT(t)
assert.NilError(t, err) defer client.Close()
var now = time.Now() var now = time.Now()
var instances uint64 = 2 var instances uint64 = 2

View File

@ -6,7 +6,6 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/network"
"github.com/docker/docker/client"
"github.com/docker/docker/integration/internal/container" "github.com/docker/docker/integration/internal/container"
"github.com/docker/docker/integration/internal/swarm" "github.com/docker/docker/integration/internal/swarm"
"github.com/gotestyourself/gotestyourself/assert" "github.com/gotestyourself/gotestyourself/assert"
@ -17,12 +16,12 @@ func TestDockerNetworkConnectAlias(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
d := swarm.NewSwarm(t, testEnv) d := swarm.NewSwarm(t, testEnv)
defer d.Stop(t) defer d.Stop(t)
client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) client := d.NewClientT(t)
assert.NilError(t, err) defer client.Close()
ctx := context.Background() ctx := context.Background()
name := "test-alias" name := "test-alias"
_, err = client.NetworkCreate(ctx, name, types.NetworkCreate{ _, err := client.NetworkCreate(ctx, name, types.NetworkCreate{
Driver: "overlay", Driver: "overlay",
Attachable: true, Attachable: true,
}) })

View File

@ -1,5 +1,7 @@
package daemon package daemon
import "github.com/docker/docker/internal/test/environment"
// WithExperimental sets the daemon in experimental mode // WithExperimental sets the daemon in experimental mode
func WithExperimental(d *Daemon) { func WithExperimental(d *Daemon) {
d.experimental = true d.experimental = true
@ -25,3 +27,12 @@ func WithSwarmListenAddr(listenAddr string) func(*Daemon) {
d.swarmListenAddr = listenAddr d.swarmListenAddr = listenAddr
} }
} }
// WithEnvironment sets options from internal/test/environment.Execution struct
func WithEnvironment(e environment.Execution) func(*Daemon) {
return func(d *Daemon) {
if e.DaemonInfo.ExperimentalBuild {
d.experimental = true
}
}
}

View File

@ -13,9 +13,7 @@ import (
// ServiceConstructor defines a swarm service constructor function // ServiceConstructor defines a swarm service constructor function
type ServiceConstructor func(*swarm.Service) type ServiceConstructor func(*swarm.Service)
// CreateServiceWithOptions creates a swarm service given the specified service constructors func (d *Daemon) createServiceWithOptions(t assert.TestingT, opts types.ServiceCreateOptions, f ...ServiceConstructor) string {
// and auth config
func (d *Daemon) CreateServiceWithOptions(t assert.TestingT, opts types.ServiceCreateOptions, f ...ServiceConstructor) string {
var service swarm.Service var service swarm.Service
for _, fn := range f { for _, fn := range f {
fn(&service) fn(&service)
@ -34,7 +32,7 @@ func (d *Daemon) CreateServiceWithOptions(t assert.TestingT, opts types.ServiceC
// CreateService creates a swarm service given the specified service constructor // CreateService creates a swarm service given the specified service constructor
func (d *Daemon) CreateService(t assert.TestingT, f ...ServiceConstructor) string { func (d *Daemon) CreateService(t assert.TestingT, f ...ServiceConstructor) string {
return d.CreateServiceWithOptions(t, types.ServiceCreateOptions{}, f...) return d.createServiceWithOptions(t, types.ServiceCreateOptions{}, f...)
} }
// GetService returns the swarm service corresponding to the specified id // GetService returns the swarm service corresponding to the specified id

View File

@ -14,6 +14,32 @@ const (
defaultSwarmListenAddr = "0.0.0.0" defaultSwarmListenAddr = "0.0.0.0"
) )
// StartAndSwarmInit starts the daemon (with busybox) and init the swarm
func (d *Daemon) StartAndSwarmInit(t testingT) {
// avoid networking conflicts
args := []string{"--iptables=false", "--swarm-default-advertise-addr=lo"}
d.StartWithBusybox(t, args...)
d.SwarmInit(t, swarm.InitRequest{})
}
// StartAndSwarmJoin starts the daemon (with busybox) and join the specified swarm as worker or manager
func (d *Daemon) StartAndSwarmJoin(t testingT, leader *Daemon, manager bool) {
// avoid networking conflicts
args := []string{"--iptables=false", "--swarm-default-advertise-addr=lo"}
d.StartWithBusybox(t, args...)
tokens := leader.JoinTokens(t)
token := tokens.Worker
if manager {
token = tokens.Manager
}
d.SwarmJoin(t, swarm.JoinRequest{
RemoteAddrs: []string{leader.SwarmListenAddr()},
JoinToken: token,
})
}
// SpecConstructor defines a swarm spec constructor // SpecConstructor defines a swarm spec constructor
type SpecConstructor func(*swarm.Spec) type SpecConstructor func(*swarm.Spec)