You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by te...@apache.org on 2022/09/16 01:32:31 UTC
[pulsar] branch master updated: [fix][broker]add test case for deleting namespace fail when has partitioned system topic (#17338)
This is an automated email from the ASF dual-hosted git repository.
technoboy 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 bfbe3811ab1 [fix][broker]add test case for deleting namespace fail when has partitioned system topic (#17338)
bfbe3811ab1 is described below
commit bfbe3811ab1120dd602d2548422f934c7358b5b5
Author: fengyubiao <yu...@streamnative.io>
AuthorDate: Fri Sep 16 09:32:24 2022 +0800
[fix][broker]add test case for deleting namespace fail when has partitioned system topic (#17338)
---
.../apache/pulsar/broker/admin/AdminApi2Test.java | 47 ++++++++++++++++++++--
1 file changed, 44 insertions(+), 3 deletions(-)
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApi2Test.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApi2Test.java
index 92eac8342f4..a619bab272e 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApi2Test.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApi2Test.java
@@ -51,7 +51,9 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import javax.ws.rs.NotAcceptableException;
import javax.ws.rs.core.Response.Status;
+import lombok.AllArgsConstructor;
import lombok.Cleanup;
+import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.bookkeeper.mledger.ManagedLedger;
import org.apache.bookkeeper.mledger.impl.ManagedCursorImpl;
@@ -1500,9 +1502,43 @@ public class AdminApi2Test extends MockedPulsarServiceBaseTest {
}
}
- @Test
- public void testDeleteNamespace() throws Exception {
- pulsar.getConfiguration().setForceDeleteNamespaceAllowed(false);
+ @Data
+ @AllArgsConstructor
+ private static class NamespaceAttr {
+ private boolean systemTopicEnabled;
+ private String autoTopicCreationType;
+ private int defaultNumPartitions;
+ private boolean forceDeleteNamespaceAllowed;
+ }
+
+ @DataProvider(name = "namespaceAttrs")
+ public Object[][] namespaceAttributes(){
+ return new Object[][]{
+ {new NamespaceAttr(false, "non-partitioned", 0, false)},
+ {new NamespaceAttr(true, "non-partitioned", 0, false)},
+ {new NamespaceAttr(true, "partitioned", 3, false)}
+ };
+ }
+
+ private NamespaceAttr markOriginalNamespaceAttr(){
+ return new NamespaceAttr(conf.isSystemTopicEnabled(), conf.getAllowAutoTopicCreationType(),
+ conf.getDefaultNumPartitions(), conf.isForceDeleteNamespaceAllowed());
+ }
+
+ private void setNamespaceAttr(NamespaceAttr namespaceAttr){
+ conf.setSystemTopicEnabled(namespaceAttr.systemTopicEnabled);
+ conf.setAllowAutoTopicCreationType(namespaceAttr.autoTopicCreationType);
+ conf.setDefaultNumPartitions(namespaceAttr.defaultNumPartitions);
+ conf.setForceDeleteNamespaceAllowed(namespaceAttr.forceDeleteNamespaceAllowed);
+ }
+
+ @Test(dataProvider = "namespaceAttrs")
+ public void testDeleteNamespace(NamespaceAttr namespaceAttr) throws Exception {
+ // Set conf.
+ internalCleanup();
+ NamespaceAttr originalNamespaceAttr = markOriginalNamespaceAttr();
+ setNamespaceAttr(namespaceAttr);
+ setup();
String tenant = "test-tenant";
assertFalse(admin.tenants().getTenants().contains(tenant));
@@ -1548,6 +1584,11 @@ public class AdminApi2Test extends MockedPulsarServiceBaseTest {
final String bundleDataPath = "/loadbalance/bundle-data/" + namespace;
assertFalse(pulsar.getLocalMetadataStore().exists(bundleDataPath).join());
+
+ // Reset config
+ internalCleanup();
+ setNamespaceAttr(originalNamespaceAttr);
+ setup();
}
private void awaitChangeEventTopicAndCompactionCreateFinish(String ns, String topic) throws Exception {