From c212bfe3ed14768c58b5ec3152cdbeac2d9c1d22 Mon Sep 17 00:00:00 2001 From: TonsnakeLin Date: Mon, 1 Apr 2024 03:03:09 -0400 Subject: [PATCH] update Signed-off-by: TonsnakeLin --- pkg/schedule/operator/operator_controller.go | 2 +- .../operator/operator_controller_test.go | 22 +++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/pkg/schedule/operator/operator_controller.go b/pkg/schedule/operator/operator_controller.go index 23d03a40622..1ec984d8e0e 100644 --- a/pkg/schedule/operator/operator_controller.go +++ b/pkg/schedule/operator/operator_controller.go @@ -459,7 +459,7 @@ func (oc *Controller) checkAddOperator(isPromoting bool, ops ...*Operator) (bool } // checkOperatorLightly checks whether the ops can be dispatched in Controller::pollNeedDispatchRegion. -// The operators can't be dispatched for some scenarios, such as region disapeared, region changed ... +// The operators can't be dispatched for some scenarios, such as region disappeared, region changed ... // `region` is the target region of `op`. func (oc *Controller) checkOperatorLightly(op *Operator) (*core.RegionInfo, CancelReasonType) { region := oc.cluster.GetRegion(op.RegionID()) diff --git a/pkg/schedule/operator/operator_controller_test.go b/pkg/schedule/operator/operator_controller_test.go index 076df8f5a3e..8581715fca3 100644 --- a/pkg/schedule/operator/operator_controller_test.go +++ b/pkg/schedule/operator/operator_controller_test.go @@ -409,10 +409,10 @@ func (suite *operatorControllerTestSuite) TestPollDispatchRegionForMergeRegion() cluster.AddLabelsStore(2, 1, map[string]string{"host": "host2"}) cluster.AddLabelsStore(3, 1, map[string]string{"host": "host3"}) - source := newRegionInfo(101, "1a", "1b", 1, 1, []uint64{101, 1}, []uint64{101, 1}) + source := newRegionInfo(101, "1a", "1b", 10, 10, []uint64{101, 1}, []uint64{101, 1}) source.GetMeta().RegionEpoch = &metapb.RegionEpoch{} cluster.PutRegion(source) - target := newRegionInfo(102, "1b", "1c", 1, 1, []uint64{101, 1}, []uint64{101, 1}) + target := newRegionInfo(102, "1b", "1c", 10, 10, []uint64{101, 1}, []uint64{101, 1}) target.GetMeta().RegionEpoch = &metapb.RegionEpoch{} cluster.PutRegion(target) @@ -439,9 +439,9 @@ func (suite *operatorControllerTestSuite) TestPollDispatchRegionForMergeRegion() r, next = controller.pollNeedDispatchRegion() re.True(next) re.Nil(r) - re.Equal(len(controller.opNotifierQueue), 1) - re.Equal(len(controller.operators), 0) - re.Equal(len(controller.wop.ListOperator()), 0) + re.Len(controller.opNotifierQueue, 1) + re.Empty(controller.operators) + re.Empty(controller.wop.ListOperator()) re.NotNil(controller.records.Get(101)) re.NotNil(controller.records.Get(102)) @@ -450,14 +450,14 @@ func (suite *operatorControllerTestSuite) TestPollDispatchRegionForMergeRegion() r, next = controller.pollNeedDispatchRegion() re.True(next) re.Nil(r) - re.Equal(len(controller.opNotifierQueue), 0) + re.Empty(controller.opNotifierQueue) // Add the two ops to waiting operators again. source.GetMeta().RegionEpoch = &metapb.RegionEpoch{ConfVer: 0, Version: 0} controller.records.ttl.Remove(101) controller.records.ttl.Remove(102) ops, err = CreateMergeRegionOperator("merge-region", cluster, source, target, OpMerge) - re.Nil(err) + re.NoError(err) re.Equal(2, controller.AddWaitingOperator(ops...)) // change the target RegionEpoch // first poll gets source region from opNotifierQueue @@ -470,9 +470,9 @@ func (suite *operatorControllerTestSuite) TestPollDispatchRegionForMergeRegion() r, next = controller.pollNeedDispatchRegion() re.True(next) re.Nil(r) - re.Equal(len(controller.opNotifierQueue), 1) - re.Equal(len(controller.operators), 0) - re.Equal(len(controller.wop.ListOperator()), 0) + re.Len(controller.opNotifierQueue, 1) + re.Empty(controller.operators) + re.Empty(controller.wop.ListOperator()) re.NotNil(controller.records.Get(101)) re.NotNil(controller.records.Get(102)) @@ -480,7 +480,7 @@ func (suite *operatorControllerTestSuite) TestPollDispatchRegionForMergeRegion() r, next = controller.pollNeedDispatchRegion() re.True(next) re.Nil(r) - re.Equal(len(controller.opNotifierQueue), 0) + re.Empty(controller.opNotifierQueue) } func (suite *operatorControllerTestSuite) TestStoreLimit() {