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
only create sqlSegmentsMetadataManager
once to speed up test
#15557
Conversation
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 change doesn't really seem to be needed. It just seems to be making everything static to avoid creation of a few objects. In and of itself, the change here is fairly simple and is okay to be be merged but in my opinion, it sets a bad precedent. A similar PR #15533 has been recently merged.
These are my primary concerns:
- Making everything static just to save on some object creation in tests doesn't seem like much of an approach. We should have a better reason of why a field should be static or not.
- We do want the target object (
sqlSegmentsMetadataManager
) to be freshly created in each test and thus be non-static. The other objectjsonMapper
is already being initialized just once. If and when more tests are added to this class, these fields would have to be reverted to non-static anyway. - The improvement of 2.9s to 2.3s in a single test doesn't justify this PR.
- Test improvements should not come at the cost of readability.
- The user @TestBoost has been recently created and looks suspiciously like a bot. 🙂
@TestBoost , please share some more information here. If you have other similar changes, it would be preferable to create a single PR containing such improvements.
Hi, To clarify, this is not a bot account. We recently developed a new tool for transforming test classes to speed up testing by reducing the number of times test fixtures (setup and teardown methods) are run, by essentially making them run at the class level instead of at the method level (between every test method). Using our tool, we were able to transform other test classes within this project, including the one from #15533, but we had the mindset of sending pull requests for a few at a time as to not overwhelm. If you would prefer that we send many or all at once, we can try that. If you have any feedback on this approach or what we could do better, we would be happy to change things accordingly. |
Thanks for the response, @TestBoost .
|
Thank you very much for pointing out! We don't find any other tests like this in server module and other modules in druid as of now. But there are other test classes that require splitting tests that utilize the same variables/resources into different test classes to make tests faster. I don't know if it's suitable. And I also applied the changes as you said in this pull request. |
@TestBoost , taking another look at this test class, I realize that it might not be needed at all. I have created #16044 to merge this test into the bigger one instead. |
Thank you so much for letting me know!!! I can close this pull request now. |
Description
This pull request tries to only create
sqlSegmentsMetadataManager
once to speed up the tests in the test classSqlSegmentsMetadataManagerEmptyTest
.There are two tests in the test class
SqlSegmentsMetadataManagerEmptyTest
. The first testtestPollEmpty
tries to assert the contents of the segments in thesqlSegmentsMetadataManager
are empty. The second testtestStopAndStart
tries to start and stop thesqlSegmentsMetadataManager
. The second test does not modify the contents of segments in thesqlSegmentsMetadataManager
and does not affect the assertions in the first test. We can run all the tests just on a singlesqlSegmentsMetadataManager
to speed up the tests in the test classSqlSegmentsMetadataManagerEmptyTest
. The runtime can decrease from2.997 s
to2.285 s
after applying the changes when run on our own machine.Release note
Key changed/added classes in this PR
SqlSegmentsMetadataManagerEmptyTest
is changed in this PR.This PR has: