Signed-off-by: Vincent Demeester <vincent@sbr.pm>
| ... | ... |
@@ -13,7 +13,6 @@ import ( |
| 13 | 13 |
"testing" |
| 14 | 14 |
"time" |
| 15 | 15 |
|
| 16 |
- "github.com/docker/docker/api/types/swarm" |
|
| 17 | 16 |
"github.com/docker/docker/integration-cli/checker" |
| 18 | 17 |
"github.com/docker/docker/integration-cli/cli" |
| 19 | 18 |
"github.com/docker/docker/integration-cli/cli/build/fakestorage" |
| ... | ... |
@@ -129,9 +128,7 @@ func (s *DockerRegistrySuite) SetUpTest(c *check.C) {
|
| 129 | 129 |
testRequires(c, DaemonIsLinux, RegistryHosting, SameHostDaemon) |
| 130 | 130 |
s.reg = registry.NewV2(c) |
| 131 | 131 |
s.reg.WaitReady(c) |
| 132 |
- s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
|
|
| 133 |
- Experimental: testEnv.DaemonInfo.ExperimentalBuild, |
|
| 134 |
- }) |
|
| 132 |
+ s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) |
|
| 135 | 133 |
} |
| 136 | 134 |
|
| 137 | 135 |
func (s *DockerRegistrySuite) TearDownTest(c *check.C) {
|
| ... | ... |
@@ -164,9 +161,7 @@ func (s *DockerSchema1RegistrySuite) SetUpTest(c *check.C) {
|
| 164 | 164 |
testRequires(c, DaemonIsLinux, RegistryHosting, NotArm64, SameHostDaemon) |
| 165 | 165 |
s.reg = registry.NewV2(c, registry.Schema1) |
| 166 | 166 |
s.reg.WaitReady(c) |
| 167 |
- s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
|
|
| 168 |
- Experimental: testEnv.DaemonInfo.ExperimentalBuild, |
|
| 169 |
- }) |
|
| 167 |
+ s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) |
|
| 170 | 168 |
} |
| 171 | 169 |
|
| 172 | 170 |
func (s *DockerSchema1RegistrySuite) TearDownTest(c *check.C) {
|
| ... | ... |
@@ -199,9 +194,7 @@ func (s *DockerRegistryAuthHtpasswdSuite) SetUpTest(c *check.C) {
|
| 199 | 199 |
testRequires(c, DaemonIsLinux, RegistryHosting, SameHostDaemon) |
| 200 | 200 |
s.reg = registry.NewV2(c, registry.Htpasswd) |
| 201 | 201 |
s.reg.WaitReady(c) |
| 202 |
- s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
|
|
| 203 |
- Experimental: testEnv.DaemonInfo.ExperimentalBuild, |
|
| 204 |
- }) |
|
| 202 |
+ s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) |
|
| 205 | 203 |
} |
| 206 | 204 |
|
| 207 | 205 |
func (s *DockerRegistryAuthHtpasswdSuite) TearDownTest(c *check.C) {
|
| ... | ... |
@@ -234,9 +227,7 @@ func (s *DockerRegistryAuthTokenSuite) OnTimeout(c *check.C) {
|
| 234 | 234 |
|
| 235 | 235 |
func (s *DockerRegistryAuthTokenSuite) SetUpTest(c *check.C) {
|
| 236 | 236 |
testRequires(c, DaemonIsLinux, RegistryHosting, SameHostDaemon) |
| 237 |
- s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
|
|
| 238 |
- Experimental: testEnv.DaemonInfo.ExperimentalBuild, |
|
| 239 |
- }) |
|
| 237 |
+ s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) |
|
| 240 | 238 |
} |
| 241 | 239 |
|
| 242 | 240 |
func (s *DockerRegistryAuthTokenSuite) TearDownTest(c *check.C) {
|
| ... | ... |
@@ -276,9 +267,7 @@ func (s *DockerDaemonSuite) OnTimeout(c *check.C) {
|
| 276 | 276 |
|
| 277 | 277 |
func (s *DockerDaemonSuite) SetUpTest(c *check.C) {
|
| 278 | 278 |
testRequires(c, DaemonIsLinux, SameHostDaemon) |
| 279 |
- s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
|
|
| 280 |
- Experimental: testEnv.DaemonInfo.ExperimentalBuild, |
|
| 281 |
- }) |
|
| 279 |
+ s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) |
|
| 282 | 280 |
} |
| 283 | 281 |
|
| 284 | 282 |
func (s *DockerDaemonSuite) TearDownTest(c *check.C) {
|
| ... | ... |
@@ -333,26 +322,18 @@ func (s *DockerSwarmSuite) SetUpTest(c *check.C) {
|
| 333 | 333 |
} |
| 334 | 334 |
|
| 335 | 335 |
func (s *DockerSwarmSuite) AddDaemon(c *check.C, joinSwarm, manager bool) *daemon.Daemon {
|
| 336 |
- d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
|
|
| 337 |
- Experimental: testEnv.DaemonInfo.ExperimentalBuild, |
|
| 338 |
- }, testdaemon.WithSwarmPort(defaultSwarmPort+s.portIndex)) |
|
| 339 |
- args := []string{"--iptables=false", "--swarm-default-advertise-addr=lo"} // avoid networking conflicts
|
|
| 340 |
- d.StartWithBusybox(c, args...) |
|
| 341 |
- |
|
| 336 |
+ d := daemon.New(c, dockerBinary, dockerdBinary, |
|
| 337 |
+ testdaemon.WithEnvironment(testEnv.Execution), |
|
| 338 |
+ testdaemon.WithSwarmPort(defaultSwarmPort+s.portIndex), |
|
| 339 |
+ ) |
|
| 342 | 340 |
if joinSwarm {
|
| 343 | 341 |
if len(s.daemons) > 0 {
|
| 344 |
- tokens := s.daemons[0].JoinTokens(c) |
|
| 345 |
- token := tokens.Worker |
|
| 346 |
- if manager {
|
|
| 347 |
- token = tokens.Manager |
|
| 348 |
- } |
|
| 349 |
- d.SwarmJoin(c, swarm.JoinRequest{
|
|
| 350 |
- RemoteAddrs: []string{s.daemons[0].SwarmListenAddr()},
|
|
| 351 |
- JoinToken: token, |
|
| 352 |
- }) |
|
| 342 |
+ d.StartAndSwarmJoin(c, s.daemons[0].Daemon, manager) |
|
| 353 | 343 |
} else {
|
| 354 |
- d.SwarmInit(c, swarm.InitRequest{})
|
|
| 344 |
+ d.StartAndSwarmInit(c) |
|
| 355 | 345 |
} |
| 346 |
+ } else {
|
|
| 347 |
+ d.StartWithBusybox(c, "--iptables=false", "--swarm-default-advertise-addr=lo") |
|
| 356 | 348 |
} |
| 357 | 349 |
|
| 358 | 350 |
s.portIndex++ |
| ... | ... |
@@ -30,21 +30,12 @@ type Daemon struct {
|
| 30 | 30 |
dockerBinary string |
| 31 | 31 |
} |
| 32 | 32 |
|
| 33 |
-// Config holds docker daemon integration configuration |
|
| 34 |
-type Config struct {
|
|
| 35 |
- Experimental bool |
|
| 36 |
-} |
|
| 37 |
- |
|
| 38 | 33 |
// New returns a Daemon instance to be used for testing. |
| 39 | 34 |
// This will create a directory such as d123456789 in the folder specified by $DOCKER_INTEGRATION_DAEMON_DEST or $DEST. |
| 40 | 35 |
// The daemon will not automatically start. |
| 41 |
-func New(t testingT, dockerBinary string, dockerdBinary string, config Config, ops ...func(*daemon.Daemon)) *Daemon {
|
|
| 36 |
+func New(t testingT, dockerBinary string, dockerdBinary string, ops ...func(*daemon.Daemon)) *Daemon {
|
|
| 42 | 37 |
ops = append(ops, daemon.WithDockerdBinary(dockerdBinary)) |
| 43 |
- if config.Experimental {
|
|
| 44 |
- ops = append(ops, daemon.WithExperimental) |
|
| 45 |
- } |
|
| 46 | 38 |
d := daemon.New(t, ops...) |
| 47 |
- |
|
| 48 | 39 |
return &Daemon{
|
| 49 | 40 |
Daemon: d, |
| 50 | 41 |
dockerBinary: dockerBinary, |
| ... | ... |
@@ -32,6 +32,7 @@ import ( |
| 32 | 32 |
"github.com/docker/docker/integration-cli/checker" |
| 33 | 33 |
"github.com/docker/docker/integration-cli/cli" |
| 34 | 34 |
"github.com/docker/docker/integration-cli/daemon" |
| 35 |
+ testdaemon "github.com/docker/docker/internal/test/daemon" |
|
| 35 | 36 |
"github.com/docker/docker/opts" |
| 36 | 37 |
"github.com/docker/docker/pkg/mount" |
| 37 | 38 |
"github.com/docker/docker/pkg/stringid" |
| ... | ... |
@@ -1432,9 +1433,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithSocketAsVolume(c *check.C) {
|
| 1432 | 1432 |
// os.Kill should kill daemon ungracefully, leaving behind container mounts. |
| 1433 | 1433 |
// A subsequent daemon restart should clean up said mounts. |
| 1434 | 1434 |
func (s *DockerDaemonSuite) TestCleanupMountsAfterDaemonAndContainerKill(c *check.C) {
|
| 1435 |
- d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
|
|
| 1436 |
- Experimental: testEnv.DaemonInfo.ExperimentalBuild, |
|
| 1437 |
- }) |
|
| 1435 |
+ d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) |
|
| 1438 | 1436 |
d.StartWithBusybox(c) |
| 1439 | 1437 |
|
| 1440 | 1438 |
out, err := d.Cmd("run", "-d", "busybox", "top")
|
| ... | ... |
@@ -1472,9 +1471,7 @@ func (s *DockerDaemonSuite) TestCleanupMountsAfterDaemonAndContainerKill(c *chec |
| 1472 | 1472 |
|
| 1473 | 1473 |
// os.Interrupt should perform a graceful daemon shutdown and hence cleanup mounts. |
| 1474 | 1474 |
func (s *DockerDaemonSuite) TestCleanupMountsAfterGracefulShutdown(c *check.C) {
|
| 1475 |
- d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
|
|
| 1476 |
- Experimental: testEnv.DaemonInfo.ExperimentalBuild, |
|
| 1477 |
- }) |
|
| 1475 |
+ d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) |
|
| 1478 | 1476 |
d.StartWithBusybox(c) |
| 1479 | 1477 |
|
| 1480 | 1478 |
out, err := d.Cmd("run", "-d", "busybox", "top")
|
| ... | ... |
@@ -1693,9 +1690,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartLocalVolumes(c *check.C) {
|
| 1693 | 1693 |
|
| 1694 | 1694 |
// FIXME(vdemeester) should be a unit test |
| 1695 | 1695 |
func (s *DockerDaemonSuite) TestDaemonCorruptedLogDriverAddress(c *check.C) {
|
| 1696 |
- d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
|
|
| 1697 |
- Experimental: testEnv.DaemonInfo.ExperimentalBuild, |
|
| 1698 |
- }) |
|
| 1696 |
+ d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) |
|
| 1699 | 1697 |
c.Assert(d.StartWithError("--log-driver=syslog", "--log-opt", "syslog-address=corrupted:42"), check.NotNil)
|
| 1700 | 1698 |
expected := "syslog-address should be in form proto://address" |
| 1701 | 1699 |
icmd.RunCommand("grep", expected, d.LogFileName()).Assert(c, icmd.Success)
|
| ... | ... |
@@ -1703,9 +1698,7 @@ func (s *DockerDaemonSuite) TestDaemonCorruptedLogDriverAddress(c *check.C) {
|
| 1703 | 1703 |
|
| 1704 | 1704 |
// FIXME(vdemeester) should be a unit test |
| 1705 | 1705 |
func (s *DockerDaemonSuite) TestDaemonCorruptedFluentdAddress(c *check.C) {
|
| 1706 |
- d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
|
|
| 1707 |
- Experimental: testEnv.DaemonInfo.ExperimentalBuild, |
|
| 1708 |
- }) |
|
| 1706 |
+ d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) |
|
| 1709 | 1707 |
c.Assert(d.StartWithError("--log-driver=fluentd", "--log-opt", "fluentd-address=corrupted:c"), check.NotNil)
|
| 1710 | 1708 |
expected := "invalid fluentd-address corrupted:c: " |
| 1711 | 1709 |
icmd.RunCommand("grep", expected, d.LogFileName()).Assert(c, icmd.Success)
|
| ... | ... |
@@ -3080,9 +3073,7 @@ func (s *DockerDaemonSuite) TestDaemonIpcModeShareableFromConfig(c *check.C) {
|
| 3080 | 3080 |
} |
| 3081 | 3081 |
|
| 3082 | 3082 |
func testDaemonStartIpcMode(c *check.C, from, mode string, valid bool) {
|
| 3083 |
- d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
|
|
| 3084 |
- Experimental: testEnv.DaemonInfo.ExperimentalBuild, |
|
| 3085 |
- }) |
|
| 3083 |
+ d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) |
|
| 3086 | 3084 |
c.Logf("Checking IpcMode %s set from %s\n", mode, from)
|
| 3087 | 3085 |
var serr error |
| 3088 | 3086 |
switch from {
|
| ... | ... |
@@ -3183,7 +3174,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartIpcMode(c *check.C) {
|
| 3183 | 3183 |
// the daemon from starting |
| 3184 | 3184 |
func (s *DockerDaemonSuite) TestFailedPluginRemove(c *check.C) {
|
| 3185 | 3185 |
testRequires(c, DaemonIsLinux, IsAmd64, SameHostDaemon) |
| 3186 |
- d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{})
|
|
| 3186 |
+ d := daemon.New(c, dockerBinary, dockerdBinary) |
|
| 3187 | 3187 |
d.Start(c) |
| 3188 | 3188 |
cli, err := client.NewClient(d.Sock(), api.DefaultVersion, nil, nil) |
| 3189 | 3189 |
c.Assert(err, checker.IsNil) |
| ... | ... |
@@ -15,6 +15,7 @@ import ( |
| 15 | 15 |
"github.com/docker/docker/daemon/graphdriver" |
| 16 | 16 |
"github.com/docker/docker/daemon/graphdriver/vfs" |
| 17 | 17 |
"github.com/docker/docker/integration-cli/daemon" |
| 18 |
+ testdaemon "github.com/docker/docker/internal/test/daemon" |
|
| 18 | 19 |
"github.com/docker/docker/pkg/archive" |
| 19 | 20 |
"github.com/docker/docker/pkg/plugins" |
| 20 | 21 |
"github.com/go-check/check" |
| ... | ... |
@@ -52,9 +53,7 @@ type graphEventsCounter struct {
|
| 52 | 52 |
} |
| 53 | 53 |
|
| 54 | 54 |
func (s *DockerExternalGraphdriverSuite) SetUpTest(c *check.C) {
|
| 55 |
- s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
|
|
| 56 |
- Experimental: testEnv.DaemonInfo.ExperimentalBuild, |
|
| 57 |
- }) |
|
| 55 |
+ s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) |
|
| 58 | 56 |
} |
| 59 | 57 |
|
| 60 | 58 |
func (s *DockerExternalGraphdriverSuite) OnTimeout(c *check.C) {
|
| ... | ... |
@@ -18,6 +18,7 @@ import ( |
| 18 | 18 |
"github.com/docker/docker/api/types" |
| 19 | 19 |
"github.com/docker/docker/integration-cli/checker" |
| 20 | 20 |
"github.com/docker/docker/integration-cli/daemon" |
| 21 |
+ testdaemon "github.com/docker/docker/internal/test/daemon" |
|
| 21 | 22 |
"github.com/docker/docker/pkg/stringid" |
| 22 | 23 |
"github.com/docker/docker/volume" |
| 23 | 24 |
"github.com/go-check/check" |
| ... | ... |
@@ -51,9 +52,7 @@ type DockerExternalVolumeSuite struct {
|
| 51 | 51 |
|
| 52 | 52 |
func (s *DockerExternalVolumeSuite) SetUpTest(c *check.C) {
|
| 53 | 53 |
testRequires(c, SameHostDaemon) |
| 54 |
- s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
|
|
| 55 |
- Experimental: testEnv.DaemonInfo.ExperimentalBuild, |
|
| 56 |
- }) |
|
| 54 |
+ s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) |
|
| 57 | 55 |
s.ec = &eventCounter{}
|
| 58 | 56 |
} |
| 59 | 57 |
|
| ... | ... |
@@ -8,6 +8,7 @@ import ( |
| 8 | 8 |
|
| 9 | 9 |
"github.com/docker/docker/integration-cli/checker" |
| 10 | 10 |
"github.com/docker/docker/integration-cli/daemon" |
| 11 |
+ testdaemon "github.com/docker/docker/internal/test/daemon" |
|
| 11 | 12 |
"github.com/go-check/check" |
| 12 | 13 |
) |
| 13 | 14 |
|
| ... | ... |
@@ -71,9 +72,7 @@ func (s *DockerSuite) TestInfoFormat(c *check.C) {
|
| 71 | 71 |
func (s *DockerSuite) TestInfoDiscoveryBackend(c *check.C) {
|
| 72 | 72 |
testRequires(c, SameHostDaemon, DaemonIsLinux) |
| 73 | 73 |
|
| 74 |
- d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
|
|
| 75 |
- Experimental: testEnv.DaemonInfo.ExperimentalBuild, |
|
| 76 |
- }) |
|
| 74 |
+ d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) |
|
| 77 | 75 |
discoveryBackend := "consul://consuladdr:consulport/some/path" |
| 78 | 76 |
discoveryAdvertise := "1.1.1.1:2375" |
| 79 | 77 |
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) {
|
| 90 | 90 |
func (s *DockerSuite) TestInfoDiscoveryInvalidAdvertise(c *check.C) {
|
| 91 | 91 |
testRequires(c, SameHostDaemon, DaemonIsLinux) |
| 92 | 92 |
|
| 93 |
- d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
|
|
| 94 |
- Experimental: testEnv.DaemonInfo.ExperimentalBuild, |
|
| 95 |
- }) |
|
| 93 |
+ d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) |
|
| 96 | 94 |
discoveryBackend := "consul://consuladdr:consulport/some/path" |
| 97 | 95 |
|
| 98 | 96 |
// --cluster-advertise with an invalid string is an error |
| ... | ... |
@@ -109,9 +106,7 @@ func (s *DockerSuite) TestInfoDiscoveryInvalidAdvertise(c *check.C) {
|
| 109 | 109 |
func (s *DockerSuite) TestInfoDiscoveryAdvertiseInterfaceName(c *check.C) {
|
| 110 | 110 |
testRequires(c, SameHostDaemon, Network, DaemonIsLinux) |
| 111 | 111 |
|
| 112 |
- d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
|
|
| 113 |
- Experimental: testEnv.DaemonInfo.ExperimentalBuild, |
|
| 114 |
- }) |
|
| 112 |
+ d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) |
|
| 115 | 113 |
discoveryBackend := "consul://consuladdr:consulport/some/path" |
| 116 | 114 |
discoveryAdvertise := "eth0" |
| 117 | 115 |
|
| ... | ... |
@@ -182,9 +177,7 @@ func (s *DockerSuite) TestInfoDisplaysStoppedContainers(c *check.C) {
|
| 182 | 182 |
func (s *DockerSuite) TestInfoDebug(c *check.C) {
|
| 183 | 183 |
testRequires(c, SameHostDaemon, DaemonIsLinux) |
| 184 | 184 |
|
| 185 |
- d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
|
|
| 186 |
- Experimental: testEnv.DaemonInfo.ExperimentalBuild, |
|
| 187 |
- }) |
|
| 185 |
+ d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) |
|
| 188 | 186 |
d.Start(c, "--debug") |
| 189 | 187 |
defer d.Stop(c) |
| 190 | 188 |
|
| ... | ... |
@@ -205,9 +198,7 @@ func (s *DockerSuite) TestInsecureRegistries(c *check.C) {
|
| 205 | 205 |
registryCIDR := "192.168.1.0/24" |
| 206 | 206 |
registryHost := "insecurehost.com:5000" |
| 207 | 207 |
|
| 208 |
- d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
|
|
| 209 |
- Experimental: testEnv.DaemonInfo.ExperimentalBuild, |
|
| 210 |
- }) |
|
| 208 |
+ d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) |
|
| 211 | 209 |
d.Start(c, "--insecure-registry="+registryCIDR, "--insecure-registry="+registryHost) |
| 212 | 210 |
defer d.Stop(c) |
| 213 | 211 |
|
| ... | ... |
@@ -18,6 +18,7 @@ import ( |
| 18 | 18 |
"github.com/docker/docker/integration-cli/checker" |
| 19 | 19 |
"github.com/docker/docker/integration-cli/cli" |
| 20 | 20 |
"github.com/docker/docker/integration-cli/daemon" |
| 21 |
+ testdaemon "github.com/docker/docker/internal/test/daemon" |
|
| 21 | 22 |
"github.com/docker/docker/pkg/stringid" |
| 22 | 23 |
"github.com/docker/docker/runconfig" |
| 23 | 24 |
"github.com/docker/libnetwork/driverapi" |
| ... | ... |
@@ -49,9 +50,7 @@ type DockerNetworkSuite struct {
|
| 49 | 49 |
} |
| 50 | 50 |
|
| 51 | 51 |
func (s *DockerNetworkSuite) SetUpTest(c *check.C) {
|
| 52 |
- s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
|
|
| 53 |
- Experimental: testEnv.DaemonInfo.ExperimentalBuild, |
|
| 54 |
- }) |
|
| 52 |
+ s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) |
|
| 55 | 53 |
} |
| 56 | 54 |
|
| 57 | 55 |
func (s *DockerNetworkSuite) TearDownTest(c *check.C) {
|
| ... | ... |
@@ -473,7 +473,7 @@ func (s *DockerSuite) TestPluginUpgrade(c *check.C) {
|
| 473 | 473 |
|
| 474 | 474 |
func (s *DockerSuite) TestPluginMetricsCollector(c *check.C) {
|
| 475 | 475 |
testRequires(c, DaemonIsLinux, Network, SameHostDaemon, IsAmd64) |
| 476 |
- d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{})
|
|
| 476 |
+ d := daemon.New(c, dockerBinary, dockerdBinary) |
|
| 477 | 477 |
d.Start(c) |
| 478 | 478 |
defer d.Stop(c) |
| 479 | 479 |
|
| ... | ... |
@@ -7,6 +7,7 @@ import ( |
| 7 | 7 |
|
| 8 | 8 |
"github.com/docker/docker/integration-cli/checker" |
| 9 | 9 |
"github.com/docker/docker/integration-cli/daemon" |
| 10 |
+ testdaemon "github.com/docker/docker/internal/test/daemon" |
|
| 10 | 11 |
"github.com/go-check/check" |
| 11 | 12 |
) |
| 12 | 13 |
|
| ... | ... |
@@ -40,9 +41,7 @@ func newDockerHubPullSuite() *DockerHubPullSuite {
|
| 40 | 40 |
// SetUpSuite starts the suite daemon. |
| 41 | 41 |
func (s *DockerHubPullSuite) SetUpSuite(c *check.C) {
|
| 42 | 42 |
testRequires(c, DaemonIsLinux, SameHostDaemon) |
| 43 |
- s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
|
|
| 44 |
- Experimental: testEnv.DaemonInfo.ExperimentalBuild, |
|
| 45 |
- }) |
|
| 43 |
+ s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) |
|
| 46 | 44 |
s.d.Start(c) |
| 47 | 45 |
} |
| 48 | 46 |
|
| ... | ... |
@@ -9,8 +9,8 @@ import ( |
| 9 | 9 |
|
| 10 | 10 |
dclient "github.com/docker/docker/client" |
| 11 | 11 |
"github.com/docker/docker/integration-cli/cli/build/fakecontext" |
| 12 |
- "github.com/docker/docker/integration-cli/daemon" |
|
| 13 | 12 |
"github.com/docker/docker/integration-cli/request" |
| 13 |
+ "github.com/docker/docker/internal/test/daemon" |
|
| 14 | 14 |
"github.com/gotestyourself/gotestyourself/assert" |
| 15 | 15 |
is "github.com/gotestyourself/gotestyourself/assert/cmp" |
| 16 | 16 |
"github.com/moby/buildkit/session" |
| ... | ... |
@@ -19,9 +19,7 @@ import ( |
| 19 | 19 |
) |
| 20 | 20 |
|
| 21 | 21 |
func TestBuildWithSession(t *testing.T) {
|
| 22 |
- d := daemon.New(t, "", "dockerd", daemon.Config{
|
|
| 23 |
- Experimental: true, |
|
| 24 |
- }) |
|
| 22 |
+ d := daemon.New(t, daemon.WithExperimental) |
|
| 25 | 23 |
d.StartWithBusybox(t) |
| 26 | 24 |
defer d.Stop(t) |
| 27 | 25 |
|
| ... | ... |
@@ -10,17 +10,15 @@ import ( |
| 10 | 10 |
|
| 11 | 11 |
"github.com/docker/docker/api/types" |
| 12 | 12 |
"github.com/docker/docker/integration-cli/cli/build/fakecontext" |
| 13 |
- "github.com/docker/docker/integration-cli/daemon" |
|
| 14 | 13 |
"github.com/docker/docker/integration/internal/container" |
| 14 |
+ "github.com/docker/docker/internal/test/daemon" |
|
| 15 | 15 |
"github.com/docker/docker/pkg/stdcopy" |
| 16 | 16 |
"github.com/gotestyourself/gotestyourself/assert" |
| 17 | 17 |
is "github.com/gotestyourself/gotestyourself/assert/cmp" |
| 18 | 18 |
) |
| 19 | 19 |
|
| 20 | 20 |
func TestBuildSquashParent(t *testing.T) {
|
| 21 |
- d := daemon.New(t, "", "dockerd", daemon.Config{
|
|
| 22 |
- Experimental: true, |
|
| 23 |
- }) |
|
| 21 |
+ d := daemon.New(t, daemon.WithExperimental) |
|
| 24 | 22 |
d.StartWithBusybox(t) |
| 25 | 23 |
defer d.Stop(t) |
| 26 | 24 |
|
| ... | ... |
@@ -26,8 +26,8 @@ func TestConfigList(t *testing.T) {
|
| 26 | 26 |
defer setupTest(t)() |
| 27 | 27 |
d := swarm.NewSwarm(t, testEnv) |
| 28 | 28 |
defer d.Stop(t) |
| 29 |
- client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) |
|
| 30 |
- assert.NilError(t, err) |
|
| 29 |
+ client := d.NewClientT(t) |
|
| 30 |
+ defer client.Close() |
|
| 31 | 31 |
|
| 32 | 32 |
ctx := context.Background() |
| 33 | 33 |
|
| ... | ... |
@@ -117,8 +117,8 @@ func TestConfigsCreateAndDelete(t *testing.T) {
|
| 117 | 117 |
defer setupTest(t)() |
| 118 | 118 |
d := swarm.NewSwarm(t, testEnv) |
| 119 | 119 |
defer d.Stop(t) |
| 120 |
- client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) |
|
| 121 |
- assert.NilError(t, err) |
|
| 120 |
+ client := d.NewClientT(t) |
|
| 121 |
+ defer client.Close() |
|
| 122 | 122 |
|
| 123 | 123 |
ctx := context.Background() |
| 124 | 124 |
|
| ... | ... |
@@ -145,8 +145,8 @@ func TestConfigsUpdate(t *testing.T) {
|
| 145 | 145 |
defer setupTest(t)() |
| 146 | 146 |
d := swarm.NewSwarm(t, testEnv) |
| 147 | 147 |
defer d.Stop(t) |
| 148 |
- client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) |
|
| 149 |
- assert.NilError(t, err) |
|
| 148 |
+ client := d.NewClientT(t) |
|
| 149 |
+ defer client.Close() |
|
| 150 | 150 |
|
| 151 | 151 |
ctx := context.Background() |
| 152 | 152 |
|
| ... | ... |
@@ -196,9 +196,9 @@ func TestConfigsUpdate(t *testing.T) {
|
| 196 | 196 |
func TestTemplatedConfig(t *testing.T) {
|
| 197 | 197 |
d := swarm.NewSwarm(t, testEnv) |
| 198 | 198 |
defer d.Stop(t) |
| 199 |
- |
|
| 199 |
+ client := d.NewClientT(t) |
|
| 200 |
+ defer client.Close() |
|
| 200 | 201 |
ctx := context.Background() |
| 201 |
- client := swarm.GetClient(t, d) |
|
| 202 | 202 |
|
| 203 | 203 |
referencedSecretName := "referencedsecret-" + t.Name() |
| 204 | 204 |
referencedSecretSpec := swarmtypes.SecretSpec{
|
| ... | ... |
@@ -338,8 +338,8 @@ func TestConfigInspect(t *testing.T) {
|
| 338 | 338 |
defer setupTest(t)() |
| 339 | 339 |
d := swarm.NewSwarm(t, testEnv) |
| 340 | 340 |
defer d.Stop(t) |
| 341 |
- client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) |
|
| 342 |
- assert.NilError(t, err) |
|
| 341 |
+ client := d.NewClientT(t) |
|
| 342 |
+ defer client.Close() |
|
| 343 | 343 |
|
| 344 | 344 |
ctx := context.Background() |
| 345 | 345 |
|
| ... | ... |
@@ -9,7 +9,6 @@ import ( |
| 9 | 9 |
"github.com/docker/docker/api/types" |
| 10 | 10 |
"github.com/docker/docker/api/types/filters" |
| 11 | 11 |
swarmtypes "github.com/docker/docker/api/types/swarm" |
| 12 |
- "github.com/docker/docker/client" |
|
| 13 | 12 |
"github.com/docker/docker/internal/test/daemon" |
| 14 | 13 |
"github.com/docker/docker/internal/test/environment" |
| 15 | 14 |
"github.com/gotestyourself/gotestyourself/assert" |
| ... | ... |
@@ -55,11 +54,7 @@ func NewSwarm(t *testing.T, testEnv *environment.Execution, ops ...func(*daemon. |
| 55 | 55 |
ops = append(ops, daemon.WithExperimental) |
| 56 | 56 |
} |
| 57 | 57 |
d := daemon.New(t, ops...) |
| 58 |
- // avoid networking conflicts |
|
| 59 |
- args := []string{"--iptables=false", "--swarm-default-advertise-addr=lo"}
|
|
| 60 |
- d.StartWithBusybox(t, args...) |
|
| 61 |
- |
|
| 62 |
- d.SwarmInit(t, swarmtypes.InitRequest{})
|
|
| 58 |
+ d.StartAndSwarmInit(t) |
|
| 63 | 59 |
return d |
| 64 | 60 |
} |
| 65 | 61 |
|
| ... | ... |
@@ -73,7 +68,8 @@ func CreateService(t *testing.T, d *daemon.Daemon, opts ...ServiceSpecOpt) strin |
| 73 | 73 |
o(&spec) |
| 74 | 74 |
} |
| 75 | 75 |
|
| 76 |
- client := GetClient(t, d) |
|
| 76 |
+ client := d.NewClientT(t) |
|
| 77 |
+ defer client.Close() |
|
| 77 | 78 |
|
| 78 | 79 |
resp, err := client.ServiceCreate(context.Background(), spec, types.ServiceCreateOptions{})
|
| 79 | 80 |
assert.NilError(t, err, "error creating service") |
| ... | ... |
@@ -140,7 +136,8 @@ func ServiceWithName(name string) ServiceSpecOpt {
|
| 140 | 140 |
|
| 141 | 141 |
// GetRunningTasks gets the list of running tasks for a service |
| 142 | 142 |
func GetRunningTasks(t *testing.T, d *daemon.Daemon, serviceID string) []swarmtypes.Task {
|
| 143 |
- client := GetClient(t, d) |
|
| 143 |
+ client := d.NewClientT(t) |
|
| 144 |
+ defer client.Close() |
|
| 144 | 145 |
|
| 145 | 146 |
filterArgs := filters.NewArgs() |
| 146 | 147 |
filterArgs.Add("desired-state", "running")
|
| ... | ... |
@@ -156,7 +153,8 @@ func GetRunningTasks(t *testing.T, d *daemon.Daemon, serviceID string) []swarmty |
| 156 | 156 |
|
| 157 | 157 |
// ExecTask runs the passed in exec config on the given task |
| 158 | 158 |
func ExecTask(t *testing.T, d *daemon.Daemon, task swarmtypes.Task, config types.ExecConfig) types.HijackedResponse {
|
| 159 |
- client := GetClient(t, d) |
|
| 159 |
+ client := d.NewClientT(t) |
|
| 160 |
+ defer client.Close() |
|
| 160 | 161 |
|
| 161 | 162 |
ctx := context.Background() |
| 162 | 163 |
resp, err := client.ContainerExecCreate(ctx, task.Status.ContainerStatus.ContainerID, config) |
| ... | ... |
@@ -173,10 +171,3 @@ func ensureContainerSpec(spec *swarmtypes.ServiceSpec) {
|
| 173 | 173 |
spec.TaskTemplate.ContainerSpec = &swarmtypes.ContainerSpec{}
|
| 174 | 174 |
} |
| 175 | 175 |
} |
| 176 |
- |
|
| 177 |
-// GetClient creates a new client for the passed in swarm daemon. |
|
| 178 |
-func GetClient(t *testing.T, d *daemon.Daemon) client.APIClient {
|
|
| 179 |
- client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) |
|
| 180 |
- assert.NilError(t, err) |
|
| 181 |
- return client |
|
| 182 |
-} |
| ... | ... |
@@ -20,8 +20,8 @@ func TestInspectNetwork(t *testing.T) {
|
| 20 | 20 |
defer setupTest(t)() |
| 21 | 21 |
d := swarm.NewSwarm(t, testEnv) |
| 22 | 22 |
defer d.Stop(t) |
| 23 |
- client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) |
|
| 24 |
- assert.NilError(t, err) |
|
| 23 |
+ client := d.NewClientT(t) |
|
| 24 |
+ defer client.Close() |
|
| 25 | 25 |
|
| 26 | 26 |
overlayName := "overlay1" |
| 27 | 27 |
networkCreate := types.NetworkCreate{
|
| ... | ... |
@@ -8,9 +8,9 @@ import ( |
| 8 | 8 |
"github.com/docker/docker/api/types" |
| 9 | 9 |
"github.com/docker/docker/api/types/network" |
| 10 | 10 |
dclient "github.com/docker/docker/client" |
| 11 |
- "github.com/docker/docker/integration-cli/daemon" |
|
| 12 | 11 |
"github.com/docker/docker/integration/internal/container" |
| 13 | 12 |
n "github.com/docker/docker/integration/network" |
| 13 |
+ "github.com/docker/docker/internal/test/daemon" |
|
| 14 | 14 |
"github.com/gotestyourself/gotestyourself/assert" |
| 15 | 15 |
"github.com/gotestyourself/gotestyourself/skip" |
| 16 | 16 |
"golang.org/x/net/context" |
| ... | ... |
@@ -22,9 +22,7 @@ func TestDockerNetworkIpvlanPersistance(t *testing.T) {
|
| 22 | 22 |
skip.If(t, testEnv.IsRemoteDaemon()) |
| 23 | 23 |
skip.If(t, !ipvlanKernelSupport(), "Kernel doesn't support ipvlan") |
| 24 | 24 |
|
| 25 |
- d := daemon.New(t, "", "dockerd", daemon.Config{
|
|
| 26 |
- Experimental: true, |
|
| 27 |
- }) |
|
| 25 |
+ d := daemon.New(t, daemon.WithExperimental) |
|
| 28 | 26 |
d.StartWithBusybox(t) |
| 29 | 27 |
defer d.Stop(t) |
| 30 | 28 |
|
| ... | ... |
@@ -88,9 +86,7 @@ func TestDockerNetworkIpvlan(t *testing.T) {
|
| 88 | 88 |
test: testIpvlanAddressing, |
| 89 | 89 |
}, |
| 90 | 90 |
} {
|
| 91 |
- d := daemon.New(t, "", "dockerd", daemon.Config{
|
|
| 92 |
- Experimental: true, |
|
| 93 |
- }) |
|
| 91 |
+ d := daemon.New(t, daemon.WithExperimental) |
|
| 94 | 92 |
d.StartWithBusybox(t) |
| 95 | 93 |
|
| 96 | 94 |
client, err := d.NewClient() |
| ... | ... |
@@ -17,8 +17,8 @@ func TestServiceWithPredefinedNetwork(t *testing.T) {
|
| 17 | 17 |
defer setupTest(t)() |
| 18 | 18 |
d := swarm.NewSwarm(t, testEnv) |
| 19 | 19 |
defer d.Stop(t) |
| 20 |
- client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) |
|
| 21 |
- assert.NilError(t, err) |
|
| 20 |
+ client := d.NewClientT(t) |
|
| 21 |
+ defer client.Close() |
|
| 22 | 22 |
|
| 23 | 23 |
hostName := "host" |
| 24 | 24 |
var instances uint64 = 1 |
| ... | ... |
@@ -47,9 +47,8 @@ func TestServiceRemoveKeepsIngressNetwork(t *testing.T) {
|
| 47 | 47 |
defer setupTest(t)() |
| 48 | 48 |
d := swarm.NewSwarm(t, testEnv) |
| 49 | 49 |
defer d.Stop(t) |
| 50 |
- |
|
| 51 |
- client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) |
|
| 52 |
- assert.NilError(t, err) |
|
| 50 |
+ client := d.NewClientT(t) |
|
| 51 |
+ defer client.Close() |
|
| 53 | 52 |
|
| 54 | 53 |
poll.WaitOn(t, swarmIngressReady(client), swarm.NetworkPoll) |
| 55 | 54 |
|
| ... | ... |
@@ -25,8 +25,8 @@ func TestSecretInspect(t *testing.T) {
|
| 25 | 25 |
defer setupTest(t)() |
| 26 | 26 |
d := swarm.NewSwarm(t, testEnv) |
| 27 | 27 |
defer d.Stop(t) |
| 28 |
- client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) |
|
| 29 |
- assert.NilError(t, err) |
|
| 28 |
+ client := d.NewClientT(t) |
|
| 29 |
+ defer client.Close() |
|
| 30 | 30 |
|
| 31 | 31 |
ctx := context.Background() |
| 32 | 32 |
|
| ... | ... |
@@ -48,9 +48,8 @@ func TestSecretList(t *testing.T) {
|
| 48 | 48 |
defer setupTest(t)() |
| 49 | 49 |
d := swarm.NewSwarm(t, testEnv) |
| 50 | 50 |
defer d.Stop(t) |
| 51 |
- client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) |
|
| 52 |
- assert.NilError(t, err) |
|
| 53 |
- |
|
| 51 |
+ client := d.NewClientT(t) |
|
| 52 |
+ defer client.Close() |
|
| 54 | 53 |
ctx := context.Background() |
| 55 | 54 |
|
| 56 | 55 |
testName0 := "test0" |
| ... | ... |
@@ -135,16 +134,15 @@ func TestSecretsCreateAndDelete(t *testing.T) {
|
| 135 | 135 |
defer setupTest(t)() |
| 136 | 136 |
d := swarm.NewSwarm(t, testEnv) |
| 137 | 137 |
defer d.Stop(t) |
| 138 |
- client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) |
|
| 139 |
- assert.NilError(t, err) |
|
| 140 |
- |
|
| 138 |
+ client := d.NewClientT(t) |
|
| 139 |
+ defer client.Close() |
|
| 141 | 140 |
ctx := context.Background() |
| 142 | 141 |
|
| 143 | 142 |
testName := "test_secret" |
| 144 | 143 |
secretID := createSecret(ctx, t, client, testName, []byte("TESTINGDATA"), nil)
|
| 145 | 144 |
|
| 146 | 145 |
// create an already existin secret, daemon should return a status code of 409 |
| 147 |
- _, err = client.SecretCreate(ctx, swarmtypes.SecretSpec{
|
|
| 146 |
+ _, err := client.SecretCreate(ctx, swarmtypes.SecretSpec{
|
|
| 148 | 147 |
Annotations: swarmtypes.Annotations{
|
| 149 | 148 |
Name: testName, |
| 150 | 149 |
}, |
| ... | ... |
@@ -183,14 +181,12 @@ func TestSecretsUpdate(t *testing.T) {
|
| 183 | 183 |
defer setupTest(t)() |
| 184 | 184 |
d := swarm.NewSwarm(t, testEnv) |
| 185 | 185 |
defer d.Stop(t) |
| 186 |
- client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) |
|
| 187 |
- assert.NilError(t, err) |
|
| 188 |
- |
|
| 186 |
+ client := d.NewClientT(t) |
|
| 187 |
+ defer client.Close() |
|
| 189 | 188 |
ctx := context.Background() |
| 190 | 189 |
|
| 191 | 190 |
testName := "test_secret" |
| 192 | 191 |
secretID := createSecret(ctx, t, client, testName, []byte("TESTINGDATA"), nil)
|
| 193 |
- assert.NilError(t, err) |
|
| 194 | 192 |
|
| 195 | 193 |
insp, _, err := client.SecretInspectWithRaw(ctx, secretID) |
| 196 | 194 |
assert.NilError(t, err) |
| ... | ... |
@@ -233,9 +229,9 @@ func TestSecretsUpdate(t *testing.T) {
|
| 233 | 233 |
func TestTemplatedSecret(t *testing.T) {
|
| 234 | 234 |
d := swarm.NewSwarm(t, testEnv) |
| 235 | 235 |
defer d.Stop(t) |
| 236 |
- |
|
| 236 |
+ client := d.NewClientT(t) |
|
| 237 |
+ defer client.Close() |
|
| 237 | 238 |
ctx := context.Background() |
| 238 |
- client := swarm.GetClient(t, d) |
|
| 239 | 239 |
|
| 240 | 240 |
referencedSecretSpec := swarmtypes.SecretSpec{
|
| 241 | 241 |
Annotations: swarmtypes.Annotations{
|
| ... | ... |
@@ -20,8 +20,8 @@ func TestCreateServiceMultipleTimes(t *testing.T) {
|
| 20 | 20 |
defer setupTest(t)() |
| 21 | 21 |
d := swarm.NewSwarm(t, testEnv) |
| 22 | 22 |
defer d.Stop(t) |
| 23 |
- client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) |
|
| 24 |
- assert.NilError(t, err) |
|
| 23 |
+ client := d.NewClientT(t) |
|
| 24 |
+ defer client.Close() |
|
| 25 | 25 |
|
| 26 | 26 |
overlayName := "overlay1" |
| 27 | 27 |
networkCreate := types.NetworkCreate{
|
| ... | ... |
@@ -78,8 +78,8 @@ func TestCreateWithDuplicateNetworkNames(t *testing.T) {
|
| 78 | 78 |
defer setupTest(t)() |
| 79 | 79 |
d := swarm.NewSwarm(t, testEnv) |
| 80 | 80 |
defer d.Stop(t) |
| 81 |
- client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) |
|
| 82 |
- assert.NilError(t, err) |
|
| 81 |
+ client := d.NewClientT(t) |
|
| 82 |
+ defer client.Close() |
|
| 83 | 83 |
|
| 84 | 84 |
name := "foo" |
| 85 | 85 |
networkCreate := types.NetworkCreate{
|
| ... | ... |
@@ -140,8 +140,8 @@ func TestCreateServiceSecretFileMode(t *testing.T) {
|
| 140 | 140 |
defer setupTest(t)() |
| 141 | 141 |
d := swarm.NewSwarm(t, testEnv) |
| 142 | 142 |
defer d.Stop(t) |
| 143 |
- client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) |
|
| 144 |
- assert.NilError(t, err) |
|
| 143 |
+ client := d.NewClientT(t) |
|
| 144 |
+ defer client.Close() |
|
| 145 | 145 |
|
| 146 | 146 |
ctx := context.Background() |
| 147 | 147 |
secretResp, err := client.SecretCreate(ctx, swarmtypes.SecretSpec{
|
| ... | ... |
@@ -221,8 +221,8 @@ func TestCreateServiceConfigFileMode(t *testing.T) {
|
| 221 | 221 |
defer setupTest(t)() |
| 222 | 222 |
d := swarm.NewSwarm(t, testEnv) |
| 223 | 223 |
defer d.Stop(t) |
| 224 |
- client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) |
|
| 225 |
- assert.NilError(t, err) |
|
| 224 |
+ client := d.NewClientT(t) |
|
| 225 |
+ defer client.Close() |
|
| 226 | 226 |
|
| 227 | 227 |
ctx := context.Background() |
| 228 | 228 |
configResp, err := client.ConfigCreate(ctx, swarmtypes.ConfigSpec{
|
| ... | ... |
@@ -23,8 +23,8 @@ func TestInspect(t *testing.T) {
|
| 23 | 23 |
defer setupTest(t)() |
| 24 | 24 |
d := swarm.NewSwarm(t, testEnv) |
| 25 | 25 |
defer d.Stop(t) |
| 26 |
- client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) |
|
| 27 |
- assert.NilError(t, err) |
|
| 26 |
+ client := d.NewClientT(t) |
|
| 27 |
+ defer client.Close() |
|
| 28 | 28 |
|
| 29 | 29 |
var now = time.Now() |
| 30 | 30 |
var instances uint64 = 2 |
| ... | ... |
@@ -6,7 +6,6 @@ import ( |
| 6 | 6 |
|
| 7 | 7 |
"github.com/docker/docker/api/types" |
| 8 | 8 |
"github.com/docker/docker/api/types/network" |
| 9 |
- "github.com/docker/docker/client" |
|
| 10 | 9 |
"github.com/docker/docker/integration/internal/container" |
| 11 | 10 |
"github.com/docker/docker/integration/internal/swarm" |
| 12 | 11 |
"github.com/gotestyourself/gotestyourself/assert" |
| ... | ... |
@@ -17,12 +16,12 @@ func TestDockerNetworkConnectAlias(t *testing.T) {
|
| 17 | 17 |
defer setupTest(t)() |
| 18 | 18 |
d := swarm.NewSwarm(t, testEnv) |
| 19 | 19 |
defer d.Stop(t) |
| 20 |
- client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) |
|
| 21 |
- assert.NilError(t, err) |
|
| 20 |
+ client := d.NewClientT(t) |
|
| 21 |
+ defer client.Close() |
|
| 22 | 22 |
ctx := context.Background() |
| 23 | 23 |
|
| 24 | 24 |
name := "test-alias" |
| 25 |
- _, err = client.NetworkCreate(ctx, name, types.NetworkCreate{
|
|
| 25 |
+ _, err := client.NetworkCreate(ctx, name, types.NetworkCreate{
|
|
| 26 | 26 |
Driver: "overlay", |
| 27 | 27 |
Attachable: true, |
| 28 | 28 |
}) |
| ... | ... |
@@ -1,5 +1,7 @@ |
| 1 | 1 |
package daemon |
| 2 | 2 |
|
| 3 |
+import "github.com/docker/docker/internal/test/environment" |
|
| 4 |
+ |
|
| 3 | 5 |
// WithExperimental sets the daemon in experimental mode |
| 4 | 6 |
func WithExperimental(d *Daemon) {
|
| 5 | 7 |
d.experimental = true |
| ... | ... |
@@ -25,3 +27,12 @@ func WithSwarmListenAddr(listenAddr string) func(*Daemon) {
|
| 25 | 25 |
d.swarmListenAddr = listenAddr |
| 26 | 26 |
} |
| 27 | 27 |
} |
| 28 |
+ |
|
| 29 |
+// WithEnvironment sets options from internal/test/environment.Execution struct |
|
| 30 |
+func WithEnvironment(e environment.Execution) func(*Daemon) {
|
|
| 31 |
+ return func(d *Daemon) {
|
|
| 32 |
+ if e.DaemonInfo.ExperimentalBuild {
|
|
| 33 |
+ d.experimental = true |
|
| 34 |
+ } |
|
| 35 |
+ } |
|
| 36 |
+} |
| ... | ... |
@@ -13,9 +13,7 @@ import ( |
| 13 | 13 |
// ServiceConstructor defines a swarm service constructor function |
| 14 | 14 |
type ServiceConstructor func(*swarm.Service) |
| 15 | 15 |
|
| 16 |
-// CreateServiceWithOptions creates a swarm service given the specified service constructors |
|
| 17 |
-// and auth config |
|
| 18 |
-func (d *Daemon) CreateServiceWithOptions(t assert.TestingT, opts types.ServiceCreateOptions, f ...ServiceConstructor) string {
|
|
| 16 |
+func (d *Daemon) createServiceWithOptions(t assert.TestingT, opts types.ServiceCreateOptions, f ...ServiceConstructor) string {
|
|
| 19 | 17 |
var service swarm.Service |
| 20 | 18 |
for _, fn := range f {
|
| 21 | 19 |
fn(&service) |
| ... | ... |
@@ -34,7 +32,7 @@ func (d *Daemon) CreateServiceWithOptions(t assert.TestingT, opts types.ServiceC |
| 34 | 34 |
|
| 35 | 35 |
// CreateService creates a swarm service given the specified service constructor |
| 36 | 36 |
func (d *Daemon) CreateService(t assert.TestingT, f ...ServiceConstructor) string {
|
| 37 |
- return d.CreateServiceWithOptions(t, types.ServiceCreateOptions{}, f...)
|
|
| 37 |
+ return d.createServiceWithOptions(t, types.ServiceCreateOptions{}, f...)
|
|
| 38 | 38 |
} |
| 39 | 39 |
|
| 40 | 40 |
// GetService returns the swarm service corresponding to the specified id |
| ... | ... |
@@ -14,6 +14,32 @@ const ( |
| 14 | 14 |
defaultSwarmListenAddr = "0.0.0.0" |
| 15 | 15 |
) |
| 16 | 16 |
|
| 17 |
+// StartAndSwarmInit starts the daemon (with busybox) and init the swarm |
|
| 18 |
+func (d *Daemon) StartAndSwarmInit(t testingT) {
|
|
| 19 |
+ // avoid networking conflicts |
|
| 20 |
+ args := []string{"--iptables=false", "--swarm-default-advertise-addr=lo"}
|
|
| 21 |
+ d.StartWithBusybox(t, args...) |
|
| 22 |
+ |
|
| 23 |
+ d.SwarmInit(t, swarm.InitRequest{})
|
|
| 24 |
+} |
|
| 25 |
+ |
|
| 26 |
+// StartAndSwarmJoin starts the daemon (with busybox) and join the specified swarm as worker or manager |
|
| 27 |
+func (d *Daemon) StartAndSwarmJoin(t testingT, leader *Daemon, manager bool) {
|
|
| 28 |
+ // avoid networking conflicts |
|
| 29 |
+ args := []string{"--iptables=false", "--swarm-default-advertise-addr=lo"}
|
|
| 30 |
+ d.StartWithBusybox(t, args...) |
|
| 31 |
+ |
|
| 32 |
+ tokens := leader.JoinTokens(t) |
|
| 33 |
+ token := tokens.Worker |
|
| 34 |
+ if manager {
|
|
| 35 |
+ token = tokens.Manager |
|
| 36 |
+ } |
|
| 37 |
+ d.SwarmJoin(t, swarm.JoinRequest{
|
|
| 38 |
+ RemoteAddrs: []string{leader.SwarmListenAddr()},
|
|
| 39 |
+ JoinToken: token, |
|
| 40 |
+ }) |
|
| 41 |
+} |
|
| 42 |
+ |
|
| 17 | 43 |
// SpecConstructor defines a swarm spec constructor |
| 18 | 44 |
type SpecConstructor func(*swarm.Spec) |
| 19 | 45 |
|