johnjcasey commented on code in PR #24205:
URL: https://github.com/apache/beam/pull/24205#discussion_r1049782192
##########
sdks/java/io/kafka/src/test/java/org/apache/beam/sdk/io/kafka/KafkaIOIT.java:
##########
@@ -545,6 +547,68 @@ private PipelineResult runWithStopReadingFn(
return readResult;
}
+ @Test
+ public void testWatermarkUpdateWithSparseMessages() throws IOException {
+ AdminClient client =
+ AdminClient.create(
+ ImmutableMap.of("bootstrap.servers",
options.getKafkaBootstrapServerAddresses()));
+
+ String topicName = "SparseDataTopicPartition-" + UUID.randomUUID();
+ Map<Integer, String> records = new HashMap<>();
+ for (int i = 0; i < 5; i++) {
+ records.put(i, String.valueOf(i));
+ }
+
+ try {
+ client.createTopics(ImmutableSet.of(new NewTopic(topicName, 1, (short)
1)));
+
+ writePipeline
+ .apply("Generate Write Elements", Create.of(records))
+ .apply(
+ "Write to Kafka",
+ KafkaIO.<Integer, String>write()
+
.withBootstrapServers(options.getKafkaBootstrapServerAddresses())
+ .withTopic(topicName)
+ .withKeySerializer(IntegerSerializer.class)
+ .withValueSerializer(StringSerializer.class));
+
+ writePipeline.run().waitUntilFinish(Duration.standardSeconds(15));
+
+ client.createPartitions(ImmutableMap.of(topicName,
NewPartitions.increaseTo(3)));
+
+ PCollection<String> values =
+ sdfReadPipeline
+ .apply(
+ "Read from Kafka",
+ KafkaIO.<Integer, String>read()
+
.withBootstrapServers(options.getKafkaBootstrapServerAddresses())
+
.withConsumerConfigUpdates(ImmutableMap.of("auto.offset.reset", "earliest"))
+ .withTopic(topicName)
+ .withKeyDeserializer(IntegerDeserializer.class)
+ .withValueDeserializer(StringDeserializer.class)
+ .withoutMetadata())
+ .apply(Window.into(FixedWindows.of(Duration.standardMinutes(1))))
+ .apply("GroupKey", GroupByKey.create())
+ .apply("GetValues", Values.create())
+ .apply(
+ "Flatten",
+
FlatMapElements.into(TypeDescriptor.of(String.class)).via(iterable ->
iterable));
+
+ PAssert.that(values).containsInAnyOrder("0", "1", "2", "3", "4");
+
+ PipelineResult readResult = sdfReadPipeline.run();
+
+ PipelineResult.State readState =
+
readResult.waitUntilFinish(Duration.standardSeconds(options.getReadTimeout() /
2));
Review Comment:
No, the /2 is a copy paste from another test case. I hadn't thought about
the wait to finish forcing advances, but that makes sense. I need to rework
this test case
--
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]