Skip to content

Commit

Permalink
pause all check
Browse files Browse the repository at this point in the history
Signed-off-by: husharp <[email protected]>
  • Loading branch information
HuSharp committed May 11, 2024
1 parent 204dcbb commit 86e3033
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
10 changes: 5 additions & 5 deletions tests/server/api/operator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (suite *operatorTestSuite) TestAddRemovePeer() {

func (suite *operatorTestSuite) checkAddRemovePeer(cluster *tests.TestCluster) {
re := suite.Require()
pauseRuleChecker(re, cluster)
pauseAllCheckers(re, cluster)
stores := []*metapb.Store{
{
Id: 1,
Expand Down Expand Up @@ -205,7 +205,7 @@ func (suite *operatorTestSuite) checkMergeRegionOperator(cluster *tests.TestClus
tests.MustPutStore(re, cluster, store)
}

pauseRuleChecker(re, cluster)
pauseAllCheckers(re, cluster)
r1 := core.NewTestRegionInfo(10, 1, []byte(""), []byte("b"), core.SetWrittenBytes(1000), core.SetReadBytes(1000), core.SetRegionConfVer(1), core.SetRegionVersion(1))
tests.MustPutRegionInfo(re, cluster, r1)
r2 := core.NewTestRegionInfo(20, 1, []byte("b"), []byte("c"), core.SetWrittenBytes(2000), core.SetReadBytes(0), core.SetRegionConfVer(2), core.SetRegionVersion(3))
Expand Down Expand Up @@ -241,7 +241,7 @@ func (suite *operatorTestSuite) TestTransferRegionWithPlacementRule() {

func (suite *operatorTestSuite) checkTransferRegionWithPlacementRule(cluster *tests.TestCluster) {
re := suite.Require()
pauseRuleChecker(re, cluster)
pauseAllCheckers(re, cluster)
stores := []*metapb.Store{
{
Id: 1,
Expand Down Expand Up @@ -521,7 +521,7 @@ func (suite *operatorTestSuite) TestGetOperatorsAsObject() {

func (suite *operatorTestSuite) checkGetOperatorsAsObject(cluster *tests.TestCluster) {
re := suite.Require()
pauseRuleChecker(re, cluster)
pauseAllCheckers(re, cluster)
stores := []*metapb.Store{
{
Id: 1,
Expand Down Expand Up @@ -642,7 +642,7 @@ func (suite *operatorTestSuite) checkRemoveOperators(cluster *tests.TestCluster)
tests.MustPutStore(re, cluster, store)
}

pauseRuleChecker(re, cluster)
pauseAllCheckers(re, cluster)
r1 := core.NewTestRegionInfo(10, 1, []byte(""), []byte("b"), core.SetWrittenBytes(1000), core.SetReadBytes(1000), core.SetRegionConfVer(1), core.SetRegionVersion(1))
tests.MustPutRegionInfo(re, cluster, r1)
r2 := core.NewTestRegionInfo(20, 1, []byte("b"), []byte("c"), core.SetWrittenBytes(2000), core.SetReadBytes(0), core.SetRegionConfVer(2), core.SetRegionVersion(3))
Expand Down
23 changes: 12 additions & 11 deletions tests/server/api/region_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func (suite *regionTestSuite) TestCheckRegionsReplicated() {

func (suite *regionTestSuite) checkRegionsReplicated(cluster *tests.TestCluster) {
re := suite.Require()
pauseRuleChecker(re, cluster)
pauseAllCheckers(re, cluster)
leader := cluster.GetLeaderServer()
urlPrefix := leader.GetAddr() + "/pd/api/v1"

Expand Down Expand Up @@ -416,15 +416,16 @@ func checkRegionCount(re *require.Assertions, cluster *tests.TestCluster, count
}
}

// pauseRuleChecker will pause rule checker to avoid unexpected operator.
func pauseRuleChecker(re *require.Assertions, cluster *tests.TestCluster) {
checkerName := "rule"
func pauseAllCheckers(re *require.Assertions, cluster *tests.TestCluster) {
checkerNames := []string{"learner", "replica", "rule", "split", "merge", "joint-state"}
addr := cluster.GetLeaderServer().GetAddr()
resp := make(map[string]any)
url := fmt.Sprintf("%s/pd/api/v1/checker/%s", addr, checkerName)
err := tu.CheckPostJSON(testDialClient, url, []byte(`{"delay":1000}`), tu.StatusOK(re))
re.NoError(err)
err = tu.ReadGetJSON(re, testDialClient, url, &resp)
re.NoError(err)
re.True(resp["paused"].(bool))
for _, checkerName := range checkerNames {
resp := make(map[string]any)
url := fmt.Sprintf("%s/pd/api/v1/checker/%s", addr, checkerName)
err := tu.CheckPostJSON(testDialClient, url, []byte(`{"delay":1000}`), tu.StatusOK(re))
re.NoError(err)
err = tu.ReadGetJSON(re, testDialClient, url, &resp)
re.NoError(err)
re.True(resp["paused"].(bool))
}
}

0 comments on commit 86e3033

Please sign in to comment.