KAFKA-14133: Migrate Consumer mock in TaskManagerTest to Mockito#13873
KAFKA-14133: Migrate Consumer mock in TaskManagerTest to Mockito#13873clolov wants to merge 3 commits intoapache:trunkfrom
Conversation
divijvaidya
left a comment
There was a problem hiding this comment.
I took an initial look but it seems like a lot of verification is missing. Can you please ensure that whenever we remove a easymock stub, we are adding a powermock verification for it?
There was a problem hiding this comment.
why are we checking for atLeastOnce and not the exact times? Isn't this relaxing constrains from what we were doing with easy mock?
(same for verifyResumeWasCalledWith)
There was a problem hiding this comment.
There are a couple of tests where consumer.resume() is called twice. I will amend this to be stricter if possible
There was a problem hiding this comment.
s/verifyResumeWasCalledWith /verifyResumeWasCalledWithAssignment
There was a problem hiding this comment.
This is not called, this is why I removed it
There was a problem hiding this comment.
This is just not called, that's why I removed it originally
There was a problem hiding this comment.
I don't think there is a need for verification here. The consumer was only replayed in EasyMock and the replayed behaviour comes by default in Mockito
This is just not called, that's why I removed it originally
There was a problem hiding this comment.
I actually do not know why these were being verified with EasyMock given that taskXY are not mocks
There was a problem hiding this comment.
I would inline this function since it became an one-liner.
when(consumer.assignment()).thenReturn(singleton(new TopicPartition("assignment", 0)));There was a problem hiding this comment.
Why do you union a single set?
| final Set<TopicPartition> partitions = union(HashSet::new, taskId00Partitions); | |
| when(consumer.assignment()).thenReturn(partitions); | |
| when(consumer.assignment()).thenReturn(taskId00Partitions); |
... and isn't this a duplicate of line 1923 (except the differing partitions).
expectAssignmentToBeCalled(consumer);Could it be that you can remove line 1923?
There was a problem hiding this comment.
Because I couldn't figure out a better way to create a set with only one element and Collections does not have a singletonSet 😞
There was a problem hiding this comment.
Oh, silly me, there is a mkSet method in Utils. Okay, I will remedy this.
Silly me x2, the thing is already a set
There was a problem hiding this comment.
You are correct, it appears I can remove line 1923
There was a problem hiding this comment.
Why do you verify? It was not verified in the original code.
I added a couple of this comments below. However, I am not sure whether the original author did not want to verify the consumer or if they forgot about it. I will leave it to you if you want to keep them or not.
There was a problem hiding this comment.
Why do you verify? It was not verified in the original code.
There was a problem hiding this comment.
Why do you verify? It was not verified in the original code.
There was a problem hiding this comment.
Why do you verify? It was not verified in the original code.
There was a problem hiding this comment.
| Mockito.verifyNoMoreInteractions(consumer); | |
| Mockito.verifyNoInteractions(consumer); |
2a5ccfd to
349a9d0
Compare
|
This PR is being marked as stale since it has not had any activity in 90 days. If you would like to keep this PR alive, please ask a committer for review. If the PR has merge conflicts, please update it with the latest from trunk (or appropriate release branch) If this PR is no longer valid or desired, please feel free to close it. If no activity occurs in the next 30 days, it will be automatically closed. |
|
I will provide an update on this pull request in order to not close it! |
Co-authored-by: Bruno Cadonna <cadonna@apache.org>
910effb to
7c917f0
Compare
|
Yes |
This pull requests migrates the Consumer mock in TaskManagerTest from EasyMock to Mockito.
The change is restricted to a single mock to minimize the scope and make it easier for review.
The reasoning as to why we would like to migrate a single mock rather than all mocks in the file at the same time has been discussed in #12607 (comment)
It takes the same approach as in:
#13529
#13621
#13681
#13711