pulsar-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [pulsar] zhanghaou commented on a change in pull request #7839: [ISSUE 7758]Support set Max Producer on topic level
Date Sat, 22 Aug 2020 01:39:44 GMT

zhanghaou commented on a change in pull request #7839:
URL: https://github.com/apache/pulsar/pull/7839#discussion_r475030592



##########
File path: pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/TopicPoliciesTest.java
##########
@@ -337,4 +338,80 @@ public void testRemovePersistence() throws Exception {
 
         admin.topics().deletePartitionedTopic(testTopic, true);
     }
+
+    @Test
+    public void testCheckMaxProducers() throws Exception {
+        Integer maxProducers = new Integer(-1);
+        log.info("MaxProducers: {} will set to the topic: {}", maxProducers, testTopic);
+        try {
+            admin.topics().setMaxProducers(testTopic, maxProducers);
+            Assert.fail();
+        } catch (PulsarAdminException e) {
+            Assert.assertEquals(e.getStatusCode(), 412);
+        }
+
+        admin.topics().deletePartitionedTopic(testTopic, true);
+    }
+
+    @Test
+    public void testSetMaxProducers() throws Exception {
+        Integer maxProducers = 2;
+        log.info("MaxProducers: {} will set to the topic: {}", maxProducers, persistenceTopic);
+        admin.topics().setMaxProducers(persistenceTopic, maxProducers);
+        Thread.sleep(3000);
+
+        admin.topics().createPartitionedTopic(persistenceTopic, 2);
+        Producer producer1 = null;
+        Producer producer2 = null;
+        Producer producer3 = null;
+        try {
+            producer1 = pulsarClient.newProducer().topic(persistenceTopic).create();
+        } catch (PulsarClientException e) {
+            Assert.fail();
+        }
+        try {
+            producer2 = pulsarClient.newProducer().topic(persistenceTopic).create();
+        } catch (PulsarClientException e) {
+            Assert.fail();
+        }
+        try {
+            producer3 = pulsarClient.newProducer().topic(persistenceTopic).create();
+            Assert.fail();
+        } catch (PulsarClientException e) {
+            log.info("Topic reached max producers limit");
+        }
+        Assert.assertNotNull(producer1);
+        Assert.assertNotNull(producer2);
+        Assert.assertNull(producer3);
+        producer1.close();
+        producer2.close();
+
+        Integer getMaxProducers = admin.topics().getMaxProducers(persistenceTopic);
+        log.info("MaxProducers {} get on topic: {}", getMaxProducers, persistenceTopic);
+        Assert.assertEquals(getMaxProducers, maxProducers);
+
+        admin.topics().deletePartitionedTopic(persistenceTopic);
+        admin.topics().deletePartitionedTopic(testTopic, true);
+    }
+
+    @Test
+    public void testRemoveMaxProducers() throws Exception {
+        Integer maxProducers = 10;
+        log.info("MaxProducers: {} will set to the topic: {}", maxProducers, testTopic);
+
+        admin.topics().setMaxProducers(testTopic, maxProducers);
+        Thread.sleep(3000);
+        Integer getMaxProducers = admin.topics().getMaxProducers(testTopic);
+
+        log.info("MaxProducers: {} get on topic: {}", getMaxProducers, testTopic);
+        Assert.assertEquals(getMaxProducers, maxProducers);
+
+        admin.topics().removeMaxProducers(testTopic);

Review comment:
       OK. I will change it.




----------------------------------------------------------------
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.

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



Mime
View raw message