From ae88c29033e8751e613716d1568ab5b42342dbd8 Mon Sep 17 00:00:00 2001 From: Ryan Leung Date: Wed, 22 Nov 2023 14:53:36 +0800 Subject: [PATCH] make TestPrimaryChange stable Signed-off-by: Ryan Leung --- tests/integrations/mcs/scheduling/server_test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/integrations/mcs/scheduling/server_test.go b/tests/integrations/mcs/scheduling/server_test.go index eb99411d27e..afd213a624b 100644 --- a/tests/integrations/mcs/scheduling/server_test.go +++ b/tests/integrations/mcs/scheduling/server_test.go @@ -127,21 +127,21 @@ func (suite *serverTestSuite) TestPrimaryChange() { tc.WaitForPrimaryServing(re) primary := tc.GetPrimaryServer() oldPrimaryAddr := primary.GetAddr() - re.Len(primary.GetCluster().GetCoordinator().GetSchedulersController().GetSchedulerNames(), 5) testutil.Eventually(re, func() bool { watchedAddr, ok := suite.pdLeader.GetServicePrimaryAddr(suite.ctx, mcs.SchedulingServiceName) - return ok && oldPrimaryAddr == watchedAddr + return ok && oldPrimaryAddr == watchedAddr && + len(primary.GetCluster().GetCoordinator().GetSchedulersController().GetSchedulerNames()) == 5 }) - // transfer leader + // change primary primary.Close() tc.WaitForPrimaryServing(re) primary = tc.GetPrimaryServer() newPrimaryAddr := primary.GetAddr() re.NotEqual(oldPrimaryAddr, newPrimaryAddr) - re.Len(primary.GetCluster().GetCoordinator().GetSchedulersController().GetSchedulerNames(), 5) testutil.Eventually(re, func() bool { watchedAddr, ok := suite.pdLeader.GetServicePrimaryAddr(suite.ctx, mcs.SchedulingServiceName) - return ok && newPrimaryAddr == watchedAddr + return ok && newPrimaryAddr == watchedAddr && + len(primary.GetCluster().GetCoordinator().GetSchedulersController().GetSchedulerNames()) == 5 }) }