Skip to content

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
  • Loading branch information
GMHDBJD authored and ti-chi-bot committed Sep 24, 2024
1 parent cfe8b62 commit cacc69e
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions dm/pkg/election/election_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,10 +447,6 @@ func (t *testElectionSuite) TestElectionSucceedButReturnError(c *C) {
c.Assert(leaderID, Equals, e1.ID())
c.Assert(leaderAddr, Equals, addr1)

c.Assert(failpoint.Enable("github.com/pingcap/tiflow/dm/pkg/election/mockCapaignSucceedButReturnErr", `return()`), IsNil)
//nolint:errcheck
defer failpoint.Disable("github.com/pingcap/tiflow/dm/pkg/election/mockCapaignSucceedButReturnErr")

// start e2
ctx2, cancel2 := context.WithCancel(context.Background())
defer cancel2()
Expand All @@ -470,15 +466,13 @@ func (t *testElectionSuite) TestElectionSucceedButReturnError(c *C) {
c.Assert(leaderAddr, Equals, addr1)
c.Assert(e2.IsLeader(), IsFalse)

c.Assert(failpoint.Enable("github.com/pingcap/tiflow/dm/pkg/election/mockCapaignSucceedButReturnErr", `return()`), IsNil)
//nolint:errcheck
defer failpoint.Disable("github.com/pingcap/tiflow/dm/pkg/election/mockCapaignSucceedButReturnErr")

e1.Close() // stop the campaign for e1
c.Assert(e1.IsLeader(), IsFalse)

ctx3, cancel3 := context.WithTimeout(context.Background(), 60*time.Second)
defer cancel3()
deleted, err := e2.ClearSessionIfNeeded(ctx3, ID1)
c.Assert(err, IsNil)
c.Assert(deleted, IsFalse)

// e2 should become the leader
select {
case leader := <-e2.LeaderNotify():
Expand Down

0 comments on commit cacc69e

Please sign in to comment.