-
Notifications
You must be signed in to change notification settings - Fork 14.4k
KAFKA-19268 Missing mocks for SharePartitionManagerTest tests #19786
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
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.
Thanks for the PR. Overall looks fine. A few comments.
For testReleaseSessionCompletesDelayedShareFetchRequest
-> you can just mock behaviour for releaseAcquiredRecords
for tp3. Example - when(sp3.releaseAcquiredRecords(ArgumentMatchers.eq(memberId))).thenReturn(CompletableFuture.completedFuture(null));
that should be enough
For testReleaseSessionSuccess
, I agree that getting the exception is intentional. So, we don't need a change there
core/src/test/java/kafka/server/share/SharePartitionManagerTest.java
Outdated
Show resolved
Hide resolved
core/src/test/java/kafka/server/share/SharePartitionManagerTest.java
Outdated
Show resolved
Hide resolved
core/src/test/java/kafka/server/share/SharePartitionManagerTest.java
Outdated
Show resolved
Hide resolved
Thank you for kind code review. I resolved all you mentioned. Also, I want you to see if testMultipleConcurrentShareFetches works as it is intended. I don't think doAnswer chaning (line 1072 ~ 1101 in sharePartitionManagerTest.java) works well in multi threading test. |
@ji-seung-ryu Thanks for the changes. As I mentioned in this comment, we also need to change |
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.
A small comment
core/src/test/java/kafka/server/share/SharePartitionManagerTest.java
Outdated
Show resolved
Hide resolved
@ji-seung-ryu , hmm, I think you're right. I have created a ticket https://issues.apache.org/jira/browse/KAFKA-19328 for tracking the same. |
@adixitconfluent Simply adding that kinds of line is not sufficient. Since tp3 is not in sharePartitionManager.partitionCache, but returned in cachedTopicIdPartitionsInShareSession. Currently, In Following codes of SharePartitionManager.java, exceptions occurs.
There are two options we can choose.
I guess 2 is the better choice, since I see this is intentional like testReleaseSessionSuccess. |
@ji-seung-ryu , the point of this test is to test that delayed share fetch requests are completed for the given watch keys when release session API is called for any group member. So, considering that, I think you should add tp3 to partition cache map and then mock |
I got your point. I will add it. |
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 for the changes. One minor nit comment
core/src/test/java/kafka/server/share/SharePartitionManagerTest.java
Outdated
Show resolved
Hide resolved
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 for the changes.
@AndrewJSchofield can you please review this PR as well? |
jira:
https://issues.apache.org/jira/browse/KAFKA-19268
In jira, there are 5 unit
tests(testAcknowledgeCompletesDelayedShareFetchRequest,
testMultipleConcurrentShareFetches
testCachedTopicPartitionsForValidShareSessions,
testReleaseSessionCompletesDelayedShareFetchRequest,
testReleaseSessionSuccess) that print exceptions.
testAcknowledgeCompletesDelayedShareFetchRequest
[problem]
acknowleged, otherwise error occurs.
[solution]
testMultipleConcurrentShareFetches
[problem]
maybeSliceFetchRecords.
at
org.apache.kafka.common.utils.AbstractIterator.next(AbstractIterator.java:52)
~[kafka-clients-4.1.0-SNAPSHOT.jar:?]
at
kafka.server.share.ShareFetchUtils.maybeSliceFetchRecords(ShareFetchUtils.java:219)
[main/:?]
at
kafka.server.share.ShareFetchUtils.processFetchResponse(ShareFetchUtils.java:132)
[main/:?]
[solution]
doAnswer chaning (line 1075 ~ 1105) works well in multi threading test.
Even though I changed values of assertEquals in doAnswer chaining to
random value, test passed as well. It needs to be checked that chaining
works well even in multi thread test.
testCachedTopicPartitionsForValidShareSessions
[problem]
[solution]
testReleaseSessionCompletesDelayedShareFetchRequest
[problem]
'sharePartitionManager.releaseSession(groupId, memberId);' which leads
to exception.
[solution]
testReleaseSessionSuccess
[problem]
'sharePartitionManager.releaseSession(groupId, memberId.toString());'
which leads to exception.
[solution]
Reviewers: Abhinav Dixit [email protected], Andrew Schofield
[email protected]