Skip to content

Commit

Permalink
make TestPrimaryChange stable (#7412)
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Leung <rleungx@gmail.com>
  • Loading branch information
rleungx authored Nov 22, 2023
1 parent 20da1c7 commit 7783c74
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tests/integrations/mcs/scheduling/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
}

Expand Down

0 comments on commit 7783c74

Please sign in to comment.