Skip to content

Commit

Permalink
[improve][test] Restart broker in SimpleProducerConsumerTest if delet…
Browse files Browse the repository at this point in the history
…ion times out
  • Loading branch information
lhotari committed May 17, 2024
1 parent 23d5e12 commit 5aae50f
Showing 1 changed file with 19 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,24 +148,29 @@ protected void setup() throws Exception {

@AfterMethod(alwaysRun = true)
public void rest() throws Exception {
pulsar.getConfiguration().setForceDeleteTenantAllowed(true);
pulsar.getConfiguration().setForceDeleteNamespaceAllowed(true);
try {
pulsar.getConfiguration().setForceDeleteTenantAllowed(true);
pulsar.getConfiguration().setForceDeleteNamespaceAllowed(true);

for (String tenant : admin.tenants().getTenants()) {
for (String namespace : admin.namespaces().getNamespaces(tenant)) {
deleteNamespaceWithRetry(namespace, true);
for (String tenant : admin.tenants().getTenants()) {
for (String namespace : admin.namespaces().getNamespaces(tenant)) {
deleteNamespaceWithRetry(namespace, true);
}
admin.tenants().deleteTenant(tenant, true);
}
admin.tenants().deleteTenant(tenant, true);
}

for (String cluster : admin.clusters().getClusters()) {
admin.clusters().deleteCluster(cluster);
}

pulsar.getConfiguration().setForceDeleteTenantAllowed(false);
pulsar.getConfiguration().setForceDeleteNamespaceAllowed(false);
for (String cluster : admin.clusters().getClusters()) {
admin.clusters().deleteCluster(cluster);
}

super.producerBaseSetup();
pulsar.getConfiguration().setForceDeleteTenantAllowed(false);
pulsar.getConfiguration().setForceDeleteNamespaceAllowed(false);
super.producerBaseSetup();
} catch (Exception | AssertionError e) {
log.warn("Failed to clean up state. Restarting broker.", e);
cleanup();
setup();
}
}

@DataProvider
Expand Down

0 comments on commit 5aae50f

Please sign in to comment.