You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/09/12 15:31:19 UTC

[GitHub] [pulsar] gaoran10 commented on a change in pull request #11986: [pulsar admin] getPartitionedTopicMetada method support setting auto create topic

gaoran10 commented on a change in pull request #11986:
URL: https://github.com/apache/pulsar/pull/11986#discussion_r706854463



##########
File path: pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/PersistentTopicsTest.java
##########
@@ -389,6 +392,27 @@ public void testNonPartitionedTopics() {
                 0);
     }
 
+    @Test
+    public void testGetPartitionedMetadata() {
+
+        String testLocalTopicName = "test-topic";
+
+        // 1) Auto create non-partitioned topic.
+        PartitionedTopicMetadata partitionedMetadata = persistentTopics.getPartitionedMetadata(testTenant, testNamespace, testLocalTopicName, true, true);
+        Assert.assertEquals(0, partitionedMetadata.partitions);
+
+        // 2. Add validate policy assert.
+        doThrow(new RestException(Response.Status.FORBIDDEN, "mock message"))
+                .when(persistentTopics).validateTopicPolicyOperation(persistentTopics.topicName, PolicyName.PARTITION, PolicyOperation.WRITE);
+        try {
+            persistentTopics.getPartitionedMetadata(testTenant, testNamespace, testLocalTopicName, true, true);
+            Assert.fail("Should fail validation on policy exception");
+        } catch (RestException e) {
+            Assert.assertEquals(Response.Status.FORBIDDEN.getStatusCode(), e.getResponse().getStatus());
+        }
+

Review comment:
       Could we add tests to when the param `checkAllowAutoCreation` is `false`?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org