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 2022/06/15 09:08:28 UTC
[GitHub] [pulsar] Demogorgon314 commented on a diff in pull request #16023: [fix][admin]allowAutoTopicCreation and allowAutoTopicCreationType etc should be dynamically configured
Demogorgon314 commented on code in PR #16023:
URL: https://github.com/apache/pulsar/pull/16023#discussion_r895622744
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BrokerServiceAutoTopicCreationTest.java:
##########
@@ -414,4 +419,105 @@ public void testAutoCreationOfSystemTopicNamespaceEvents() throws Exception {
assertTrue(admin.namespaces().getTopics("prop/ns-abc").contains(topicString));
assertFalse(admin.topics().getPartitionedTopicList("prop/ns-abc").contains(topicString));
}
+
+ @Test
+ public void testDynamicConfigurationTopicAutoCreationDisable() throws PulsarAdminException {
+ // test disable AllowAutoTopicCreation
+ pulsar.getConfiguration().setAllowAutoTopicCreation(true);
+ admin.brokers().updateDynamicConfiguration("allowAutoTopicCreation", "false");
+ final String namespaceName = "prop/ns-abc";
+ final String topic = "persistent://" + namespaceName + "/test-dynamicConfiguration-topic-auto-creation-"
+ + UUID.randomUUID();
+ try {
+ org.apache.pulsar.client.api.Producer<byte[]> producer = pulsarClient.newProducer()
Review Comment:
```suggestion
pulsarClient.newProducer()
```
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BrokerServiceAutoTopicCreationTest.java:
##########
@@ -414,4 +419,105 @@ public void testAutoCreationOfSystemTopicNamespaceEvents() throws Exception {
assertTrue(admin.namespaces().getTopics("prop/ns-abc").contains(topicString));
assertFalse(admin.topics().getPartitionedTopicList("prop/ns-abc").contains(topicString));
}
+
+ @Test
+ public void testDynamicConfigurationTopicAutoCreationDisable() throws PulsarAdminException {
+ // test disable AllowAutoTopicCreation
+ pulsar.getConfiguration().setAllowAutoTopicCreation(true);
+ admin.brokers().updateDynamicConfiguration("allowAutoTopicCreation", "false");
+ final String namespaceName = "prop/ns-abc";
+ final String topic = "persistent://" + namespaceName + "/test-dynamicConfiguration-topic-auto-creation-"
+ + UUID.randomUUID();
+ try {
+ org.apache.pulsar.client.api.Producer<byte[]> producer = pulsarClient.newProducer()
+ .topic(topic)
+ .create();
Review Comment:
```suggestion
.create();
fail();
```
Should add `fail()`.
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BrokerServiceAutoTopicCreationTest.java:
##########
@@ -414,4 +419,105 @@ public void testAutoCreationOfSystemTopicNamespaceEvents() throws Exception {
assertTrue(admin.namespaces().getTopics("prop/ns-abc").contains(topicString));
assertFalse(admin.topics().getPartitionedTopicList("prop/ns-abc").contains(topicString));
}
+
+ @Test
+ public void testDynamicConfigurationTopicAutoCreationDisable() throws PulsarAdminException {
+ // test disable AllowAutoTopicCreation
+ pulsar.getConfiguration().setAllowAutoTopicCreation(true);
+ admin.brokers().updateDynamicConfiguration("allowAutoTopicCreation", "false");
+ final String namespaceName = "prop/ns-abc";
+ final String topic = "persistent://" + namespaceName + "/test-dynamicConfiguration-topic-auto-creation-"
+ + UUID.randomUUID();
+ try {
+ org.apache.pulsar.client.api.Producer<byte[]> producer = pulsarClient.newProducer()
+ .topic(topic)
+ .create();
+ } catch (Exception e) {
+ assertTrue(e instanceof PulsarClientException);
Review Comment:
```suggestion
assertTrue(e instanceof PulsarClientException.NotFoundException);
```
--
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