Skip to content

Commit

Permalink
Make new config when retrying testServer creation (#6204)
Browse files Browse the repository at this point in the history
  • Loading branch information
freddygv authored Jul 24, 2019
1 parent d86efb8 commit 199f6cc
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions agent/consul/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,18 @@ func testServerDCExpectNonVoter(t *testing.T, dc string, expect int) (string, *S
}

func testServerWithConfig(t *testing.T, cb func(*Config)) (string, *Server) {
dir, config := testServerConfig(t)
if cb != nil {
cb(config)
}

var dir string
var config *Config
var srv *Server
var err error

// Retry added to avoid cases where bind addr is already in use
retry.RunWith(retry.ThreeTimes(), t, func(r *retry.R) {
dir, config = testServerConfig(t)
if cb != nil {
cb(config)
}

srv, err = newServer(config)
if err != nil {
os.RemoveAll(dir)
Expand All @@ -183,10 +185,6 @@ func newServer(c *Config) (*Server, error) {
oldNotify()
}
}
// Restore old notify to guard against re-closing `up` on a retry
defer func() {
c.NotifyListen = oldNotify
}()

// start server
w := c.LogOutput
Expand Down

0 comments on commit 199f6cc

Please sign in to comment.