From 79590fda366145a2d2b1eef0ac6313e2e05198f9 Mon Sep 17 00:00:00 2001 From: Arash Deshmeh Date: Fri, 15 Jun 2018 16:06:45 -0400 Subject: [PATCH 1/2] migrate TestAPINetworkCreateDelete from integration-cli/ to integration/ Signed-off-by: Arash Deshmeh Upstream-commit: f5426214295cb59d54ece5a24d4720e31947981b Component: engine --- .../integration-cli/docker_api_network_test.go | 18 ------------------ .../engine/integration/network/delete_test.go | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/components/engine/integration-cli/docker_api_network_test.go b/components/engine/integration-cli/docker_api_network_test.go index 9c22cb7e3a..9ec2ba90e8 100644 --- a/components/engine/integration-cli/docker_api_network_test.go +++ b/components/engine/integration-cli/docker_api_network_test.go @@ -26,24 +26,6 @@ func (s *DockerSuite) TestAPINetworkGetDefaults(c *check.C) { } } -func (s *DockerSuite) TestAPINetworkCreateDelete(c *check.C) { - testRequires(c, DaemonIsLinux) - // Create a network - name := "testnetwork" - config := types.NetworkCreateRequest{ - Name: name, - NetworkCreate: types.NetworkCreate{ - CheckDuplicate: true, - }, - } - id := createNetwork(c, config, http.StatusCreated) - c.Assert(isNetworkAvailable(c, name), checker.Equals, true) - - // delete the network and make sure it is deleted - deleteNetwork(c, id, true) - c.Assert(isNetworkAvailable(c, name), checker.Equals, false) -} - func (s *DockerSuite) TestAPINetworkCreateCheckDuplicate(c *check.C) { testRequires(c, DaemonIsLinux) name := "testcheckduplicate" diff --git a/components/engine/integration/network/delete_test.go b/components/engine/integration/network/delete_test.go index c2684ae247..c9099f4816 100644 --- a/components/engine/integration/network/delete_test.go +++ b/components/engine/integration/network/delete_test.go @@ -44,6 +44,24 @@ func createAmbiguousNetworks(t *testing.T) (string, string, string) { return testNet, idPrefixNet, fullIDNet } +func TestNetworkCreateDelete(t *testing.T) { + skip.If(t, testEnv.DaemonInfo.OSType != "linux") + defer setupTest(t)() + client := request.NewAPIClient(t) + ctx := context.Background() + + netName := "testnetwork_" + t.Name() + network.CreateNoError(t, ctx, client, netName, + network.WithCheckDuplicate(), + ) + assert.Check(t, IsNetworkAvailable(client, netName)) + + // delete the network and make sure it is deleted + err := client.NetworkRemove(ctx, netName) + assert.NilError(t, err) + assert.Check(t, IsNetworkNotAvailable(client, netName)) +} + // TestDockerNetworkDeletePreferID tests that if a network with a name // equal to another network's ID exists, the Network with the given // ID is removed, and not the network with the given name. From 28ecd8f494eb4b5050b8d87e244f0a6956305ca5 Mon Sep 17 00:00:00 2001 From: Arash Deshmeh Date: Mon, 11 Jun 2018 12:11:22 -0400 Subject: [PATCH 2/2] refactor network inspect integration tests to use network package Signed-off-by: Arash Deshmeh Upstream-commit: dda4128c7ea6df5565e4ad3c0f0958a0aad547da Component: engine --- .../engine/integration/internal/network/ops.go | 2 +- .../engine/integration/network/inspect_test.go | 15 ++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/components/engine/integration/internal/network/ops.go b/components/engine/integration/internal/network/ops.go index 8bec62d79e..9b69b79bfb 100644 --- a/components/engine/integration/internal/network/ops.go +++ b/components/engine/integration/internal/network/ops.go @@ -19,7 +19,7 @@ func WithIPv6() func(*types.NetworkCreate) { } } -// WithCheckDuplicate enables CheckDuplicate on the create network request +// WithCheckDuplicate sets the CheckDuplicate field on create network request func WithCheckDuplicate() func(*types.NetworkCreate) { return func(n *types.NetworkCreate) { n.CheckDuplicate = true diff --git a/components/engine/integration/network/inspect_test.go b/components/engine/integration/network/inspect_test.go index 659ca29735..815ffb4c33 100644 --- a/components/engine/integration/network/inspect_test.go +++ b/components/engine/integration/network/inspect_test.go @@ -9,6 +9,7 @@ import ( "github.com/docker/docker/api/types/filters" swarmtypes "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/client" + "github.com/docker/docker/integration/internal/network" "github.com/docker/docker/integration/internal/swarm" "gotest.tools/assert" "gotest.tools/poll" @@ -24,14 +25,10 @@ func TestInspectNetwork(t *testing.T) { defer client.Close() overlayName := "overlay1" - networkCreate := types.NetworkCreate{ - CheckDuplicate: true, - Driver: "overlay", - } - - netResp, err := client.NetworkCreate(context.Background(), overlayName, networkCreate) - assert.NilError(t, err) - overlayID := netResp.ID + overlayID := network.CreateNoError(t, context.Background(), client, overlayName, + network.WithDriver("overlay"), + network.WithCheckDuplicate(), + ) var instances uint64 = 4 serviceName := "TestService" + t.Name() @@ -44,7 +41,7 @@ func TestInspectNetwork(t *testing.T) { poll.WaitOn(t, serviceRunningTasksCount(client, serviceID, instances), swarm.ServicePoll) - _, _, err = client.ServiceInspectWithRaw(context.Background(), serviceID, types.ServiceInspectOptions{}) + _, _, err := client.ServiceInspectWithRaw(context.Background(), serviceID, types.ServiceInspectOptions{}) assert.NilError(t, err) // Test inspect verbose with full NetworkID