From f4b2f0a0a26a4514ac48fdcba0f2849353e81373 Mon Sep 17 00:00:00 2001 From: Dltmd202 Date: Sun, 27 Oct 2024 14:51:35 +0900 Subject: [PATCH] Lower the replication factor for transactions topic on EmbeddedKafka --- .../kafka/test/context/EmbeddedKafkaContextCustomizer.java | 5 +++-- .../test/context/EmbeddedKafkaContextCustomizerTests.java | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/spring-kafka-test/src/main/java/org/springframework/kafka/test/context/EmbeddedKafkaContextCustomizer.java b/spring-kafka-test/src/main/java/org/springframework/kafka/test/context/EmbeddedKafkaContextCustomizer.java index e8ec424dc2..8fa4937f99 100644 --- a/spring-kafka-test/src/main/java/org/springframework/kafka/test/context/EmbeddedKafkaContextCustomizer.java +++ b/spring-kafka-test/src/main/java/org/springframework/kafka/test/context/EmbeddedKafkaContextCustomizer.java @@ -47,12 +47,13 @@ * @author Oleg Artyomov * @author Sergio Lourenco * @author Pawel Lozinski - * @author Dltmd202 + * @author Seonghwan Lee * @since 1.3 */ class EmbeddedKafkaContextCustomizer implements ContextCustomizer { private final EmbeddedKafka embeddedKafka; + private final String TRANSACTION_STATE_LOG_REPLICATION_FACTOR = "transaction.state.log.replication.factor"; EmbeddedKafkaContextCustomizer(EmbeddedKafka embeddedKafka) { @@ -122,7 +123,7 @@ public void customizeContext(ConfigurableApplicationContext context, MergedConte } } - properties.putIfAbsent(TRANSACTION_STATE_LOG_REPLICATION_FACTOR, String.valueOf(Math.min(3, embeddedKafka.value()))); + properties.putIfAbsent(TRANSACTION_STATE_LOG_REPLICATION_FACTOR, String.valueOf(Math.min(3, embeddedKafka.count()))); embeddedKafkaBroker.brokerProperties((Map) (Map) properties); if (StringUtils.hasText(this.embeddedKafka.bootstrapServersProperty())) { diff --git a/spring-kafka-test/src/test/java/org/springframework/kafka/test/context/EmbeddedKafkaContextCustomizerTests.java b/spring-kafka-test/src/test/java/org/springframework/kafka/test/context/EmbeddedKafkaContextCustomizerTests.java index c77b689c1d..3d911ae6d5 100644 --- a/spring-kafka-test/src/test/java/org/springframework/kafka/test/context/EmbeddedKafkaContextCustomizerTests.java +++ b/spring-kafka-test/src/test/java/org/springframework/kafka/test/context/EmbeddedKafkaContextCustomizerTests.java @@ -16,6 +16,8 @@ package org.springframework.kafka.test.context; +import java.util.Map; + import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -25,7 +27,6 @@ import org.springframework.kafka.test.EmbeddedKafkaBroker; import org.springframework.kafka.test.utils.KafkaTestUtils; -import java.util.Map; import static org.assertj.core.api.Assertions.assertThat; @@ -107,7 +108,6 @@ void testTransactionReplicationFactor() { assertThat(properties.get("transaction.state.log.replication.factor")).isEqualTo("2"); } - @EmbeddedKafka(kraft = false) private static final class TestWithEmbeddedKafka {