Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[test][admin]add test case: delete namespace when has partitioned system topic #17338

Merged
merged 1 commit into from
Sep 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@
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;
Expand Down Expand Up @@ -1500,9 +1502,43 @@ public void testDeleteTenant() throws Exception {
}
}

@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));
Expand Down Expand Up @@ -1548,6 +1584,11 @@ public void testDeleteNamespace() throws Exception {

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 {
Expand Down