From c096225e8ee6cb36e363ac38de4e4a566cf09918 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sat, 13 Jul 2019 03:13:37 +0200 Subject: [PATCH] DockerSwarmSuite lock portIndex to work around race Signed-off-by: Sebastiaan van Stijn --- integration-cli/check_test.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/integration-cli/check_test.go b/integration-cli/check_test.go index 2a0b1a25d5..38eb63579c 100644 --- a/integration-cli/check_test.go +++ b/integration-cli/check_test.go @@ -304,8 +304,8 @@ func init() { type DockerSwarmSuite struct { server *httptest.Server ds *DockerSuite + daemonsLock sync.Mutex // protect access to daemons and portIndex daemons []*daemon.Daemon - daemonsLock sync.Mutex // protect access to daemons portIndex int } @@ -336,8 +336,8 @@ func (s *DockerSwarmSuite) AddDaemon(c *check.C, joinSwarm, manager bool) *daemo d.StartNode(c) } - s.portIndex++ s.daemonsLock.Lock() + s.portIndex++ s.daemons = append(s.daemons, d) s.daemonsLock.Unlock() @@ -354,9 +354,8 @@ func (s *DockerSwarmSuite) TearDownTest(c *check.C) { } } s.daemons = nil - s.daemonsLock.Unlock() - s.portIndex = 0 + s.daemonsLock.Unlock() s.ds.TearDownTest(c) }