Skip to content

Commit

Permalink
*: remove IsFeatureSupported from Cluster interface (#4527)
Browse files Browse the repository at this point in the history
* remove IsFeatureSupported interface

Signed-off-by: Ryan Leung <rleungx@gmail.com>

* address comments

Signed-off-by: Ryan Leung <rleungx@gmail.com>
  • Loading branch information
rleungx authored Jan 5, 2022
1 parent a901999 commit 0f0326c
Show file tree
Hide file tree
Showing 17 changed files with 75 additions and 101 deletions.
38 changes: 9 additions & 29 deletions pkg/mock/mockcluster/mockcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,24 @@ type Cluster struct {
*labeler.RegionLabeler
*statistics.HotStat
*config.PersistOptions
ID uint64
suspectRegions map[uint64]struct{}
disabledFeatures map[versioninfo.Feature]struct{}
ID uint64
suspectRegions map[uint64]struct{}
}

// NewCluster creates a new Cluster
func NewCluster(ctx context.Context, opts *config.PersistOptions) *Cluster {
clus := &Cluster{
BasicCluster: core.NewBasicCluster(),
IDAllocator: mockid.NewIDAllocator(),
HotStat: statistics.NewHotStat(ctx),
PersistOptions: opts,
suspectRegions: map[uint64]struct{}{},
disabledFeatures: make(map[versioninfo.Feature]struct{}),
BasicCluster: core.NewBasicCluster(),
IDAllocator: mockid.NewIDAllocator(),
HotStat: statistics.NewHotStat(ctx),
PersistOptions: opts,
suspectRegions: map[uint64]struct{}{},
}
if clus.PersistOptions.GetReplicationConfig().EnablePlacementRules {
clus.initRuleManager()
}
// It should be updated to the latest feature version.
clus.PersistOptions.SetClusterVersion(versioninfo.MinSupportedVersion(versioninfo.HotScheduleWithQuery))
clus.RegionLabeler, _ = labeler.NewRegionLabeler(core.NewStorage(kv.NewMemoryKV()))
return clus
}
Expand Down Expand Up @@ -729,26 +729,6 @@ func (mc *Cluster) SetStoreLabel(storeID uint64, labels map[string]string) {
mc.PutStore(newStore)
}

// DisableFeature marks that these features are not supported in the cluster.
func (mc *Cluster) DisableFeature(fs ...versioninfo.Feature) {
for _, f := range fs {
mc.disabledFeatures[f] = struct{}{}
}
}

// EnableFeature marks that these features are supported in the cluster.
func (mc *Cluster) EnableFeature(fs ...versioninfo.Feature) {
for _, f := range fs {
delete(mc.disabledFeatures, f)
}
}

// IsFeatureSupported checks if the feature is supported by current cluster.
func (mc *Cluster) IsFeatureSupported(f versioninfo.Feature) bool {
_, ok := mc.disabledFeatures[f]
return !ok
}

// AddSuspectRegions mock method
func (mc *Cluster) AddSuspectRegions(ids ...uint64) {
for _, id := range ids {
Expand Down
13 changes: 0 additions & 13 deletions server/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1451,19 +1451,6 @@ func (c *RaftCluster) changedRegionNotifier() <-chan *core.RegionInfo {
return c.changedRegions
}

// IsFeatureSupported checks if the feature is supported by current cluster.
func (c *RaftCluster) IsFeatureSupported(f versioninfo.Feature) bool {
clusterVersion := *c.opt.GetClusterVersion()
minSupportVersion := *versioninfo.MinSupportedVersion(f)
// For features before version 5.0 (such as BatchSplit), strict version checks are performed according to the
// original logic. But according to Semantic Versioning, specify a version MAJOR.MINOR.PATCH, PATCH is used when you
// make backwards compatible bug fixes. In version 5.0 and later, we need to strictly comply.
if versioninfo.IsCompatible(minSupportVersion, *versioninfo.MinSupportedVersion(versioninfo.Version4_0)) {
return !clusterVersion.LessThan(minSupportVersion)
}
return versioninfo.IsCompatible(minSupportVersion, clusterVersion)
}

// GetMetaCluster gets meta cluster.
func (c *RaftCluster) GetMetaCluster() *metapb.Cluster {
c.RLock()
Expand Down
4 changes: 2 additions & 2 deletions server/cluster/cluster_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (c *RaftCluster) HandleAskSplit(request *pdpb.AskSplitRequest) (*pdpb.AskSp
}
}

if c.IsFeatureSupported(versioninfo.RegionMerge) {
if versioninfo.IsFeatureSupported(c.GetOpts().GetClusterVersion(), versioninfo.RegionMerge) {
// Disable merge for the 2 regions in a period of time.
c.GetMergeChecker().RecordRegionSplit([]uint64{reqRegion.GetId(), newRegionID})
}
Expand Down Expand Up @@ -129,7 +129,7 @@ func (c *RaftCluster) HandleAskBatchSplit(request *pdpb.AskBatchSplitRequest) (*
}

recordRegions = append(recordRegions, reqRegion.GetId())
if c.IsFeatureSupported(versioninfo.RegionMerge) {
if versioninfo.IsFeatureSupported(c.GetOpts().GetClusterVersion(), versioninfo.RegionMerge) {
// Disable merge the regions in a period of time.
c.GetMergeChecker().RecordRegionSplit(recordRegions)
}
Expand Down
2 changes: 1 addition & 1 deletion server/grpc_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,7 @@ func (s *GrpcServer) AskBatchSplit(ctx context.Context, request *pdpb.AskBatchSp
return &pdpb.AskBatchSplitResponse{Header: s.notBootstrappedHeader()}, nil
}

if !rc.IsFeatureSupported(versioninfo.BatchSplit) {
if !versioninfo.IsFeatureSupported(rc.GetOpts().GetClusterVersion(), versioninfo.BatchSplit) {
return &pdpb.AskBatchSplitResponse{Header: s.incompatibleVersion("batch_split")}, nil
}
if request.GetRegion() == nil {
Expand Down
2 changes: 1 addition & 1 deletion server/schedule/checker/learner_checker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type testLearnerCheckerSuite struct {
func (s *testLearnerCheckerSuite) SetUpTest(c *C) {
s.ctx, s.cancel = context.WithCancel(context.Background())
s.cluster = mockcluster.NewCluster(s.ctx, config.NewTestOptions())
s.cluster.DisableFeature(versioninfo.JointConsensus)
s.cluster.SetClusterVersion(versioninfo.MinSupportedVersion(versioninfo.Version4_0))
s.lc = NewLearnerChecker(s.cluster)
for id := uint64(1); id <= 10; id++ {
s.cluster.PutStoreWithLabels(id)
Expand Down
4 changes: 2 additions & 2 deletions server/schedule/checker/merge_checker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (s *testMergeCheckerSuite) SetUpTest(c *C) {
s.cluster.SetLabelPropertyConfig(config.LabelPropertyConfig{
config.RejectLeader: {{Key: "reject", Value: "leader"}},
})
s.cluster.DisableFeature(versioninfo.JointConsensus)
s.cluster.SetClusterVersion(versioninfo.MinSupportedVersion(versioninfo.Version4_0))
stores := map[uint64][]string{
1: {}, 2: {}, 3: {}, 4: {}, 5: {}, 6: {},
7: {"reject", "leader"},
Expand Down Expand Up @@ -520,7 +520,7 @@ func (s *testMergeCheckerSuite) TestCache(c *C) {
s.cluster.SetMaxMergeRegionSize(2)
s.cluster.SetMaxMergeRegionKeys(2)
s.cluster.SetSplitMergeInterval(time.Hour)
s.cluster.DisableFeature(versioninfo.JointConsensus)
s.cluster.SetClusterVersion(versioninfo.MinSupportedVersion(versioninfo.Version4_0))
stores := map[uint64][]string{
1: {}, 2: {}, 3: {}, 4: {}, 5: {}, 6: {},
}
Expand Down
20 changes: 10 additions & 10 deletions server/schedule/checker/replica_checker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (s *testReplicaCheckerSuite) TearDownTest(c *C) {
func (s *testReplicaCheckerSuite) SetUpTest(c *C) {
cfg := config.NewTestOptions()
s.cluster = mockcluster.NewCluster(s.ctx, cfg)
s.cluster.DisableFeature(versioninfo.JointConsensus)
s.cluster.SetClusterVersion(versioninfo.MinSupportedVersion(versioninfo.Version4_0))
s.rc = NewReplicaChecker(s.cluster, cache.NewDefaultCache(10))
stats := &pdpb.StoreStats{
Capacity: 100,
Expand Down Expand Up @@ -209,7 +209,7 @@ func (s *testReplicaCheckerSuite) TestBasic(c *C) {
opt := config.NewTestOptions()
tc := mockcluster.NewCluster(s.ctx, opt)
tc.SetMaxSnapshotCount(2)
tc.DisableFeature(versioninfo.JointConsensus)
tc.SetClusterVersion(versioninfo.MinSupportedVersion(versioninfo.Version4_0))
rc := NewReplicaChecker(tc, cache.NewDefaultCache(10))

// Add stores 1,2,3,4.
Expand Down Expand Up @@ -282,7 +282,7 @@ func (s *testReplicaCheckerSuite) TestLostStore(c *C) {
opt := config.NewTestOptions()
tc := mockcluster.NewCluster(s.ctx, opt)

tc.DisableFeature(versioninfo.JointConsensus)
tc.SetClusterVersion(versioninfo.MinSupportedVersion(versioninfo.Version4_0))
tc.AddRegionStore(1, 1)
tc.AddRegionStore(2, 1)

Expand All @@ -300,7 +300,7 @@ func (s *testReplicaCheckerSuite) TestLostStore(c *C) {
func (s *testReplicaCheckerSuite) TestOffline(c *C) {
opt := config.NewTestOptions()
tc := mockcluster.NewCluster(s.ctx, opt)
tc.DisableFeature(versioninfo.JointConsensus)
tc.SetClusterVersion(versioninfo.MinSupportedVersion(versioninfo.Version4_0))
tc.SetMaxReplicas(3)
tc.SetLocationLabels([]string{"zone", "rack", "host"})

Expand Down Expand Up @@ -352,7 +352,7 @@ func (s *testReplicaCheckerSuite) TestOffline(c *C) {
func (s *testReplicaCheckerSuite) TestDistinctScore(c *C) {
opt := config.NewTestOptions()
tc := mockcluster.NewCluster(s.ctx, opt)
tc.DisableFeature(versioninfo.JointConsensus)
tc.SetClusterVersion(versioninfo.MinSupportedVersion(versioninfo.Version4_0))
tc.SetMaxReplicas(3)
tc.SetLocationLabels([]string{"zone", "rack", "host"})

Expand Down Expand Up @@ -431,7 +431,7 @@ func (s *testReplicaCheckerSuite) TestDistinctScore(c *C) {
func (s *testReplicaCheckerSuite) TestDistinctScore2(c *C) {
opt := config.NewTestOptions()
tc := mockcluster.NewCluster(s.ctx, opt)
tc.DisableFeature(versioninfo.JointConsensus)
tc.SetClusterVersion(versioninfo.MinSupportedVersion(versioninfo.Version4_0))
tc.SetMaxReplicas(5)
tc.SetLocationLabels([]string{"zone", "host"})

Expand Down Expand Up @@ -462,7 +462,7 @@ func (s *testReplicaCheckerSuite) TestStorageThreshold(c *C) {
opt := config.NewTestOptions()
tc := mockcluster.NewCluster(s.ctx, opt)
tc.SetLocationLabels([]string{"zone"})
tc.DisableFeature(versioninfo.JointConsensus)
tc.SetClusterVersion(versioninfo.MinSupportedVersion(versioninfo.Version4_0))
rc := NewReplicaChecker(tc, cache.NewDefaultCache(10))

tc.AddLabelsStore(1, 1, map[string]string{"zone": "z1"})
Expand Down Expand Up @@ -497,7 +497,7 @@ func (s *testReplicaCheckerSuite) TestStorageThreshold(c *C) {
func (s *testReplicaCheckerSuite) TestOpts(c *C) {
opt := config.NewTestOptions()
tc := mockcluster.NewCluster(s.ctx, opt)
tc.DisableFeature(versioninfo.JointConsensus)
tc.SetClusterVersion(versioninfo.MinSupportedVersion(versioninfo.Version4_0))
rc := NewReplicaChecker(tc, cache.NewDefaultCache(10))

tc.AddRegionStore(1, 100)
Expand Down Expand Up @@ -528,7 +528,7 @@ func (s *testReplicaCheckerSuite) TestOpts(c *C) {
func (s *testReplicaCheckerSuite) TestFixDownPeer(c *C) {
opt := config.NewTestOptions()
tc := mockcluster.NewCluster(s.ctx, opt)
tc.DisableFeature(versioninfo.JointConsensus)
tc.SetClusterVersion(versioninfo.MinSupportedVersion(versioninfo.Version4_0))
tc.SetLocationLabels([]string{"zone"})
rc := NewReplicaChecker(tc, cache.NewDefaultCache(10))

Expand Down Expand Up @@ -559,7 +559,7 @@ func (s *testReplicaCheckerSuite) TestFixDownPeer(c *C) {
func (s *testReplicaCheckerSuite) TestFixOfflinePeer(c *C) {
opt := config.NewTestOptions()
tc := mockcluster.NewCluster(s.ctx, opt)
tc.DisableFeature(versioninfo.JointConsensus)
tc.SetClusterVersion(versioninfo.MinSupportedVersion(versioninfo.Version4_0))
tc.SetLocationLabels([]string{"zone"})
rc := NewReplicaChecker(tc, cache.NewDefaultCache(10))

Expand Down
4 changes: 2 additions & 2 deletions server/schedule/checker/rule_checker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (s *testRuleCheckerSerialSuite) SetUpTest(c *C) {
cfg := config.NewTestOptions()
cfg.SetPlacementRulesCacheEnabled(true)
s.cluster = mockcluster.NewCluster(s.ctx, cfg)
s.cluster.DisableFeature(versioninfo.JointConsensus)
s.cluster.SetClusterVersion(versioninfo.MinSupportedVersion(versioninfo.Version4_0))
s.cluster.SetEnablePlacementRules(true)
s.ruleManager = s.cluster.RuleManager
s.rc = NewRuleChecker(s.cluster, s.ruleManager, cache.NewDefaultCache(10))
Expand All @@ -79,7 +79,7 @@ func (s *testRuleCheckerSuite) TearDownTest(c *C) {
func (s *testRuleCheckerSuite) SetUpTest(c *C) {
cfg := config.NewTestOptions()
s.cluster = mockcluster.NewCluster(s.ctx, cfg)
s.cluster.DisableFeature(versioninfo.JointConsensus)
s.cluster.SetClusterVersion(versioninfo.MinSupportedVersion(versioninfo.Version4_0))
s.cluster.SetEnablePlacementRules(true)
s.ruleManager = s.cluster.RuleManager
s.rc = NewRuleChecker(s.cluster, s.ruleManager, cache.NewDefaultCache(10))
Expand Down
2 changes: 1 addition & 1 deletion server/schedule/operator/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func NewBuilder(desc string, cluster opt.Cluster, region *core.RegionInfo, opts
}

// build flags
supportJointConsensus := cluster.IsFeatureSupported(versioninfo.JointConsensus)
supportJointConsensus := versioninfo.IsFeatureSupported(cluster.GetOpts().GetClusterVersion(), versioninfo.JointConsensus)

b.rules = rules
b.originPeers = originPeers
Expand Down
2 changes: 1 addition & 1 deletion server/schedule/operator/create_operator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1039,7 +1039,7 @@ func (s *testCreateOperatorSuite) TestMoveRegionWithoutJointConsensus(c *C) {
},
}

s.cluster.DisableFeature(versioninfo.JointConsensus)
s.cluster.SetClusterVersion(versioninfo.MinSupportedVersion(versioninfo.Version4_0))
for _, tc := range tt {
c.Log(tc.name)
region := core.NewRegionInfo(&metapb.Region{Id: 10, Peers: tc.originPeers}, tc.originPeers[0])
Expand Down
2 changes: 0 additions & 2 deletions server/schedule/opt/opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"github.com/tikv/pd/server/core"
"github.com/tikv/pd/server/schedule/placement"
"github.com/tikv/pd/server/statistics"
"github.com/tikv/pd/server/versioninfo"
)

// Cluster provides an overview of a cluster's regions distribution.
Expand All @@ -36,7 +35,6 @@ type Cluster interface {
AllocID() (uint64, error)
GetRuleManager() *placement.RuleManager
RemoveScheduler(name string) error
IsFeatureSupported(f versioninfo.Feature) bool
AddSuspectRegions(ids ...uint64)
GetBasicCluster() *core.BasicCluster
}
4 changes: 2 additions & 2 deletions server/schedule/region_scatterer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (s *testScatterRegionSuite) scatter(c *C, numStores, numRegions uint64, use
defer cancel()
opt := config.NewTestOptions()
tc := mockcluster.NewCluster(ctx, opt)
tc.DisableFeature(versioninfo.JointConsensus)
tc.SetClusterVersion(versioninfo.MinSupportedVersion(versioninfo.Version4_0))

// Add ordinary stores.
for i := uint64(1); i <= numStores; i++ {
Expand Down Expand Up @@ -159,7 +159,7 @@ func (s *testScatterRegionSuite) scatterSpecial(c *C, numOrdinaryStores, numSpec
defer cancel()
opt := config.NewTestOptions()
tc := mockcluster.NewCluster(ctx, opt)
tc.DisableFeature(versioninfo.JointConsensus)
tc.SetClusterVersion(versioninfo.MinSupportedVersion(versioninfo.Version4_0))

// Add ordinary stores.
for i := uint64(1); i <= numOrdinaryStores; i++ {
Expand Down
22 changes: 11 additions & 11 deletions server/schedulers/balance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ func (s *testBalanceRegionSchedulerSuite) TestBalance(c *C) {
// TODO: enable placementrules
opt.SetPlacementRuleEnabled(false)
tc := mockcluster.NewCluster(s.ctx, opt)
tc.DisableFeature(versioninfo.JointConsensus)
tc.SetClusterVersion(versioninfo.MinSupportedVersion(versioninfo.Version4_0))
oc := schedule.NewOperatorController(s.ctx, nil, nil)

sb, err := schedule.CreateScheduler(BalanceRegionType, oc, core.NewStorage(kv.NewMemoryKV()), schedule.ConfigSliceDecoder(BalanceRegionType, []string{"", ""}))
Expand Down Expand Up @@ -640,7 +640,7 @@ func (s *testBalanceRegionSchedulerSuite) TestReplicas3(c *C) {
tc := mockcluster.NewCluster(s.ctx, opt)
tc.SetMaxReplicas(3)
tc.SetLocationLabels([]string{"zone", "rack", "host"})
tc.DisableFeature(versioninfo.JointConsensus)
tc.SetClusterVersion(versioninfo.MinSupportedVersion(versioninfo.Version4_0))
oc := schedule.NewOperatorController(s.ctx, nil, nil)

sb, err := schedule.CreateScheduler(BalanceRegionType, oc, core.NewStorage(kv.NewMemoryKV()), schedule.ConfigSliceDecoder(BalanceRegionType, []string{"", ""}))
Expand Down Expand Up @@ -705,7 +705,7 @@ func (s *testBalanceRegionSchedulerSuite) TestReplicas5(c *C) {
tc.SetMaxReplicas(5)
tc.SetLocationLabels([]string{"zone", "rack", "host"})

tc.DisableFeature(versioninfo.JointConsensus)
tc.SetClusterVersion(versioninfo.MinSupportedVersion(versioninfo.Version4_0))
oc := schedule.NewOperatorController(s.ctx, nil, nil)

sb, err := schedule.CreateScheduler(BalanceRegionType, oc, core.NewStorage(kv.NewMemoryKV()), schedule.ConfigSliceDecoder(BalanceRegionType, []string{"", ""}))
Expand Down Expand Up @@ -766,7 +766,7 @@ func (s *testBalanceRegionSchedulerSuite) TestBalance1(c *C) {
opt := config.NewTestOptions()
opt.SetPlacementRuleEnabled(false)
tc := mockcluster.NewCluster(s.ctx, opt)
tc.DisableFeature(versioninfo.JointConsensus)
tc.SetClusterVersion(versioninfo.MinSupportedVersion(versioninfo.Version4_0))
tc.SetTolerantSizeRatio(1)
tc.SetRegionScheduleLimit(1)
tc.SetRegionScoreFormulaVersion("v1")
Expand Down Expand Up @@ -845,7 +845,7 @@ func (s *testBalanceRegionSchedulerSuite) TestStoreWeight(c *C) {
tc := mockcluster.NewCluster(s.ctx, opt)
// TODO: enable placementrules
tc.SetPlacementRuleEnabled(false)
tc.DisableFeature(versioninfo.JointConsensus)
tc.SetClusterVersion(versioninfo.MinSupportedVersion(versioninfo.Version4_0))
oc := schedule.NewOperatorController(s.ctx, nil, nil)

sb, err := schedule.CreateScheduler(BalanceRegionType, oc, core.NewStorage(kv.NewMemoryKV()), schedule.ConfigSliceDecoder(BalanceRegionType, []string{"", ""}))
Expand Down Expand Up @@ -873,7 +873,7 @@ func (s *testBalanceRegionSchedulerSuite) TestReplacePendingRegion(c *C) {
tc := mockcluster.NewCluster(s.ctx, opt)
tc.SetMaxReplicas(3)
tc.SetLocationLabels([]string{"zone", "rack", "host"})
tc.DisableFeature(versioninfo.JointConsensus)
tc.SetClusterVersion(versioninfo.MinSupportedVersion(versioninfo.Version4_0))
oc := schedule.NewOperatorController(s.ctx, nil, nil)

sb, err := schedule.CreateScheduler(BalanceRegionType, oc, core.NewStorage(kv.NewMemoryKV()), schedule.ConfigSliceDecoder(BalanceRegionType, []string{"", ""}))
Expand All @@ -889,7 +889,7 @@ func (s *testBalanceRegionSchedulerSuite) TestOpInfluence(c *C) {
tc := mockcluster.NewCluster(s.ctx, opt)
// TODO: enable placementrules
tc.SetEnablePlacementRules(false)
tc.DisableFeature(versioninfo.JointConsensus)
tc.SetClusterVersion(versioninfo.MinSupportedVersion(versioninfo.Version4_0))
stream := hbstream.NewTestHeartbeatStreams(s.ctx, tc.ID, tc, false /* no need to run */)
oc := schedule.NewOperatorController(s.ctx, tc, stream)
sb, err := schedule.CreateScheduler(BalanceRegionType, oc, core.NewStorage(kv.NewMemoryKV()), schedule.ConfigSliceDecoder(BalanceRegionType, []string{"", ""}))
Expand Down Expand Up @@ -938,7 +938,7 @@ func (s *testBalanceRegionSchedulerSuite) checkReplacePendingRegion(c *C, tc *mo
func (s *testBalanceRegionSchedulerSuite) TestShouldNotBalance(c *C) {
opt := config.NewTestOptions()
tc := mockcluster.NewCluster(s.ctx, opt)
tc.DisableFeature(versioninfo.JointConsensus)
tc.SetClusterVersion(versioninfo.MinSupportedVersion(versioninfo.Version4_0))
oc := schedule.NewOperatorController(s.ctx, nil, nil)
sb, err := schedule.CreateScheduler(BalanceRegionType, oc, core.NewStorage(kv.NewMemoryKV()), schedule.ConfigSliceDecoder(BalanceRegionType, []string{"", ""}))
c.Assert(err, IsNil)
Expand All @@ -955,7 +955,7 @@ func (s *testBalanceRegionSchedulerSuite) TestShouldNotBalance(c *C) {
func (s *testBalanceRegionSchedulerSuite) TestEmptyRegion(c *C) {
opt := config.NewTestOptions()
tc := mockcluster.NewCluster(s.ctx, opt)
tc.DisableFeature(versioninfo.JointConsensus)
tc.SetClusterVersion(versioninfo.MinSupportedVersion(versioninfo.Version4_0))
oc := schedule.NewOperatorController(s.ctx, nil, nil)
sb, err := schedule.CreateScheduler(BalanceRegionType, oc, core.NewStorage(kv.NewMemoryKV()), schedule.ConfigSliceDecoder(BalanceRegionType, []string{"", ""}))
c.Assert(err, IsNil)
Expand Down Expand Up @@ -1058,7 +1058,7 @@ func (s *testScatterRangeSuite) TestBalance(c *C) {
// TODO: enable palcementrules
opt.SetPlacementRuleEnabled(false)
tc := mockcluster.NewCluster(s.ctx, opt)
tc.DisableFeature(versioninfo.JointConsensus)
tc.SetClusterVersion(versioninfo.MinSupportedVersion(versioninfo.Version4_0))
// range cluster use a special tolerant ratio, cluster opt take no impact
tc.SetTolerantSizeRatio(10000)
// Add stores 1,2,3,4,5.
Expand Down Expand Up @@ -1122,7 +1122,7 @@ func (s *testScatterRangeSuite) TestBalanceLeaderLimit(c *C) {
opt := config.NewTestOptions()
opt.SetPlacementRuleEnabled(false)
tc := mockcluster.NewCluster(s.ctx, opt)
tc.DisableFeature(versioninfo.JointConsensus)
tc.SetClusterVersion(versioninfo.MinSupportedVersion(versioninfo.Version4_0))
tc.SetTolerantSizeRatio(2.5)
// Add stores 1,2,3,4,5.
tc.AddRegionStore(1, 0)
Expand Down
Loading

0 comments on commit 0f0326c

Please sign in to comment.