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
KAFKA-14683 Migrate WorkerSinkTaskTest to Mockito (3/3) #15316
KAFKA-14683 Migrate WorkerSinkTaskTest to Mockito (3/3) #15316
Conversation
As part of this last batch, please also removed this test from the list here: Line 424 in 5cfcc52
|
…ignment to Mockito
19f27a8
to
99cd3b9
Compare
Final batch of the This one is probably the largest of the 3 (sorry). Tagging @divijvaidya @gharris1727 @C0urante |
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 @hgeraldino, that last test is especially complex. Thank you for your attention to detail here!
|
||
rebalanceListener.getValue().onPartitionsRevoked(INITIAL_ASSIGNMENT); | ||
rebalanceListener.getValue().onPartitionsAssigned(Collections.emptyList()); | ||
return new ConsumerRecords<>(Collections.singletonMap(TOPIC_PARTITION3, Collections.singletonList(newRecord))); |
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.
in the original test:
This confuses me. The earlier 3rd poll assigned topic-partition 3, and iteration 3 paused the newAssignment, including topic-partition 3. Yet in the 5th poll, this record is returned for a partition which should be paused.
The 5th iteration has the put succeed, and then the partitions are unpaused. But this unpause should only allow for new records to appear in the 6th poll, right?
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.
You're right, the test was a bit off mainly because the first call to task.put(..)
shouldn't have thrown an exception.
Here's the sequence now (which matches the original WorkerSinkTaskTest):
- Iteration#1: partitions on INITIAL_ASSIGNMENT are assigned
- Iteration#2:
task.put(...)
throws, partitions are paused - Iteration#3: P3 is assigned,
task.put(...)
throws (task is already paused so it's a noop) - Iteration#4:
task.put(...)
throws, noop - Iteration#5: initial assignment is revoked (pending messages for P1 are removed);
consumer.poll(...)
returns a record for P3, which is successfully processed.
I've added the corresponding verifications after each step. Hope it makes sense now
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/WorkerSinkTaskMockitoTest.java
Show resolved
Hide resolved
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/WorkerSinkTaskMockitoTest.java
Show resolved
Hide resolved
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/WorkerSinkTaskMockitoTest.java
Outdated
Show resolved
Hide resolved
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/WorkerSinkTaskMockitoTest.java
Show resolved
Hide resolved
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/WorkerSinkTaskMockitoTest.java
Outdated
Show resolved
Hide resolved
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/WorkerSinkTaskMockitoTest.java
Outdated
Show resolved
Hide resolved
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/WorkerSinkTaskMockitoTest.java
Outdated
Show resolved
Hide resolved
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/WorkerSinkTaskMockitoTest.java
Outdated
Show resolved
Hide resolved
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/WorkerSinkTaskMockitoTest.java
Outdated
Show resolved
Hide resolved
…/WorkerSinkTaskMockitoTest.java Co-authored-by: Greg Harris <gharris1727@gmail.com>
Thanks @gharris1727 for your review. I think I addressed most of your comments. If anyone has any other suggestions, please let me know. Ideally we should rename this file back to |
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 @hgeraldino for all your hard work!
We can straighten out the build.gradle and move back to the old class name in a follow-up.
Test failures appear unrelated, and the runtime tests pass locally for me. |
Reviewers: Greg Harris <greg.harris@aiven.io>
Reviewers: Greg Harris <greg.harris@aiven.io>
Last batch for migrating WorkerSinkTaskTest tests to Mockito