-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
ddl: refactor and add some unit tests for label rules #27715
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clearly not all ocurrences of GetLabelRules
are refactored.
} | ||
|
||
type mockLabelManager struct { | ||
sync.RWMutex | ||
labelRules map[string]*label.Rule | ||
labelRules map[string][]byte |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need to marshal/unmarshak
, so you want a more real mock API?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we don't marshal/unmarshal
it, we need to do type conversion explicitly.
ddl/attributes_sql_test.go
Outdated
tk.MustExec(`alter table t1 partition p1 attributes="";`) | ||
tk.MustExec(`alter table t1 partition p2 attributes="";`) | ||
tk.MustExec(`alter table t1 partition p3 attributes="";`) | ||
tk.MustExec("drop table if exists t1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
drop table should drop attributes of partitions too, I think. We should not need to add alter table t1 partition p3 attributes=""
, if we added, something is wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is because we need to trigger GC to delete the rules currently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason why I do it is to prevent the influence among cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could also create a new store for every case, infoschema is binded to domain. BTW, I believe you could filter unexisted labels for information_schema.region_label
to clear the result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onTruncateTablePartition
should be refactored, too?
Signed-off-by: Ryan Leung <rleungx@gmail.com>
Signed-off-by: Ryan Leung <rleungx@gmail.com>
Signed-off-by: Ryan Leung <rleungx@gmail.com>
/sig sql-infra |
/merge |
This pull request has been accepted and is ready to merge. Commit hash: e3c5b42
|
/run-check_dev_2 |
@rleungx: Your PR was out of date, I have automatically updated it for you. At the same time I will also trigger all tests for you: /run-all-tests If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
What problem does this PR solve?
Problem Summary: Previously, the region label feature is lack of unit tests. This PR does tiny refactor and adds some basic unit tests for the region label.
What is changed and how it works?
What's Changed:
GetLabelRules
Check List
Tests
Release note