Skip to content

Bugfix: set max_active_partitions on topic creation #512

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ public CompletableFuture<Status> createTopic(String path, CreateTopicSettings se
if (partitioningSettings != null) {
requestBuilder.setPartitioningSettings(YdbTopic.PartitioningSettings.newBuilder()
.setMinActivePartitions(partitioningSettings.getMinActivePartitions())
.setMaxActivePartitions(partitioningSettings.getMaxActivePartitions())
.setPartitionCountLimit(partitioningSettings.getPartitionCountLimit())
.setAutoPartitioningSettings(YdbTopic.AutoPartitioningSettings.newBuilder()
.setStrategy(toProto(partitioningSettings.getAutoPartitioningStrategy()))));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.FixMethodOrder;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import org.slf4j.Logger;
Expand Down Expand Up @@ -55,6 +54,8 @@ public class YdbTopicsIntegrationTest {
public final static GrpcTransportRule ydbTransport = new GrpcTransportRule();

private final static String TEST_TOPIC = "integration_test_topic";
private final static String TEST_OTHER_TOPIC = "integration_test_other_topic";

private final static String TEST_CONSUMER1 = "consumer";
private final static String TEST_CONSUMER2 = "other_consumer";

Expand Down Expand Up @@ -244,12 +245,13 @@ public void onMessages(DataReceivedEvent dre) {
}
}

@Ignore("remove ignore once :latest YDB container tag moves onto version 25.1")
@Test
public void step07_alterTopicWithAutoPartitioning() {
client.alterTopic(TEST_TOPIC, AlterTopicSettings.newBuilder()
.setAlterPartitioningSettings(AlterPartitioningSettings.newBuilder()
.setAutoPartitioningStrategy(AutoPartitioningStrategy.SCALE_UP)
.setMaxActivePartitions(10)
.setMinActivePartitions(5)
.setWriteStrategySettings(AlterAutoPartitioningWriteStrategySettings.newBuilder()
.setStabilizationWindow(Duration.ofMinutes(1))
.setUpUtilizationPercent(80)
Expand All @@ -267,10 +269,34 @@ public void step07_alterTopicWithAutoPartitioning() {
.setUpUtilizationPercent(80)
.setDownUtilizationPercent(20)
.build())
.setMinActivePartitions(1)
.setMaxActivePartitions(1)
.setMinActivePartitions(5)
.setMaxActivePartitions(10)
.build();

Assert.assertEquals(expectedPartitioningSettings, actualPartitioningSettings);
}

@Test
public void step08_createTopicWithAutoPartitioning() {
PartitioningSettings expectedPartitioningSettings = PartitioningSettings.newBuilder()
.setMaxActivePartitions(8)
.setMinActivePartitions(4)
.setAutoPartitioningStrategy(AutoPartitioningStrategy.SCALE_UP)
.setWriteStrategySettings(AutoPartitioningWriteStrategySettings.newBuilder()
.setDownUtilizationPercent(5)
.setUpUtilizationPercent(75)
.setStabilizationWindow(Duration.ofMinutes(2))
.build())
.build();

CompletableFuture<Status> secondaryTopicCreated = client.createTopic(TEST_OTHER_TOPIC, CreateTopicSettings.newBuilder()
.setPartitioningSettings(expectedPartitioningSettings)
.build());

secondaryTopicCreated.join().expectSuccess("can't create the topic");

TopicDescription description = client.describeTopic(TEST_OTHER_TOPIC).join().getValue();

Assert.assertEquals(expectedPartitioningSettings, description.getPartitioningSettings());
}
}