mirror of
https://github.com/status-im/consul.git
synced 2025-01-14 07:44:50 +00:00
testutil: key leader wait on bootstrap flag
This commit is contained in:
parent
04d73628d1
commit
480c189d9a
@ -29,10 +29,9 @@ func TestMain(t *testing.T) {
|
|||||||
defer srv1.Stop()
|
defer srv1.Stop()
|
||||||
|
|
||||||
// Create a secondary server, passing in configuration
|
// Create a secondary server, passing in configuration
|
||||||
// to avoid bootstrapping or waiting for a leader.
|
// to avoid bootstrapping as we are forming a cluster.
|
||||||
srv2 := testutil.NewTestServerConfig(t, func(c *testutil.TestServerConfig) {
|
srv2 := testutil.NewTestServerConfig(t, func(c *testutil.TestServerConfig) {
|
||||||
c.Bootstrap = false
|
c.Bootstrap = false
|
||||||
c.NoLeaderWait = true
|
|
||||||
})
|
})
|
||||||
defer srv2.Stop()
|
defer srv2.Stop()
|
||||||
|
|
||||||
|
@ -59,11 +59,6 @@ type TestServerConfig struct {
|
|||||||
Bind string `json:"bind_addr,omitempty"`
|
Bind string `json:"bind_addr,omitempty"`
|
||||||
Addresses *TestAddressConfig `json:"addresses,omitempty"`
|
Addresses *TestAddressConfig `json:"addresses,omitempty"`
|
||||||
Ports *TestPortConfig `json:"ports,omitempty"`
|
Ports *TestPortConfig `json:"ports,omitempty"`
|
||||||
|
|
||||||
// NoLeaderWait is a special config option used to instruct
|
|
||||||
// the test harness not to wait for a leader. Useful for
|
|
||||||
// bootstrapping a multi-node cluster for testing.
|
|
||||||
NoLeaderWait bool `json:"-"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ServerConfigCallback is a function interface which can be
|
// ServerConfigCallback is a function interface which can be
|
||||||
@ -207,10 +202,10 @@ func NewTestServerConfig(t *testing.T, cb ServerConfigCallback) *TestServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Wait for the server to be ready
|
// Wait for the server to be ready
|
||||||
if consulConfig.NoLeaderWait {
|
if consulConfig.Bootstrap {
|
||||||
server.waitForAPI()
|
|
||||||
} else {
|
|
||||||
server.waitForLeader()
|
server.waitForLeader()
|
||||||
|
} else {
|
||||||
|
server.waitForAPI()
|
||||||
}
|
}
|
||||||
|
|
||||||
return server
|
return server
|
||||||
|
Loading…
x
Reference in New Issue
Block a user