From 09e272f5d932bffae5b5c9e8f908994a829b3b4c Mon Sep 17 00:00:00 2001 From: Ryan Leung Date: Tue, 27 Aug 2024 11:43:46 +0800 Subject: [PATCH] *: remove the previous joined pd (#8562) close tikv/pd#7954 Signed-off-by: Ryan Leung --- tests/cluster.go | 5 +++++ tests/integrations/mcs/scheduling/api_test.go | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/tests/cluster.go b/tests/cluster.go index f9cbb99ce25..5cd90d8e03e 100644 --- a/tests/cluster.go +++ b/tests/cluster.go @@ -611,6 +611,11 @@ func (c *TestCluster) StopAll() error { return nil } +// DeleteServer is used to delete a server. +func (c *TestCluster) DeleteServer(name string) { + delete(c.servers, name) +} + // GetServer returns a server with a given name. func (c *TestCluster) GetServer(name string) *TestServer { return c.servers[name] diff --git a/tests/integrations/mcs/scheduling/api_test.go b/tests/integrations/mcs/scheduling/api_test.go index d2027a616cb..6335d104e3e 100644 --- a/tests/integrations/mcs/scheduling/api_test.go +++ b/tests/integrations/mcs/scheduling/api_test.go @@ -513,6 +513,20 @@ func (suite *apiTestSuite) checkFollowerForward(cluster *tests.TestCluster) { defer cancel() follower, err := cluster.JoinAPIServer(ctx) re.NoError(err) + defer func() { + leader := cluster.GetLeaderServer() + cli := leader.GetEtcdClient() + testutil.Eventually(re, func() bool { + _, err = cli.MemberRemove(context.Background(), follower.GetServer().GetMember().ID()) + return err == nil + }) + testutil.Eventually(re, func() bool { + res, err := cli.MemberList(context.Background()) + return err == nil && len(res.Members) == 1 + }) + cluster.DeleteServer(follower.GetConfig().Name) + follower.Destroy() + }() re.NoError(follower.Run()) re.NotEmpty(cluster.WaitLeader())