showuon commented on a change in pull request #9029: URL: https://github.com/apache/kafka/pull/9029#discussion_r455672187
########## File path: connect/mirror/src/test/java/org/apache/kafka/connect/mirror/MirrorConnectorsIntegrationTest.java ########## @@ -315,9 +319,34 @@ public void testReplication() throws InterruptedException { backup.kafka().consume(NUM_RECORDS_PRODUCED, 2 * RECORD_TRANSFER_DURATION_MS, "primary.test-topic-2").count()); } + private void waitForConsumerGroupOffsetSync(Consumer<byte[], byte[]> consumer, List<String> topics) + throws InterruptedException { + Admin backupClient = backup.kafka().createAdminClient(); + List<TopicPartition> tps = new ArrayList<>(NUM_PARTITIONS * topics.size()); + IntStream.range(0, NUM_PARTITIONS).forEach( + partitionInd -> { + for (String topic: topics) { + tps.add(new TopicPartition(topic, partitionInd)); + } + } + ); + long expectedTotalOffsets = NUM_RECORDS_PRODUCED * topics.size(); + + waitForCondition(() -> { + Map<TopicPartition, OffsetAndMetadata> consumerGroupOffsets = + backupClient.listConsumerGroupOffsets("consumer-group-1").partitionsToOffsetAndMetadata().get(); + long consumerGroupOffsetTotal = consumerGroupOffsets.values().stream().mapToLong(metadata -> metadata.offset()).sum(); + + Map<TopicPartition, Long> offsets = consumer.endOffsets(tps, Duration.ofMillis(500)); + long totalOffsets = offsets.values().stream().mapToLong(l -> l).sum(); + + // make sure the consumer group offsets are synced to expected number + return totalOffsets == expectedTotalOffsets && consumerGroupOffsetTotal > 0; + }, OFFSET_SYNC_DURATION_MS, "Consumer group offset sync is not complete in time"); + } @Test - public void testOneWayReplicationWithAutorOffsetSync1() throws InterruptedException { + public void testOneWayReplicationWithAutoOffsetSync() throws InterruptedException { Review comment: rename the typo test name ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org