diff --git a/pkg/member/member.go b/pkg/member/member.go index 6eddf9a7c77..dd36214a595 100644 --- a/pkg/member/member.go +++ b/pkg/member/member.go @@ -27,6 +27,7 @@ import ( "time" "github.com/pingcap/errors" + "github.com/pingcap/failpoint" "github.com/pingcap/kvproto/pkg/pdpb" "github.com/pingcap/log" "github.com/tikv/pd/pkg/election" @@ -181,6 +182,9 @@ func (m *EmbeddedEtcdMember) GetLastLeaderUpdatedTime() time.Time { // and make it become a PD leader. // leader should be changed when campaign leader frequently. func (m *EmbeddedEtcdMember) CampaignLeader(ctx context.Context, leaseTimeout int64) error { + failpoint.Inject("skipCampaignLeaderCheck", func() { + failpoint.Return(m.leadership.Campaign(leaseTimeout, m.MemberValue())) + }) if len(m.leadership.CampaignTimes) >= campaignLeaderFrequencyTimes { log.Warn("campaign times is too frequent, resign and campaign again", zap.String("leader-name", m.Name()), zap.String("leader-key", m.GetLeaderPath())) diff --git a/tests/integrations/tso/client_test.go b/tests/integrations/tso/client_test.go index 63243214e81..73198690966 100644 --- a/tests/integrations/tso/client_test.go +++ b/tests/integrations/tso/client_test.go @@ -300,7 +300,10 @@ func (suite *tsoClientTestSuite) TestUpdateAfterResetTSO() { re := suite.Require() ctx, cancel := context.WithCancel(suite.ctx) defer cancel() - + re.NoError(failpoint.Enable("github.com/tikv/pd/pkg/member/skipCampaignLeaderCheck", "return(true)")) + defer func() { + re.NoError(failpoint.Disable("github.com/tikv/pd/pkg/member/skipCampaignLeaderCheck")) + }() for i := 0; i < len(suite.clients); i++ { client := suite.clients[i] testutil.Eventually(re, func() bool {