[fix][test] Replace PulsarService Mockito spy solution for overriding getters in tests#19323
Merged
lhotari merged 1 commit intoJan 25, 2023
Merged
Conversation
Member
Author
|
/pulsarbot rerun-failure-checks |
dafd673 to
7e86291
Compare
eolivelli
approved these changes
Jan 25, 2023
eolivelli
left a comment
Contributor
There was a problem hiding this comment.
This is very good.
And I agree that we were (still are?) using too much Mockito.spy() with all the problems that we know about it
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #13620
Fixes #16444
Fixes #16427
Motivation
Mockito is not thread safe and there's a problem with mocking PulsarService which is described in #16821 description:
Unfortunately, the solution made in PR #16821 didn't fix the problem. A better solution is needed to fix the problem.
Modifications
Replace the Mockito spy based PulsarService used in a few unit tests with a subclass of PulsarService which reduces the use of Mockito. Mockito spies can be continued to be used, but the getters are replaced with overridden methods in a new class TestPulsarService which extends PulsarService.
The test code is also simplified by moving the required collaborator objects and resources to the TestPulsarService.Factory class which contains a
close()method to close and release the allocated resources.Documentation
docdoc-requireddoc-not-neededdoc-complete