Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Signed-off-by: TonsnakeLin <[email protected]>
  • Loading branch information
TonsnakeLin authored and ti-chi-bot committed May 15, 2024
1 parent 2aafd3e commit c212bfe
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pkg/schedule/operator/operator_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
22 changes: 11 additions & 11 deletions pkg/schedule/operator/operator_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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))

Expand All @@ -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
Expand All @@ -470,17 +470,17 @@ 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))

controller.opNotifierQueue[0].time = time.Now()
r, next = controller.pollNeedDispatchRegion()
re.True(next)
re.Nil(r)
re.Equal(len(controller.opNotifierQueue), 0)
re.Empty(controller.opNotifierQueue)
}

func (suite *operatorControllerTestSuite) TestStoreLimit() {
Expand Down

0 comments on commit c212bfe

Please sign in to comment.