-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
storage: Split storage.Stores
#9014
Comments
Would it be sufficient to relocate these methods to helpers_test.go? On Thu, Sep 1, 2016 at 2:12 AM, Ben Darnell [email protected]
|
No; many tests rely on the fact that I'm also not sure whether all the tests that rely on this are confined to the |
I'm not sure I understand.
Moving
If this is the case then indeed the only solution will be to have a test-only type that lives in a package which we validate is not imported into prod code. |
It sounds to me like you've summed up the situation pretty well; what part do you not understand? We can't move LookupReplica to a test file as long as it's used in Send. We can't remove the call from Send because many tests will start failing. |
My suggestion was to move these functions to a test file as a way of getting the compiler to help guide correcting the problem. In case those functions are called directly from test code, this approach will require less work than extracting a new type. |
And I was surprised again in #16893 to re-learn that it was still going through this code path. That PR prevents the split snapshot race tests from using this code path, but many other tests in package storage still do. |
Thanks to the previous commit, Stores.LookupReplica is now unused save for a few tests that can be trivially rewritten to call LookupReplica on the one store within. Rewrite those tests and remove it. We get to remove Stores.FirstRange, too, since its only caller was the test for stores.LookupReplica. Fix cockroachdb#9014. Release note: None
Thanks to the previous commit, Stores.LookupReplica is now unused save for a few tests that can be trivially rewritten to call LookupReplica on the one store within. Rewrite those tests and remove it. We get to remove Stores.FirstRange, too, since its only caller was the test for stores.LookupReplica. Fix cockroachdb#9014. Release note: None
Fixed by #25061! |
storage.Stores
contains several methods which are only intended for use in tests (LookupReplica
,FirstRange
,RangeLookup
). However, not all tests need them (ones that use aDistSender
generally shouldn't, although I was surprised to learn in #8868 that the split snapshot race tests hit this code path), and becauseStores.Send
"helpfully" callsLookupReplica
ifRangeID
is zero, we could call these methods in production too.These methods should be removed from
Stores
and placed on a wrapper object that can be used explicitly by tests that need it, so we can ensure that tests that shouldn't use it don't end up accidentally relying on this behavior.The text was updated successfully, but these errors were encountered: