Skip to content

Conversation

@brandboat
Copy link
Member

@brandboat brandboat commented Oct 24, 2025

This patch wraps ShareFetchUtils static method processFetchResponse
with MockedStatic to improve test isolation and also fixes some
incorrect test results.

@github-actions github-actions bot added core Kafka Broker KIP-932 Queues for Kafka labels Oct 24, 2025
@brandboat brandboat changed the title KAFKA-19345: Use ShareFetchUtils mock for DelayedShareFetchTest tests (WIP) KAFKA-19345: Use ShareFetchUtils mock for DelayedShareFetchTest tests Oct 24, 2025
@brandboat brandboat changed the title (WIP) KAFKA-19345: Use ShareFetchUtils mock for DelayedShareFetchTest tests KAFKA-19345: Use ShareFetchUtils mock for DelayedShareFetchTest tests Oct 24, 2025
assertNull(shareGroupMetrics.topicPartitionsFetchRatio(groupId));

delayedShareFetch.lock().unlock();
Mockito.verify(exceptionHandler, never()).accept(any(), any());
Copy link
Member Author

@brandboat brandboat Oct 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exceptionHandler shouldn't be triggered in this test case.
The reason it throw error simply due to incorrect test mock up,

when(replicaManager.getPartitionOrException(tp0.topicPartition())).thenReturn(p0);
the above code snippet override the return value of replicaManager.getPartitionOrException(tp0.topicPartition()) defined in
mockTopicIdPartitionFetchBytes(replicaManager, tp0, hwmOffsetMetadata);
, which make isMinBytesSatisfied raise NPE , and this is unexpected.

assertTrue(delayedShareFetch.lock().tryLock());
delayedShareFetch.lock().unlock();
Mockito.verify(exceptionHandler, times(1)).accept(any(), any());
Mockito.verify(exceptionHandler, never()).accept(any(), any());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@brandboat
Copy link
Member Author

UserQuotaTest#testThrottledRequest(String) with groupProtocol=classic is a known flaky test (KAFKA-8459). It’s unrelated to this PR and passes locally.

@brandboat
Copy link
Member Author

Gentle ping , @AndrewJSchofield, @apoorvmittal10, @adixitconfluent — sorry for the late implementation 🙏
I’ve also fixed a few incorrect tests in this patch. Would appreciate your review when you have a chance. Thanks!

@apoorvmittal10
Copy link
Contributor

@adixitconfluent Can you please review the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-approved core Kafka Broker KIP-932 Queues for Kafka

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants