chia7712 commented on code in PR #15489:
URL: https://github.com/apache/kafka/pull/15489#discussion_r1547986293


##########
tools/src/test/java/org/apache/kafka/tools/GetOffsetShellTest.java:
##########
@@ -391,4 +420,15 @@ private String[] addBootstrapServer(String... args) {
 
         return newArgs.toArray(new String[0]);
     }
+
+    private void retryUntilEqual(List<Row> expected, Supplier<List<Row>> 
outputSupplier) {
+        try {
+            TestUtils.waitForCondition(
+                    () -> expected.equals(outputSupplier.get()),
+                    "TopicOffsets did not match. Expected: " + 
expectedTestTopicOffsets() + ", but was: " + outputSupplier.get()

Review Comment:
   Could you use `admin` to list latest offsets after it fails? for example:
   
   ```java
       private Set<Row> parse() throws ExecutionException, InterruptedException 
{
           try (Admin admin = cluster.createAdminClient()) {
               Set<String> topics = admin.listTopics(new 
ListTopicsOptions().listInternal(true)).listings().get()
                       
.stream().map(TopicListing::name).collect(Collectors.toSet());
               Map<TopicPartition, OffsetSpec> offsetRequest = 
admin.describeTopics(topics)
                       .allTopicNames().get().entrySet().stream().flatMap(entry 
-> entry.getValue().partitions()
                               .stream().map(p -> new 
AbstractMap.SimpleImmutableEntry<>(new TopicPartition(entry.getKey(), 
p.partition()), OffsetSpec.latest())))
                       .collect(Collectors.toMap(Map.Entry::getKey, 
Map.Entry::getValue));
               return 
admin.listOffsets(offsetRequest).all().get().entrySet().stream()
                       .map(entry -> new Row(entry.getKey().topic(), 
entry.getKey().partition(), entry.getValue().offset()))
                       .collect(Collectors.toSet());
           }
       }
   ```



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to