brenden20 commented on code in PR #16140:
URL: https://github.com/apache/kafka/pull/16140#discussion_r1630082187
##########
clients/src/test/java/org/apache/kafka/clients/consumer/internals/ConsumerNetworkThreadTest.java:
##########
@@ -150,35 +184,49 @@ public void testStartupAndTearDown() throws
InterruptedException {
}
@Test
- public void testApplicationEvent() {
- ApplicationEvent e = new PollEvent(100);
- applicationEventsQueue.add(e);
+ public void testRequestsTransferFromManagersToClientOnThreadRun() {
+ List<Optional<? extends RequestManager>> list = new ArrayList<>();
+ list.add(Optional.of(coordinatorRequestManager));
+ list.add(Optional.of(heartbeatRequestManager));
+ list.add(Optional.of(offsetsRequestManager));
+
+ when(requestManagers.entries()).thenReturn(list);
+
when(coordinatorRequestManager.poll(anyLong())).thenReturn(mock(NetworkClientDelegate.PollResult.class));
consumerNetworkThread.runOnce();
- verify(applicationEventProcessor, times(1)).process(e);
+ requestManagers.entries().forEach(rmo -> rmo.ifPresent(rm ->
verify(rm).poll(anyLong())));
+ requestManagers.entries().forEach(rmo -> rmo.ifPresent(rm ->
verify(rm).maximumTimeToWait(anyLong())));
+
verify(networkClientDelegate).addAll(any(NetworkClientDelegate.PollResult.class));
+ verify(networkClientDelegate).poll(anyLong(), anyLong());
}
- @Test
- public void testMetadataUpdateEvent() {
- ApplicationEvent e = new NewTopicsMetadataUpdateRequestEvent();
+ @ParameterizedTest
+ @MethodSource("applicationEvents")
+ public void testApplicationEventIsProcessed(ApplicationEvent e) {
applicationEventsQueue.add(e);
consumerNetworkThread.runOnce();
- verify(metadata).requestUpdateForNewTopics();
- }
- @Test
- public void testAsyncCommitEvent() {
- ApplicationEvent e = new AsyncCommitEvent(new HashMap<>());
- applicationEventsQueue.add(e);
- consumerNetworkThread.runOnce();
- verify(applicationEventProcessor).process(any(AsyncCommitEvent.class));
+ if (e instanceof CompletableEvent)
+ verify(applicationEventReaper).add((CompletableEvent<?>) e);
+
+ verify(applicationEventProcessor).process(any(e.getClass()));
+ assertTrue(applicationEventsQueue.isEmpty());
}
- @Test
- public void testSyncCommitEvent() {
- ApplicationEvent e = new SyncCommitEvent(new HashMap<>(),
calculateDeadlineMs(time, 100));
- applicationEventsQueue.add(e);
- consumerNetworkThread.runOnce();
- verify(applicationEventProcessor).process(any(SyncCommitEvent.class));
+ private static Stream<Arguments> applicationEvents() {
+ Time time1 = new MockTime();
+ Map<TopicPartition, OffsetAndMetadata> offset =
mockTopicPartitionOffset();
+ final long currentTimeMs = time1.milliseconds();
+
+ // use 500 for deadlineMs
Review Comment:
Mistake leaving that there, fixed now
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]