Skip to content

Commit

Permalink
Add retention.ms=Long.MAX_VALUE to prevent topic cleanup during test
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffxiang committed Oct 25, 2024
1 parent 1849158 commit 29adc49
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Properties;
import java.util.Random;
Expand Down Expand Up @@ -236,7 +238,9 @@ public void createTestTopic(String topicUriString,
Properties properties) {
LOG.info("Creating topic {}", topicUriString);
try (AdminClient adminClient = AdminClient.create(getStandardKafkaProperties())) {
NewTopic topicObj = new NewTopic(BaseTopicUri.validate(topicUriString).getTopic(), numberOfPartitions, (short) replicationFactor);
Map<String, String> topicConfigs = new HashMap<>();
topicConfigs.put("retention.ms", Long.toString(Long.MAX_VALUE));
NewTopic topicObj = new NewTopic(BaseTopicUri.validate(topicUriString).getTopic(), numberOfPartitions, (short) replicationFactor).configs(topicConfigs);
adminClient.createTopics(Collections.singleton(topicObj)).all().get();
} catch (Exception e) {
// try to create it assuming that it's not a topicUriString
Expand Down

0 comments on commit 29adc49

Please sign in to comment.