From 218af8c7bd5699b7b24437c28542c86ea64899f0 Mon Sep 17 00:00:00 2001 From: Arko Dasgupta Date: Thu, 15 Aug 2019 14:09:47 -0700 Subject: [PATCH] Move defer method to the top right after New is called Signed-off-by: Arko Dasgupta (cherry picked from commit a65dee30fc36ed974940b699ed22ab9242eac6cf) Signed-off-by: Sebastiaan van Stijn --- integration/network/service_test.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/integration/network/service_test.go b/integration/network/service_test.go index a965a17b22..df2404c372 100644 --- a/integration/network/service_test.go +++ b/integration/network/service_test.go @@ -353,6 +353,7 @@ func TestServiceWithDataPathPortInit(t *testing.T) { // Clean up , set it back to original one to make sure other tests don't fail // call without datapath port option. d = swarm.NewSwarm(t, testEnv) + defer d.Stop(t) nc := d.NewClientT(t) defer nc.Close() // Create a overlay network @@ -373,14 +374,12 @@ func TestServiceWithDataPathPortInit(t *testing.T) { assert.Equal(t, info.Swarm.Cluster.DataPathPort, defaultDataPathPort) err = nc.ServiceRemove(ctx, serviceID) assert.NilError(t, err) - assert.NilError(t, err) poll.WaitOn(t, noServices(ctx, nc), swarm.ServicePoll) poll.WaitOn(t, swarm.NoTasks(ctx, nc), swarm.ServicePoll) err = nc.NetworkRemove(ctx, overlayID) assert.NilError(t, err) err = d.SwarmLeave(t, true) assert.NilError(t, err) - defer d.Stop(t) } func TestServiceWithDefaultAddressPoolInit(t *testing.T) { @@ -389,7 +388,7 @@ func TestServiceWithDefaultAddressPoolInit(t *testing.T) { d := swarm.NewSwarm(t, testEnv, daemon.WithSwarmDefaultAddrPool([]string{"20.20.0.0/16"}), daemon.WithSwarmDefaultAddrPoolSubnetSize(24)) - + defer d.Stop(t) cli := d.NewClientT(t) defer cli.Close() ctx := context.Background() @@ -428,6 +427,5 @@ func TestServiceWithDefaultAddressPoolInit(t *testing.T) { assert.NilError(t, err) err = d.SwarmLeave(t, true) assert.NilError(t, err) - defer d.Stop(t) }