You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/01/11 09:54:49 UTC

[GitHub] [flink] JingsongLi commented on a change in pull request #18326: [FLINK-25209][tests] Wait until the consuming topic is ready before polling records in KafkaContainerClient#readMessages

JingsongLi commented on a change in pull request #18326:
URL: https://github.com/apache/flink/pull/18326#discussion_r781978821



##########
File path: flink-end-to-end-tests/flink-end-to-end-tests-common-kafka/src/main/java/org/apache/flink/tests/util/kafka/KafkaContainerClient.java
##########
@@ -99,7 +102,19 @@ public void createTopic(int replicationFactor, int numPartitions, String topic)
         final List<T> messages = Collections.synchronizedList(new ArrayList<>(expectedNumMessages));
         try (Consumer<Bytes, T> consumer =
                 new KafkaConsumer<>(props, new BytesDeserializer(), valueDeserializer)) {
-            consumer.subscribe(Pattern.compile(topic));
+            // Wait until the reading topic is created
+            CommonTestUtils.waitUtil(
+                    () -> consumer.listTopics(Duration.ofSeconds(1)).containsKey(topic),
+                    Duration.ofSeconds(30),

Review comment:
       Longer? maybe 60s?

##########
File path: flink-end-to-end-tests/flink-end-to-end-tests-common-kafka/src/main/java/org/apache/flink/tests/util/kafka/KafkaContainerClient.java
##########
@@ -99,7 +102,19 @@ public void createTopic(int replicationFactor, int numPartitions, String topic)
         final List<T> messages = Collections.synchronizedList(new ArrayList<>(expectedNumMessages));
         try (Consumer<Bytes, T> consumer =
                 new KafkaConsumer<>(props, new BytesDeserializer(), valueDeserializer)) {
-            consumer.subscribe(Pattern.compile(topic));
+            // Wait until the reading topic is created
+            CommonTestUtils.waitUtil(

Review comment:
       Can we extract a method: 'waitTopicCreation'?




-- 
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: issues-unsubscribe@flink.apache.org

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