Skip to content

Commit

Permalink
tests: make TestAllocIDAfterLeaderChange more stable (tikv#8558)
Browse files Browse the repository at this point in the history
close tikv#8557

need to wait leader

Signed-off-by: husharp <[email protected]>

Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
  • Loading branch information
HuSharp and ti-chi-bot[bot] authored Aug 22, 2024
1 parent c963e77 commit 32829f1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/integrations/mcs/scheduling/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ func (suite *serverTestSuite) TestAllocIDAfterLeaderChange() {
pd2, err := suite.cluster.Join(suite.ctx)
re.NoError(err)
err = pd2.Run()
re.NotEmpty(suite.cluster.WaitLeader())
re.NoError(err)
tc, err := tests.NewTestSchedulingCluster(suite.ctx, 1, suite.backendEndpoints)
re.NoError(err)
Expand Down
2 changes: 2 additions & 0 deletions tests/server/join/join_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func TestSimpleJoin(t *testing.T) {
re.NoError(err)
_, err = os.Stat(filepath.Join(pd2.GetConfig().DataDir, "join"))
re.False(os.IsNotExist(err))
re.NotEmpty(cluster.WaitLeader())
members, err = etcdutil.ListEtcdMembers(ctx, client)
re.NoError(err)
re.Len(members.Members, 2)
Expand All @@ -73,6 +74,7 @@ func TestSimpleJoin(t *testing.T) {
re.NoError(err)
_, err = os.Stat(filepath.Join(pd3.GetConfig().DataDir, "join"))
re.False(os.IsNotExist(err))
re.NotEmpty(cluster.WaitLeader())
members, err = etcdutil.ListEtcdMembers(ctx, client)
re.NoError(err)
re.Len(members.Members, 3)
Expand Down
1 change: 1 addition & 0 deletions tests/server/watch/leader_watch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func TestWatcher(t *testing.T) {
re.NoError(failpoint.Enable("github.com/tikv/pd/server/delayWatcher", `pause`))
err = pd3.Run()
re.NoError(err)
re.NotEmpty(cluster.WaitLeader())
time.Sleep(200 * time.Millisecond)
re.Equal(pd1.GetConfig().Name, pd3.GetLeader().GetName())
err = pd1.Stop()
Expand Down

0 comments on commit 32829f1

Please sign in to comment.