Skip to content

Commit d137e35

Browse files
committed
fix ut
Signed-off-by: okjiang <[email protected]>
1 parent dbcc245 commit d137e35

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

server/cluster/cluster.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2451,10 +2451,6 @@ func (c *RaftCluster) SetAllStoresLimit(typ storelimit.Type, ratePerMin float64)
24512451

24522452
// refreshStoreRateLimit applies the schedule config's store limit to the in-memory store limiter.
24532453
func (c *RaftCluster) refreshStoreRateLimit(storeID uint64, limitType storelimit.Type) {
2454-
// Only v1 uses StoreRateLimit for AddPeer/RemovePeer.
2455-
if c.opt.GetStoreLimitVersion() != storelimit.VersionV1 {
2456-
return
2457-
}
24582454
store := c.GetStore(storeID)
24592455
if store == nil {
24602456
return

server/cluster/cluster_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2905,8 +2905,14 @@ func TestCheckCache(t *testing.T) {
29052905

29062906
// case 2: operator cannot be created due to store limit restriction
29072907
oc.RemoveOperator(oc.GetOperator(1))
2908-
err := tc.SetStoreLimit(1, storelimit.AddPeer, 0)
2908+
err := tc.SetStoreLimit(1, storelimit.AddPeer, 0.0001)
29092909
re.NoError(err)
2910+
// StoreRateLimit treats rate=0 as unlimited. To simulate a throttled store,
2911+
// we set a small positive rate and exhaust the initial tokens.
2912+
store := tc.GetStore(1)
2913+
re.NotNil(store)
2914+
re.True(store.GetStoreLimit().Take(storelimit.RegionInfluence[storelimit.AddPeer], storelimit.AddPeer, constant.Low))
2915+
re.False(store.IsAvailable(storelimit.AddPeer, constant.Low))
29102916
checker.PatrolRegions()
29112917
re.Len(checker.GetPendingProcessedRegions(), 1)
29122918

0 commit comments

Comments
 (0)