mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #2754 from xiang90/member_change
integration: add a test case for a full cluster rotation
This commit is contained in:
commit
33f3bb3074
@ -209,6 +209,27 @@ func TestForceNewCluster(t *testing.T) {
|
|||||||
clusterMustProgress(t, c.Members[:1])
|
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.
|
// Ensure we can remove a member then add a new one back immediately.
|
||||||
func TestIssue2681(t *testing.T) {
|
func TestIssue2681(t *testing.T) {
|
||||||
defer afterTest(t)
|
defer afterTest(t)
|
||||||
@ -399,8 +420,7 @@ func (c *cluster) HTTPMembers() []client.Member {
|
|||||||
|
|
||||||
func (c *cluster) addMember(t *testing.T, usePeerTLS bool) {
|
func (c *cluster) addMember(t *testing.T, usePeerTLS bool) {
|
||||||
clusterStr := c.Members[0].Cluster.String()
|
clusterStr := c.Members[0].Cluster.String()
|
||||||
idx := len(c.Members)
|
m := mustNewMember(t, c.name(rand.Int()), usePeerTLS)
|
||||||
m := mustNewMember(t, c.name(idx), usePeerTLS)
|
|
||||||
scheme := "http"
|
scheme := "http"
|
||||||
if usePeerTLS {
|
if usePeerTLS {
|
||||||
scheme = "https"
|
scheme = "https"
|
||||||
@ -447,7 +467,7 @@ func (c *cluster) AddTLSMember(t *testing.T) {
|
|||||||
|
|
||||||
func (c *cluster) RemoveMember(t *testing.T, id uint64) {
|
func (c *cluster) RemoveMember(t *testing.T, id uint64) {
|
||||||
// send remove request to the cluster
|
// send remove request to the cluster
|
||||||
cc := mustNewHTTPClient(t, []string{c.URL(0)})
|
cc := mustNewHTTPClient(t, c.URLs())
|
||||||
ma := client.NewMembersAPI(cc)
|
ma := client.NewMembersAPI(cc)
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), requestTimeout)
|
ctx, cancel := context.WithTimeout(context.Background(), requestTimeout)
|
||||||
if err := ma.Remove(ctx, types.ID(id).String()); err != nil {
|
if err := ma.Remove(ctx, types.ID(id).String()); err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user