api: fixing join tests

This commit is contained in:
Ryan Uber
2015-09-14 14:04:30 -07:00
parent c9bb562ec1
commit 3d8b115943
2 changed files with 16 additions and 5 deletions

View File

@@ -114,7 +114,7 @@ func (a *Agent) Join(addrs ...string) (int, error) {
if resp.Error != "" {
return 0, fmt.Errorf("failed joining: %s", resp.Error)
}
return resp.NumNodes, nil
return resp.NumJoined, nil
}
// Members is used to query all of the known server members
@@ -138,8 +138,8 @@ func (a *Agent) ForceLeave(node string) error {
// joinResponse is used to decode the response we get while
// sending a member join request.
type joinResponse struct {
NumNodes int `json:"num_nodes"`
Error string `json:"error"`
NumJoined int `json:"num_joined"`
Error string `json:"error"`
}
// AgentMember represents a cluster member known to the agent

View File

@@ -11,10 +11,21 @@ import (
type configCallback func(c *Config)
// seen is used to track which tests we have already marked as parallel
var seen map[*testing.T]struct{}
func init() {
seen = make(map[*testing.T]struct{})
}
func makeClient(t *testing.T, cb1 configCallback,
cb2 testutil.ServerConfigCallback) (*Client, *testutil.TestServer) {
// Always run these tests in parallel
t.Parallel()
// Always run these tests in parallel. Check if we have already
// marked the current test, as more than 1 call causes panics.
if _, ok := seen[t]; !ok {
seen[t] = struct{}{}
t.Parallel()
}
// Make client config
conf := DefaultConfig()