slbotbm commented on code in PR #4351:
URL: https://github.com/apache/iggy/pull/4351#discussion_r4172175268
##########
foreign/java/java-sdk/src/test/java/org/apache/iggy/client/blocking/IntegrationTest.java:
##########
@@ -117,4 +124,36 @@ protected void trackUser(Long userId) {
createdUserIds.add(userId);
}
}
+
+ protected static PolledMessages pollMessages(MessagesClient
messagesClient, StreamId streamId, TopicId topicId) {
+ return messagesClient.pollMessages(
+ streamId,
+ topicId,
+ Optional.empty(),
+ Consumer.of(0L),
+ new PollingStrategy(PollingKind.Last, BigInteger.TEN),
+ 10L,
+ false);
+ }
+
+ /**
+ * Polls until no messages remain or the timeout elapses. A purge is
acknowledged once the
+ * server accepts it, but the messages can still be visible to a poll
issued right after, so a
+ * single poll is not a reliable assertion that the purge took effect.
+ */
+ protected static boolean pollUntilEmpty(MessagesClient messagesClient,
StreamId streamId, TopicId topicId) {
+ var deadline = System.currentTimeMillis() + 10_000;
+ do {
+ if (pollMessages(messagesClient, streamId,
topicId).messages().isEmpty()) {
+ return true;
+ }
+ try {
+ Thread.sleep(200);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ return false;
+ }
+ } while (System.currentTimeMillis() < deadline);
+ return false;
Review Comment:
It is alright to use llms to write code. But at least control it well and
make it follow the repository's patterns. This looks like you one-shotted the
implementation
##########
foreign/java/java-sdk/src/test/java/org/apache/iggy/client/blocking/IntegrationTest.java:
##########
@@ -117,4 +124,36 @@ protected void trackUser(Long userId) {
createdUserIds.add(userId);
}
}
+
+ protected static PolledMessages pollMessages(MessagesClient
messagesClient, StreamId streamId, TopicId topicId) {
+ return messagesClient.pollMessages(
+ streamId,
+ topicId,
+ Optional.empty(),
+ Consumer.of(0L),
+ new PollingStrategy(PollingKind.Last, BigInteger.TEN),
+ 10L,
+ false);
+ }
Review Comment:
Inline this. No need for separate function
##########
foreign/java/java-sdk/src/test/java/org/apache/iggy/client/blocking/IntegrationTest.java:
##########
@@ -117,4 +124,36 @@ protected void trackUser(Long userId) {
createdUserIds.add(userId);
}
}
+
+ protected static PolledMessages pollMessages(MessagesClient
messagesClient, StreamId streamId, TopicId topicId) {
+ return messagesClient.pollMessages(
+ streamId,
+ topicId,
+ Optional.empty(),
+ Consumer.of(0L),
+ new PollingStrategy(PollingKind.Last, BigInteger.TEN),
+ 10L,
+ false);
+ }
+
+ /**
+ * Polls until no messages remain or the timeout elapses. A purge is
acknowledged once the
+ * server accepts it, but the messages can still be visible to a poll
issued right after, so a
+ * single poll is not a reliable assertion that the purge took effect.
+ */
+ protected static boolean pollUntilEmpty(MessagesClient messagesClient,
StreamId streamId, TopicId topicId) {
+ var deadline = System.currentTimeMillis() + 10_000;
+ do {
+ if (pollMessages(messagesClient, streamId,
topicId).messages().isEmpty()) {
+ return true;
+ }
+ try {
+ Thread.sleep(200);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ return false;
+ }
+ } while (System.currentTimeMillis() < deadline);
+ return false;
Review Comment:
Inline this as well.
--
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]