integration: add a test case for a full cluster rotation

This commit is contained in:
Xiang Li 2015-04-24 14:34:21 -07:00
parent d080c33c07
commit 077c8397d2

View File

@ -209,6 +209,27 @@ func TestForceNewCluster(t *testing.T) {
clusterMustProgress(t, c.Members[:1])
}
func TestAddMemberAfterClusterFullRotation(t *testing.T) {
defer afterTest(t)
c := NewCluster(t, 3)
c.Launch(t)
defer c.Terminate(t)
// remove all the previous three members and add in three new members.
for i := 0; i < 3; i++ {
c.RemoveMember(t, uint64(c.Members[0].s.ID()))
c.waitLeader(t, c.Members)
c.AddMember(t)
c.waitLeader(t, c.Members)
}
c.AddMember(t)
c.waitLeader(t, c.Members)
clusterMustProgress(t, c.Members)
}
// Ensure we can remove a member then add a new one back immediately.
func TestIssue2681(t *testing.T) {
defer afterTest(t)
@ -399,8 +420,7 @@ func (c *cluster) HTTPMembers() []client.Member {
func (c *cluster) addMember(t *testing.T, usePeerTLS bool) {
clusterStr := c.Members[0].Cluster.String()
idx := len(c.Members)
m := mustNewMember(t, c.name(idx), usePeerTLS)
m := mustNewMember(t, c.name(rand.Int()), usePeerTLS)
scheme := "http"
if usePeerTLS {
scheme = "https"
@ -447,7 +467,7 @@ func (c *cluster) AddTLSMember(t *testing.T) {
func (c *cluster) RemoveMember(t *testing.T, id uint64) {
// send remove request to the cluster
cc := mustNewHTTPClient(t, []string{c.URL(0)})
cc := mustNewHTTPClient(t, c.URLs())
ma := client.NewMembersAPI(cc)
ctx, cancel := context.WithTimeout(context.Background(), requestTimeout)
if err := ma.Remove(ctx, types.ID(id).String()); err != nil {