From 840124a19642768f0ab2cb3aa7ec420008e56349 Mon Sep 17 00:00:00 2001 From: Arash Deshmeh Date: Sat, 16 Jun 2018 06:04:31 -0400 Subject: [PATCH 1/3] refactored integration/service/network integration tests to use network package Signed-off-by: Arash Deshmeh Upstream-commit: 8b07ec58ea5792f906c006edc5db9f37c7a570de Component: engine --- .../engine/integration/internal/network/ops.go | 7 +++++++ .../engine/integration/service/network_test.go | 12 ++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/components/engine/integration/internal/network/ops.go b/components/engine/integration/internal/network/ops.go index 9b69b79bfb..33bd3d05f3 100644 --- a/components/engine/integration/internal/network/ops.go +++ b/components/engine/integration/internal/network/ops.go @@ -33,6 +33,13 @@ func WithInternal() func(*types.NetworkCreate) { } } +// WithAttachable sets Attachable flag on the create network request +func WithAttachable() func(*types.NetworkCreate) { + return func(n *types.NetworkCreate) { + n.Attachable = true + } +} + // WithMacvlan sets the network as macvlan with the specified parent func WithMacvlan(parent string) func(*types.NetworkCreate) { return func(n *types.NetworkCreate) { diff --git a/components/engine/integration/service/network_test.go b/components/engine/integration/service/network_test.go index 4ebbd972a8..ba170fce0e 100644 --- a/components/engine/integration/service/network_test.go +++ b/components/engine/integration/service/network_test.go @@ -7,6 +7,7 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/network" "github.com/docker/docker/integration/internal/container" + net "github.com/docker/docker/integration/internal/network" "github.com/docker/docker/integration/internal/swarm" "gotest.tools/assert" is "gotest.tools/assert/cmp" @@ -21,11 +22,10 @@ func TestDockerNetworkConnectAlias(t *testing.T) { ctx := context.Background() name := t.Name() + "test-alias" - _, err := client.NetworkCreate(ctx, name, types.NetworkCreate{ - Driver: "overlay", - Attachable: true, - }) - assert.NilError(t, err) + net.CreateNoError(t, ctx, client, name, + net.WithDriver("overlay"), + net.WithAttachable(), + ) cID1 := container.Create(t, ctx, client, func(c *container.TestContainerConfig) { c.NetworkingConfig = &network.NetworkingConfig{ @@ -35,7 +35,7 @@ func TestDockerNetworkConnectAlias(t *testing.T) { } }) - err = client.NetworkConnect(ctx, name, cID1, &network.EndpointSettings{ + err := client.NetworkConnect(ctx, name, cID1, &network.EndpointSettings{ Aliases: []string{ "aaa", }, From f402d858a86a6c2b4eea93ef223c4c97b373b7d2 Mon Sep 17 00:00:00 2001 From: Yuichiro Kaneko Date: Tue, 26 Jun 2018 21:35:43 +0900 Subject: [PATCH 2/3] Update comments about `InitRouter` This is a follow-up of commit 408c7ad (PR: #32453) Signed-off-by: Yuichiro Kaneko Upstream-commit: dbd4c290b7029d31fa69c906a8da864589f19e09 Component: engine --- components/engine/api/server/server.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/engine/api/server/server.go b/components/engine/api/server/server.go index 3874a56ce5..c364008286 100644 --- a/components/engine/api/server/server.go +++ b/components/engine/api/server/server.go @@ -149,7 +149,7 @@ func (s *Server) makeHTTPHandler(handler httputils.APIFunc) http.HandlerFunc { } // InitRouter initializes the list of routers for the server. -// This method also enables the Go profiler if enableProfiler is true. +// This method also enables the Go profiler. func (s *Server) InitRouter(routers ...router.Router) { s.routers = append(s.routers, routers...) From bc8dee16e557300d48a2439e0ca1869c23b05414 Mon Sep 17 00:00:00 2001 From: Lotus Fenn Date: Wed, 27 Jun 2018 00:56:52 -0700 Subject: [PATCH 3/3] add unique names to integration/network/service_test.go Signed-off-by: Lotus Fenn Upstream-commit: f94c97d3200ec11762fc3fb3c2eafd5866ffa976 Component: engine --- .../engine/integration/network/service_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/components/engine/integration/network/service_test.go b/components/engine/integration/network/service_test.go index d926045b72..b276c510cd 100644 --- a/components/engine/integration/network/service_test.go +++ b/components/engine/integration/network/service_test.go @@ -66,7 +66,7 @@ func TestDaemonDefaultNetworkPools(t *testing.T) { assert.Equal(t, out.IPAM.Config[0].Subnet, "175.30.0.0/16") // Create a bridge network and verify its subnet is the second default pool - name := "elango" + name := "elango" + t.Name() network.CreateNoError(t, context.Background(), cli, name, network.WithDriver("bridge"), ) @@ -75,7 +75,7 @@ func TestDaemonDefaultNetworkPools(t *testing.T) { assert.Equal(t, out.IPAM.Config[0].Subnet, "175.33.0.0/24") // Create a bridge network and verify its subnet is the third default pool - name = "saanvi" + name = "saanvi" + t.Name() network.CreateNoError(t, context.Background(), cli, name, network.WithDriver("bridge"), ) @@ -99,7 +99,7 @@ func TestDaemonRestartWithExistingNetwork(t *testing.T) { defer cli.Close() // Create a bridge network - name := "elango" + name := "elango" + t.Name() network.CreateNoError(t, context.Background(), cli, name, network.WithDriver("bridge"), ) @@ -131,7 +131,7 @@ func TestDaemonRestartWithExistingNetworkWithDefaultPoolRange(t *testing.T) { defer cli.Close() // Create a bridge network - name := "elango" + name := "elango" + t.Name() network.CreateNoError(t, context.Background(), cli, name, network.WithDriver("bridge"), ) @@ -140,7 +140,7 @@ func TestDaemonRestartWithExistingNetworkWithDefaultPoolRange(t *testing.T) { networkip := out.IPAM.Config[0].Subnet // Create a bridge network - name = "sthira" + name = "sthira" + t.Name() network.CreateNoError(t, context.Background(), cli, name, network.WithDriver("bridge"), ) @@ -154,7 +154,7 @@ func TestDaemonRestartWithExistingNetworkWithDefaultPoolRange(t *testing.T) { "--default-address-pool", "base=175.19.0.0/16,size=24") // Create a bridge network - name = "saanvi" + name = "saanvi" + t.Name() network.CreateNoError(t, context.Background(), cli, name, network.WithDriver("bridge"), )