Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests/rule: make TestLargeRules more stable #8038

Closed
wants to merge 1 commit into from

Conversation

HuSharp
Copy link
Member

@HuSharp HuSharp commented Apr 8, 2024

What problem does this PR solve?

Issue Number: Ref #7969

What is changed and how does it work?

tested by #7969
Because below code will add default rule after the previous test finished, we need to skip default rule for large rule test to make it stable

func (suite *ruleTestSuite) TearDownTest() {
re := suite.Require()
cleanFunc := func(cluster *tests.TestCluster) {
def := placement.GroupBundle{
ID: "pd",
Rules: []*placement.Rule{
{GroupID: "pd", ID: "default", Role: "voter", Count: 3},
},
}
data, err := json.Marshal([]placement.GroupBundle{def})
re.NoError(err)
urlPrefix := cluster.GetLeaderServer().GetAddr()
err = tu.CheckPostJSON(testDialClient, urlPrefix+"/pd/api/v1/config/placement-rule", data, tu.StatusOK(re))
re.NoError(err)
}
suite.env.RunFuncInTwoModes(cleanFunc)
}
will

Check List

Tests

  • Unit test
  • Integration test

Release note

None.

Signed-off-by: husharp <jinhao.hu@pingcap.com>
@HuSharp HuSharp requested review from lhy1024 and rleungx April 8, 2024 07:01
Copy link
Contributor

ti-chi-bot bot commented Apr 8, 2024

[REVIEW NOTIFICATION]

This pull request has not been approved.

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Apr 8, 2024
@HuSharp HuSharp changed the title tests/rule: make large rule stable tests/rule: make TestLargeRules more stable Apr 8, 2024
@rleungx
Copy link
Member

rleungx commented Apr 8, 2024

Is there any error stack?

@HuSharp
Copy link
Member Author

HuSharp commented Apr 8, 2024

Is there any error stack?

This condition will never be met, I printed respBundle which has one more default value {GroupID: "pd", ID: "default", Role: "voter", Count: 3} than resp (this default value is added by TearDownTest`)
(

if len(respBundle) != len(bundle) {
return false
}
)

@@ -1261,6 +1261,13 @@ func (suite *ruleTestSuite) postAndCheckRuleBundle(urlPrefix string, bundle []pl
err = tu.CheckGetJSON(testDialClient, urlPrefix+"/config/placement-rule", nil,
tu.StatusOK(re), tu.ExtractJSON(re, &respBundle))
re.NoError(err)
// skip default rule check
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will it affect TestDeleteAndUpdate?

Copy link
Contributor

@nolouch nolouch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will add default rule after the previous test finished

Why does it happen? Does it share the same environment?

@HuSharp
Copy link
Member Author

HuSharp commented Apr 15, 2024

will add default rule after the previous test finished

Why does it happen? Does it share the same environment?

yes, this suite test build env firstly and then using TearDownTest to clean up placement rules

func (suite *ruleTestSuite) SetupSuite() {
suite.env = tests.NewSchedulingTestEnvironment(suite.T(), func(conf *config.Config, _ string) {
conf.PDServerCfg.KeyType = "raw"
conf.Replication.EnablePlacementRules = true
})
}

@HuSharp
Copy link
Member Author

HuSharp commented Apr 15, 2024

/hold

meet other issues need to be fixed

@ti-chi-bot ti-chi-bot bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 15, 2024
@HuSharp
Copy link
Member Author

HuSharp commented Apr 15, 2024

Root cause is

So, we can close this pr now :)

@HuSharp HuSharp closed this Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants