Skip to content

Commit

Permalink
DockerSwarmSuite lock portIndex to work around race
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastiaan van Stijn <[email protected]>
  • Loading branch information
thaJeztah committed Jul 13, 2019
1 parent 47a84dc commit c096225
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions integration-cli/check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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()

Expand All @@ -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)
}

Expand Down

0 comments on commit c096225

Please sign in to comment.