Skip to content

Commit

Permalink
change method name deleteNamespaceGraceFully -> deleteNamespaceWithRetry
Browse files Browse the repository at this point in the history
  • Loading branch information
poorbarcode committed Nov 18, 2022
1 parent 647d892 commit 8dc781c
Show file tree
Hide file tree
Showing 14 changed files with 54 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public void resetClusters() throws Exception {
pulsar.getConfiguration().setForceDeleteNamespaceAllowed(true);
for (String tenant : admin.tenants().getTenants()) {
for (String namespace : admin.namespaces().getNamespaces(tenant)) {
deleteNamespaceGraceFully(namespace, true, admin, pulsar,
deleteNamespaceWithRetry(namespace, true, admin, pulsar,
mockPulsarSetup.getPulsar());
}
admin.tenants().deleteTenant(tenant, true);
Expand Down Expand Up @@ -1515,7 +1515,7 @@ public void testDeleteTenant() throws Exception {
assertFalse(admin.topics().getList(namespace).isEmpty());

try {
deleteNamespaceGraceFully(namespace, false);
admin.namespaces().deleteNamespace(namespace, false);
fail("should have failed due to namespace not empty");
} catch (PulsarAdminException e) {
// Expected: cannot delete non-empty tenant
Expand All @@ -1526,7 +1526,7 @@ public void testDeleteTenant() throws Exception {
assertTrue(admin.topics().getList(namespace).isEmpty());

// delete namespace
deleteNamespaceGraceFully(namespace, false);
deleteNamespaceWithRetry(namespace, false);
assertFalse(admin.namespaces().getNamespaces(tenant).contains(namespace));
assertTrue(admin.namespaces().getNamespaces(tenant).isEmpty());

Expand Down Expand Up @@ -1607,7 +1607,7 @@ public void testDeleteNamespace(NamespaceAttr namespaceAttr) throws Exception {
assertFalse(admin.topics().getList(namespace).isEmpty());

try {
deleteNamespaceGraceFully(namespace, false);
admin.namespaces().deleteNamespace(namespace, false);
fail("should have failed due to namespace not empty");
} catch (PulsarAdminException e) {
// Expected: cannot delete non-empty tenant
Expand All @@ -1618,7 +1618,7 @@ public void testDeleteNamespace(NamespaceAttr namespaceAttr) throws Exception {
assertTrue(admin.topics().getList(namespace).isEmpty());

// delete namespace
deleteNamespaceGraceFully(namespace, false);
deleteNamespaceWithRetry(namespace, false);
assertFalse(admin.namespaces().getNamespaces(tenant).contains(namespace));
assertTrue(admin.namespaces().getNamespaces(tenant).isEmpty());

Expand Down Expand Up @@ -1667,7 +1667,7 @@ public void testDeleteNamespaceWithTopicPolicies() throws Exception {
});
producer.close();
admin.topics().delete(topic);
deleteNamespaceGraceFully(namespace, false);
deleteNamespaceWithRetry(namespace, false);
Awaitility.await().untilAsserted(() -> {
assertTrue(admin.namespaces().getNamespaces(tenant).isEmpty());
});
Expand Down Expand Up @@ -1880,7 +1880,7 @@ public void testForceDeleteNamespace() throws Exception {
final String topic = "persistent://" + namespaceName + "/test" + UUID.randomUUID();
pulsarClient.newProducer(Schema.DOUBLE).topic(topic).create().close();
Awaitility.await().untilAsserted(() -> assertNotNull(admin.schemas().getSchemaInfo(topic)));
deleteNamespaceGraceFully(namespaceName, true);
deleteNamespaceWithRetry(namespaceName, true);
try {
admin.schemas().getSchemaInfo(topic);
Assert.fail("fail");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public void resetClusters() throws Exception {
pulsar.getConfiguration().setForceDeleteNamespaceAllowed(true);
for (String tenant : admin.tenants().getTenants()) {
for (String namespace : admin.namespaces().getNamespaces(tenant)) {
deleteNamespaceGraceFully(namespace, true);
deleteNamespaceWithRetry(namespace, true);
}
admin.tenants().deleteTenant(tenant, true);
}
Expand Down Expand Up @@ -297,7 +297,7 @@ public void clusters() throws Exception {
Awaitility.await()
.untilAsserted(() -> assertEquals(admin.clusters().getClusters(), List.of("test")));

deleteNamespaceGraceFully("prop-xyz/ns1", false);
deleteNamespaceWithRetry("prop-xyz/ns1", false);
admin.clusters().deleteCluster("test");
assertEquals(admin.clusters().getClusters(), new ArrayList<>());

Expand Down Expand Up @@ -526,7 +526,7 @@ public void brokers() throws Exception {
String.format("%s:%d", parts[0], pulsar.getListenPortHTTPS().get()));
Assert.assertEquals(nsMap2.size(), 2);

deleteNamespaceGraceFully("prop-xyz/ns1", false);
deleteNamespaceWithRetry("prop-xyz/ns1", false);
admin.clusters().deleteCluster("test");
assertEquals(admin.clusters().getClusters(), new ArrayList<>());
}
Expand Down Expand Up @@ -757,7 +757,7 @@ public void properties() throws Exception {
assertEquals(e.getStatusCode(), 409);
assertEquals(e.getMessage(), "The tenant still has active namespaces");
}
deleteNamespaceGraceFully("prop-xyz/ns1", false);
deleteNamespaceWithRetry("prop-xyz/ns1", false);
admin.tenants().deleteTenant("prop-xyz");
assertEquals(admin.tenants().getTenants(), new ArrayList<>());

Expand Down Expand Up @@ -786,7 +786,7 @@ public void namespaces() throws Exception {
assertEquals(admin.namespaces().getPolicies("prop-xyz/ns3").bundles.getNumBundles(), 4);
assertEquals(admin.namespaces().getPolicies("prop-xyz/ns3").bundles.getBoundaries().size(), 5);

deleteNamespaceGraceFully("prop-xyz/ns3", false);
deleteNamespaceWithRetry("prop-xyz/ns3", false);

try {
admin.namespaces().createNamespace("non-existing/ns1");
Expand Down Expand Up @@ -860,7 +860,7 @@ public void namespaces() throws Exception {
}
assertTrue(i < 10);

deleteNamespaceGraceFully("prop-xyz/ns1", false);
deleteNamespaceWithRetry("prop-xyz/ns1", false);
assertEquals(admin.namespaces().getNamespaces("prop-xyz"), List.of("prop-xyz/ns2"));

try {
Expand Down Expand Up @@ -1289,7 +1289,7 @@ public void testGetPartitionedStatsInternal() throws Exception {

@Test(dataProvider = "numBundles")
public void testDeleteNamespaceBundle(Integer numBundles) throws Exception {
deleteNamespaceGraceFully("prop-xyz/ns1", false);
deleteNamespaceWithRetry("prop-xyz/ns1", false);
admin.namespaces().createNamespace("prop-xyz/ns1-bundles", numBundles);
admin.namespaces().setNamespaceReplicationClusters("prop-xyz/ns1-bundles", Set.of("test"));

Expand All @@ -1301,7 +1301,7 @@ public void testDeleteNamespaceBundle(Integer numBundles) throws Exception {

assertEquals(admin.namespaces().getTopics("prop-xyz/ns1-bundles"), new ArrayList<>());

deleteNamespaceGraceFully("prop-xyz/ns1-bundles", false);
deleteNamespaceWithRetry("prop-xyz/ns1-bundles", false);
assertEquals(admin.namespaces().getNamespaces("prop-xyz", "test"), new ArrayList<>());
}

Expand Down Expand Up @@ -1388,14 +1388,14 @@ public void testDeleteNamespaceForcefully() throws Exception {
assertFalse(admin.topics().getList(namespace).isEmpty());

try {
deleteNamespaceGraceFully(namespace, false);
deleteNamespaceWithRetry(namespace, false);
fail("should have failed due to namespace not empty");
} catch (PulsarAdminException e) {
// Expected: cannot delete non-empty tenant
}

// delete namespace forcefully
deleteNamespaceGraceFully(namespace, true);
deleteNamespaceWithRetry(namespace, true);
assertFalse(admin.namespaces().getNamespaces(tenant).contains(namespace));
assertTrue(admin.namespaces().getNamespaces(tenant).isEmpty());

Expand Down Expand Up @@ -2287,7 +2287,7 @@ public void testBackwardCompatibility() throws Exception {
assertEquals(result.someNewIntField, 0);
assertNull(result.someNewString);

deleteNamespaceGraceFully("prop-xyz/ns1", false);
deleteNamespaceWithRetry("prop-xyz/ns1", false);
admin.tenants().deleteTenant("prop-xyz");
assertEquals(admin.tenants().getTenants(), new ArrayList<>());
}
Expand Down Expand Up @@ -3202,9 +3202,9 @@ public void testSubscriptionExpiry() throws Exception {
admin.topics().delete(topic1);
admin.topics().delete(topic2);
admin.topics().delete(topic3);
deleteNamespaceGraceFully(namespace1, false);
deleteNamespaceGraceFully(namespace2, false);
deleteNamespaceGraceFully(namespace3, false);
deleteNamespaceWithRetry(namespace1, false);
deleteNamespaceWithRetry(namespace2, false);
deleteNamespaceWithRetry(namespace3, false);
}

@Test
Expand All @@ -3217,11 +3217,11 @@ public void testCreateAndDeleteNamespaceWithBundles() throws Exception {
String ns = BrokerTestUtil.newUniqueName("prop-xyz/ns");

admin.namespaces().createNamespace(ns, 24);
deleteNamespaceGraceFully(ns, false);
deleteNamespaceWithRetry(ns, false);

// Re-create and re-delete
admin.namespaces().createNamespace(ns, 32);
deleteNamespaceGraceFully(ns, false);
deleteNamespaceWithRetry(ns, false);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ public void testDeleteNamespace() throws Exception {
admin.topics().delete("tenant1/ns1/foobar", true);

log.info("Deleting namespace");
deleteNamespaceGraceFully("tenant1/ns1", false, admin);
deleteNamespaceWithRetry("tenant1/ns1", false, admin);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ protected void setup() throws Exception {
protected void cleanup() throws Exception {
// cleanup.
admin.topics().delete(topicName);
deleteNamespaceGraceFully(namespaceName, false);
deleteNamespaceWithRetry(namespaceName, false);
admin.tenants().deleteTenant(tenantName);
admin.clusters().deleteCluster(clusterName);
// super cleanup.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1993,7 +1993,7 @@ private void cleanupNamespaceByNsCollection(Collection<String> namespaces)
if (StringUtils.isEmpty(ns)){
continue;
}
deleteNamespaceGraceFully(ns, true);
deleteNamespaceWithRetry(ns, true);
}
pulsar.getConfiguration().setForceDeleteNamespaceAllowed(forceDeleteNamespaceAllowedOriginalValue);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public void reset() throws Exception {
pulsar.getConfiguration().setForceDeleteNamespaceAllowed(true);
for (String tenant : admin.tenants().getTenants()) {
for (String namespace : admin.namespaces().getNamespaces(tenant)) {
deleteNamespaceGraceFully(namespace, true, admin, pulsar,
deleteNamespaceWithRetry(namespace, true, admin, pulsar,
mockPulsarSetup.getPulsar());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -671,34 +671,34 @@ public Map<Class<?>, Collection<Class<?>>> register(Object callback, Object... c
}

/**
* see {@link BrokerTestBase#deleteNamespaceGraceFully(String, boolean, PulsarAdmin, Collection)}
* see {@link BrokerTestBase#deleteNamespaceWithRetry(String, boolean, PulsarAdmin, Collection)}
*/
protected void deleteNamespaceGraceFully(String ns, boolean force)
protected void deleteNamespaceWithRetry(String ns, boolean force)
throws Exception {
BrokerTestBase.deleteNamespaceGraceFully(ns, force, admin, pulsar);
BrokerTestBase.deleteNamespaceWithRetry(ns, force, admin, pulsar);
}

/**
* see {@link BrokerTestBase#deleteNamespaceGraceFully(String, boolean, PulsarAdmin, Collection)}
* see {@link BrokerTestBase#deleteNamespaceWithRetry(String, boolean, PulsarAdmin, Collection)}
*/
protected void deleteNamespaceGraceFully(String ns, boolean force, PulsarAdmin admin)
protected void deleteNamespaceWithRetry(String ns, boolean force, PulsarAdmin admin)
throws Exception {
BrokerTestBase.deleteNamespaceGraceFully(ns, force, admin, pulsar);
BrokerTestBase.deleteNamespaceWithRetry(ns, force, admin, pulsar);
}

/**
* see {@link MockedPulsarServiceBaseTest#deleteNamespaceGraceFully(String, boolean, PulsarAdmin, Collection)}
* see {@link MockedPulsarServiceBaseTest#deleteNamespaceWithRetry(String, boolean, PulsarAdmin, Collection)}
*/
public static void deleteNamespaceGraceFully(String ns, boolean force, PulsarAdmin admin, PulsarService...pulsars)
public static void deleteNamespaceWithRetry(String ns, boolean force, PulsarAdmin admin, PulsarService...pulsars)
throws Exception {
deleteNamespaceGraceFully(ns, force, admin, Arrays.asList(pulsars));
deleteNamespaceWithRetry(ns, force, admin, Arrays.asList(pulsars));
}

/**
* Wait until system topic "__change_event" and subscription "__compaction" are created, and then delete the namespace.
*/
public static void deleteNamespaceGraceFully(String ns, boolean force, PulsarAdmin admin,
Collection<PulsarService> pulsars) throws Exception {
public static void deleteNamespaceWithRetry(String ns, boolean force, PulsarAdmin admin,
Collection<PulsarService> pulsars) throws Exception {
for (PulsarService pulsar : pulsars) {
// Prevents new events from triggering system topic creation.
CanPausedNamespaceService canPausedNamespaceService =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void unLoad(NamespaceBundle bundle) {
Assert.assertTrue(onLoad.get());
Assert.assertTrue(unLoad.get());
admin.topics().delete(topic);
deleteNamespaceGraceFully(namespace, false);
deleteNamespaceWithRetry(namespace, false);
}

@Test
Expand All @@ -120,7 +120,7 @@ public void testGetAllPartitions() throws Exception {
}

admin.topics().deletePartitionedTopic(topicName);
deleteNamespaceGraceFully(namespace, false);
deleteNamespaceWithRetry(namespace, false);
}

@Test
Expand Down Expand Up @@ -170,6 +170,6 @@ public boolean test(NamespaceBundle namespaceBundle) {
Assert.assertEquals(onLoad.get(), 1);
Assert.assertEquals(unLoad.get(), 1);
admin.topics().delete(topic);
deleteNamespaceGraceFully(namespace, false);
deleteNamespaceWithRetry(namespace, false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public void testResourceGroupAttachToNamespace() throws Exception {
assertNull(pulsar.getResourceGroupServiceManager()
.getNamespaceResourceGroup(NamespaceName.get(namespaceName))));

deleteNamespaceGraceFully(namespaceName, false);
deleteNamespaceWithRetry(namespaceName, false);
deleteResourceGroup(rgName);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,19 @@ public class BacklogQuotaManagerTest {
private static final int MAX_ENTRIES_PER_LEDGER = 5;

/**
* see {@link MockedPulsarServiceBaseTest#deleteNamespaceGraceFully(String, boolean, PulsarAdmin, Collection)}
* see {@link MockedPulsarServiceBaseTest#deleteNamespaceWithRetry(String, boolean, PulsarAdmin, Collection)}
*/
protected void deleteNamespaceGraceFully(String ns, boolean force)
throws Exception {
MockedPulsarServiceBaseTest.deleteNamespaceGraceFully(ns, force, admin, pulsar);
MockedPulsarServiceBaseTest.deleteNamespaceWithRetry(ns, force, admin, pulsar);
}

/**
* see {@link MockedPulsarServiceBaseTest#deleteNamespaceGraceFully(String, boolean, PulsarAdmin, Collection)}
* see {@link MockedPulsarServiceBaseTest#deleteNamespaceWithRetry(String, boolean, PulsarAdmin, Collection)}
*/
protected void deleteNamespaceGraceFully(String ns, boolean force, PulsarAdmin admin)
throws Exception {
MockedPulsarServiceBaseTest.deleteNamespaceGraceFully(ns, force, admin, pulsar);
MockedPulsarServiceBaseTest.deleteNamespaceWithRetry(ns, force, admin, pulsar);
}

@DataProvider(name = "backlogQuotaSizeGB")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void testRecreateNamespace() throws Exception {

// Delete and recreate with 32 bundles
admin.topics().delete(topic);
deleteNamespaceGraceFully(namespace, false);
deleteNamespaceWithRetry(namespace, false);
admin.namespaces().createNamespace(namespace, 32);

BundlesData bundlesData = admin.namespaces().getBundles(namespace);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ public void testMessageExpiry() throws Exception {
consumer.close();
admin.topics().deleteSubscription(topicName, subName);
admin.topics().delete(topicName);
deleteNamespaceGraceFully(namespaceName, false);
deleteNamespaceWithRetry(namespaceName, false);
}

@Test
Expand Down Expand Up @@ -1090,7 +1090,7 @@ public void testMessageExpiryWithTopicMessageTTL() throws Exception {
consumer.close();
admin.topics().deleteSubscription(topicName, subName);
admin.topics().delete(topicName);
deleteNamespaceGraceFully(namespaceName, true);
deleteNamespaceWithRetry(namespaceName, true);
} catch (PulsarAdminException e) {
Assert.assertEquals(e.getStatusCode(), 500);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,18 +333,18 @@ protected final void internalCleanup() {
}

/**
* see {@link BrokerTestBase#deleteNamespaceGraceFully(String, boolean, PulsarAdmin, Collection)}
* see {@link BrokerTestBase#deleteNamespaceWithRetry(String, boolean, PulsarAdmin, Collection)}
*/
protected void deleteNamespaceGraceFully(String ns, boolean force)
throws Exception {
MockedPulsarServiceBaseTest.deleteNamespaceGraceFully(ns, force, admin, pulsarServiceList);
MockedPulsarServiceBaseTest.deleteNamespaceWithRetry(ns, force, admin, pulsarServiceList);
}

/**
* see {@link MockedPulsarServiceBaseTest#deleteNamespaceGraceFully(String, boolean, PulsarAdmin, Collection)}
* see {@link MockedPulsarServiceBaseTest#deleteNamespaceWithRetry(String, boolean, PulsarAdmin, Collection)}
*/
protected void deleteNamespaceGraceFully(String ns, boolean force, PulsarAdmin admin)
throws Exception {
MockedPulsarServiceBaseTest.deleteNamespaceGraceFully(ns, force, admin, pulsarServiceList);
MockedPulsarServiceBaseTest.deleteNamespaceWithRetry(ns, force, admin, pulsarServiceList);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public void rest() throws Exception {

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

0 comments on commit 8dc781c

Please sign in to comment.