Skip to content
This repository was archived by the owner on Oct 13, 2023. It is now read-only.

Commit b537e79

Browse files
Arko DasguptathaJeztah
authored andcommitted
Move defer method to the top right after New is called
Signed-off-by: Arko Dasgupta <arko.dasgupta@docker.com> (cherry picked from commit a65dee30fc36ed974940b699ed22ab9242eac6cf) Signed-off-by: Sebastiaan van Stijn <github@gone.nl> Upstream-commit: 218af8c7bd5699b7b24437c28542c86ea64899f0 Component: engine
1 parent d113f11 commit b537e79

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

components/engine/integration/network/service_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ func TestServiceWithDataPathPortInit(t *testing.T) {
353353
// Clean up , set it back to original one to make sure other tests don't fail
354354
// call without datapath port option.
355355
d = swarm.NewSwarm(t, testEnv)
356+
defer d.Stop(t)
356357
nc := d.NewClientT(t)
357358
defer nc.Close()
358359
// Create a overlay network
@@ -373,14 +374,12 @@ func TestServiceWithDataPathPortInit(t *testing.T) {
373374
assert.Equal(t, info.Swarm.Cluster.DataPathPort, defaultDataPathPort)
374375
err = nc.ServiceRemove(ctx, serviceID)
375376
assert.NilError(t, err)
376-
assert.NilError(t, err)
377377
poll.WaitOn(t, noServices(ctx, nc), swarm.ServicePoll)
378378
poll.WaitOn(t, swarm.NoTasks(ctx, nc), swarm.ServicePoll)
379379
err = nc.NetworkRemove(ctx, overlayID)
380380
assert.NilError(t, err)
381381
err = d.SwarmLeave(t, true)
382382
assert.NilError(t, err)
383-
defer d.Stop(t)
384383
}
385384

386385
func TestServiceWithDefaultAddressPoolInit(t *testing.T) {
@@ -389,7 +388,7 @@ func TestServiceWithDefaultAddressPoolInit(t *testing.T) {
389388
d := swarm.NewSwarm(t, testEnv,
390389
daemon.WithSwarmDefaultAddrPool([]string{"20.20.0.0/16"}),
391390
daemon.WithSwarmDefaultAddrPoolSubnetSize(24))
392-
391+
defer d.Stop(t)
393392
cli := d.NewClientT(t)
394393
defer cli.Close()
395394
ctx := context.Background()
@@ -428,6 +427,5 @@ func TestServiceWithDefaultAddressPoolInit(t *testing.T) {
428427
assert.NilError(t, err)
429428
err = d.SwarmLeave(t, true)
430429
assert.NilError(t, err)
431-
defer d.Stop(t)
432430

433431
}

0 commit comments

Comments
 (0)