Skip to content

Commit

Permalink
testutil: key leader wait on bootstrap flag
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanuber committed May 9, 2015
1 parent 04d7362 commit 480c189
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
3 changes: 1 addition & 2 deletions testutil/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ func TestMain(t *testing.T) {
defer srv1.Stop()

// 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) {
c.Bootstrap = false
c.NoLeaderWait = true
})
defer srv2.Stop()

Expand Down
11 changes: 3 additions & 8 deletions testutil/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@ type TestServerConfig struct {
Bind string `json:"bind_addr,omitempty"`
Addresses *TestAddressConfig `json:"addresses,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
Expand Down Expand Up @@ -207,10 +202,10 @@ func NewTestServerConfig(t *testing.T, cb ServerConfigCallback) *TestServer {
}

// Wait for the server to be ready
if consulConfig.NoLeaderWait {
server.waitForAPI()
} else {
if consulConfig.Bootstrap {
server.waitForLeader()
} else {
server.waitForAPI()
}

return server
Expand Down

0 comments on commit 480c189

Please sign in to comment.