Make new config when retrying testServer creation (#6204)
This commit is contained in:
parent
c19f46639b
commit
1b97d65873
|
@ -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) {
|
func testServerWithConfig(t *testing.T, cb func(*Config)) (string, *Server) {
|
||||||
dir, config := testServerConfig(t)
|
var dir string
|
||||||
if cb != nil {
|
var config *Config
|
||||||
cb(config)
|
|
||||||
}
|
|
||||||
|
|
||||||
var srv *Server
|
var srv *Server
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
// Retry added to avoid cases where bind addr is already in use
|
// Retry added to avoid cases where bind addr is already in use
|
||||||
retry.RunWith(retry.ThreeTimes(), t, func(r *retry.R) {
|
retry.RunWith(retry.ThreeTimes(), t, func(r *retry.R) {
|
||||||
|
dir, config = testServerConfig(t)
|
||||||
|
if cb != nil {
|
||||||
|
cb(config)
|
||||||
|
}
|
||||||
|
|
||||||
srv, err = newServer(config)
|
srv, err = newServer(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
os.RemoveAll(dir)
|
os.RemoveAll(dir)
|
||||||
|
@ -183,10 +185,6 @@ func newServer(c *Config) (*Server, error) {
|
||||||
oldNotify()
|
oldNotify()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Restore old notify to guard against re-closing `up` on a retry
|
|
||||||
defer func() {
|
|
||||||
c.NotifyListen = oldNotify
|
|
||||||
}()
|
|
||||||
|
|
||||||
// start server
|
// start server
|
||||||
w := c.LogOutput
|
w := c.LogOutput
|
||||||
|
|
Loading…
Reference in New Issue