Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
ref tikv#5568

Signed-off-by: Wenbo Zhang <[email protected]>
  • Loading branch information
ethercflow committed Oct 17, 2022
1 parent aae3f16 commit 8508800
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions server/api/trend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ func TestTrend(t *testing.T) {

// Create 3 operators that transfers leader, moves follower, moves leader.
re.NoError(svr.GetHandler().AddTransferLeaderOperator(4, 2))
changeToWitness(svr, 5, 2)
re.NoError(svr.GetHandler().AddTransferPeerOperator(5, 2, 3))
time.Sleep(time.Second)
mustWitness(re, svr, 5, 3)
re.NoError(svr.GetHandler().AddTransferPeerOperator(6, 1, 3))
// Complete the operators.
mustRegionHeartbeat(re, svr, region4.Clone(core.WithLeader(region4.GetStorePeer(2))))
Expand Down Expand Up @@ -124,3 +126,17 @@ func newRegionInfo(id uint64, startKey, endKey string, confVer, ver uint64, vote
leader,
)
}

func changeToWitness(svr *server.Server, regionID, storeID uint64) {
c := svr.GetRaftCluster()
region := c.GetRegion(regionID)
peer := region.GetStorePeer(storeID)
peer.IsWitness = true
}

func mustWitness(re *require.Assertions, svr *server.Server, regionID, storeID uint64) {
c := svr.GetRaftCluster()
region := c.GetRegion(regionID)
peer := region.GetStorePeer(storeID)
re.True(peer.IsWitness)
}

0 comments on commit 8508800

Please sign in to comment.