Copilot commented on code in PR #7043:
URL: https://github.com/apache/shenyu/pull/7043#discussion_r4044858670
##########
shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-kafka/src/test/java/org/apache/shenyu/plugin/logging/kafka/kafka/KafkaLogCollectClientTest.java:
##########
@@ -68,4 +74,27 @@ public void testInitClient() throws NoSuchFieldException,
IllegalAccessException
kafkaLogCollectClient.close();
}
}
+
+ @Test
+ public void testConsume0FlushesOncePerBatch() throws NoSuchFieldException,
IllegalAccessException {
+ KafkaProducer<String, String> producer = mock(KafkaProducer.class);
+ setProducer(producer);
+
kafkaLogCollectClient.consume0(Collections.singletonList(shenyuRequestLog));
+ verify(producer).flush();
Review Comment:
This test does not exercise the optimization. The client's `topic` is never
initialized, so constructing each `ProducerRecord` fails before `send`, and the
outer `flush()` still satisfies the assertion. Also, a one-record batch would
pass with the old per-record flush. Set a valid topic and use at least two
records so the exact-once verification distinguishes batch flushing from the
previous behavior.
--
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]