This is an automated email from the ASF dual-hosted git repository. mmerli pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/master by this push: new 55f7fd6 Fixed updating partitioned topic without subscriptions (#7064) 55f7fd6 is described below commit 55f7fd655768e2b41afb06a635891c813340fcb9 Author: Matteo Merli <mme...@apache.org> AuthorDate: Wed May 27 22:00:28 2020 -0700 Fixed updating partitioned topic without subscriptions (#7064) --- .../broker/admin/IncrementPartitionsTest.java | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/IncrementPartitionsTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/IncrementPartitionsTest.java index f43d381..ba2a560 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/IncrementPartitionsTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/IncrementPartitionsTest.java @@ -23,6 +23,8 @@ import static org.testng.Assert.assertEquals; import org.apache.pulsar.broker.admin.AdminApiTest.MockedPulsarService; import org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest; import org.apache.pulsar.client.api.Consumer; +import org.apache.pulsar.client.api.Producer; +import org.apache.pulsar.client.api.Schema; import org.apache.pulsar.common.naming.TopicName; import org.apache.pulsar.common.policies.data.ClusterData; import org.apache.pulsar.common.policies.data.TenantInfo; @@ -33,6 +35,8 @@ import org.testng.annotations.Test; import com.google.common.collect.Lists; import com.google.common.collect.Sets; +import lombok.Cleanup; + public class IncrementPartitionsTest extends MockedPulsarServiceBaseTest { private MockedPulsarService mockPulsarSetup; @@ -97,4 +101,26 @@ public class IncrementPartitionsTest extends MockedPulsarServiceBaseTest { consumer.close(); } + + @Test + public void testIncrementPartitionsWithNoSubscriptions() throws Exception { + final String partitionedTopicName = "persistent://prop-xyz/use/ns1/test-topic-" + System.nanoTime(); + + admin.topics().createPartitionedTopic(partitionedTopicName, 1); + assertEquals(admin.topics().getPartitionedTopicMetadata(partitionedTopicName).partitions, 1); + + @Cleanup + Producer<String> consumer = pulsarClient.newProducer(Schema.STRING) + .topic(partitionedTopicName) + .create(); + + admin.topics().updatePartitionedTopic(partitionedTopicName, 2); + assertEquals(admin.topics().getPartitionedTopicMetadata(partitionedTopicName).partitions, 2); + + admin.topics().updatePartitionedTopic(partitionedTopicName, 10); + assertEquals(admin.topics().getPartitionedTopicMetadata(partitionedTopicName).partitions, 10); + + admin.topics().updatePartitionedTopic(partitionedTopicName, 20); + assertEquals(admin.topics().getPartitionedTopicMetadata(partitionedTopicName).partitions, 20); + } }