From 850880042e32a87987fab19f7dfe23ee0f5e8eb8 Mon Sep 17 00:00:00 2001
From: Wenbo Zhang <ethercflow@gmail.com>
Date: Mon, 17 Oct 2022 18:13:49 +0800
Subject: [PATCH] tmp

ref tikv/pd#5568

Signed-off-by: Wenbo Zhang <ethercflow@gmail.com>
---
 server/api/trend_test.go | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/server/api/trend_test.go b/server/api/trend_test.go
index 9655faf0b7a2..26bf4794edc8 100644
--- a/server/api/trend_test.go
+++ b/server/api/trend_test.go
@@ -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))))
@@ -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)
+}