-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[Feature]: Sort results of getTablets for consistency in output/readability #17771
Conversation
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
Woops, looks like my commit signing was off. Will fix. |
Signed-off-by: Lucas Morduchowicz <lmorduch@gmail.com>
b6cea9e
to
fd13c20
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #17771 +/- ##
==========================================
- Coverage 67.95% 67.95% -0.01%
==========================================
Files 1585 1585
Lines 255162 255160 -2
==========================================
- Hits 173408 173390 -18
- Misses 81754 81770 +16 ☔ View full report in Codecov by Sentry. |
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.
LGTM. Thanks, @lmorduch ! I thought that we had already done this but it appears that the reality was that I was always thinking we should do this (whenever I noticed output changes in successive GetTablets
commands) but I never actually did. 🙂
Do you mind doing one more thing? I think that we should get rid of the AssertSameTablets()
function and use utils.MustMatch()
instead in the other call sites as well.
❯ git grep AssertSameTablets | cat
go/vt/vtctl/grpcvtctldserver/server_test.go: testutil.AssertSameTablets(t, tt.expectedRemainingTablets, resp.Tablets)
go/vt/vtctl/grpcvtctldserver/server_test.go: testutil.AssertSameTablets(t, tt.expected, resp.Tablets)
go/vt/vtctl/grpcvtctldserver/server_test.go: testutil.AssertSameTablets(t, tt.expectedTopo, resp.Tablets)
go/vt/vtctl/grpcvtctldserver/testutil/proto_compare.go:func AssertSameTablets(t *testing.T, expected, actual []*topodatapb.Tablet) {
…ed for getTablets now Signed-off-by: Lucas Morduchowicz <lmorduch@gmail.com>
Thanks a ton for the review and the feedback! My bad re the test function, I should have checked the other calls to assertSameTablets- they all are checking results from getTablets. Updated to remove the helper function and just call
Full output below.
|
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.
Thanks again, @lmorduch ! Nice work on this
Thanks for the help and feedback! Really appreciate the assistance. |
Description
This sorts the results of GetTablets (which for my current use case, will sort the output of ListShardTablets) and allow it to be consistently grokkable due to it's deterministic ordering.
To test this change, I first modified the
TestGetTablets
unit test under server_test.go from callingtestutil.AssertSameTablets(t, tt.expected, resp.Tablets)
, which first sorts the expected and actual, toutils.MustMatch(t, tt.expected, resp.Tablets)
, the call made under the hood after sorting inAssertSameTablets
. I got the following runninggo test
with just that test change:After implementing the actual code changes in
server.go
, I get:Related Issue(s)
This is the related issue: #17744
Checklist
Deployment Notes
I don't believe this has any special properties with regards to deployments