Skip to content
Merged
Show file tree
Hide file tree
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 @@ -733,6 +733,7 @@ protected void deleteNamespaceWithRetry(String ns, boolean force)
*/
public static void deleteNamespaceWithRetry(String ns, boolean force, PulsarAdmin admin) throws Exception {
Awaitility.await()
.atMost(20, TimeUnit.SECONDS)
.pollDelay(500, TimeUnit.MILLISECONDS)
.until(() -> {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,28 @@ void shutdown() throws Exception {
}

@BeforeMethod(alwaysRun = true)
void createNamespaces() throws PulsarAdminException {
void createNamespaces() throws Exception {
config.setPreciseTimeBasedBacklogQuotaCheck(false);
admin.namespaces().createNamespace("prop/ns-quota");
admin.namespaces().setNamespaceReplicationClusters("prop/ns-quota", Sets.newHashSet("usc"), false);
admin.namespaces().createNamespace("prop/quotahold");
admin.namespaces().setNamespaceReplicationClusters("prop/quotahold", Sets.newHashSet("usc"), false);
admin.namespaces().createNamespace("prop/quotaholdasync");
admin.namespaces().setNamespaceReplicationClusters("prop/quotaholdasync", Sets.newHashSet("usc"), false);
createNamespaceForTest("prop/ns-quota");
createNamespaceForTest("prop/quotahold");
createNamespaceForTest("prop/quotaholdasync");
}

/**
* If a previous test's @AfterMethod timed out before the namespace was fully removed, the
* leftover would otherwise cascade as HTTP 409 here and fail every subsequent test.
* Force-delete and retry so each test starts with clean namespace state.
*/
private void createNamespaceForTest(String ns) throws Exception {
try {
admin.namespaces().createNamespace(ns);
} catch (PulsarAdminException.ConflictException e) {
log.warn().attr("namespace", ns)
.log("Namespace already exists from previous test — force-deleting and recreating");
deleteNamespaceWithRetry(ns, true);
admin.namespaces().createNamespace(ns);
}
admin.namespaces().setNamespaceReplicationClusters(ns, Sets.newHashSet("usc"), false);
}

@AfterMethod(alwaysRun = true)
Expand Down
Loading