Skip to content

Commit

Permalink
Lower the replication factor for transactions topic on EmbeddedKafka
Browse files Browse the repository at this point in the history
  • Loading branch information
Dltmd202 committed Oct 29, 2024
1 parent df61740 commit f4b2f0a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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<String, String>) (Map<?, ?>) properties);
if (StringUtils.hasText(this.embeddedKafka.bootstrapServersProperty())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand Down Expand Up @@ -107,7 +108,6 @@ void testTransactionReplicationFactor() {
assertThat(properties.get("transaction.state.log.replication.factor")).isEqualTo("2");
}


@EmbeddedKafka(kraft = false)
private static final class TestWithEmbeddedKafka {

Expand Down

0 comments on commit f4b2f0a

Please sign in to comment.