Skip to content

Commit 1eb08ed

Browse files
authored
[fix][test] Deflake TopicPoliciesTest.setupTestTopic by retrying forced namespace deletion (#25974)
1 parent 65b4321 commit 1eb08ed

1 file changed

Lines changed: 5 additions & 10 deletions

File tree

pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/TopicPoliciesTest.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -175,16 +175,11 @@ void setupTestTopic() throws Exception {
175175
} catch (PulsarAdminException.NotFoundException e) {
176176
// topic may already be deleted
177177
}
178-
try {
179-
admin.namespaces().deleteNamespace(myNamespace, true);
180-
} catch (PulsarAdminException.NotFoundException e) {
181-
// namespace may already be deleted
182-
}
183-
try {
184-
admin.namespaces().deleteNamespace(myNamespaceV1, true);
185-
} catch (PulsarAdminException.NotFoundException e) {
186-
// namespace may already be deleted
187-
}
178+
// Use deleteNamespaceWithRetry since the forced namespace deletion can fail transiently with HTTP 422 when a
179+
// topic deletion in the cascade races with concurrent topic loading; the helper retries and treats an
180+
// already-deleted namespace as success.
181+
deleteNamespaceWithRetry(myNamespace, true);
182+
deleteNamespaceWithRetry(myNamespaceV1, true);
188183
admin.namespaces().createNamespace(testTenant + "/" + testNamespace, Set.of("test"));
189184
admin.namespaces().createNamespace(myNamespaceV1);
190185
admin.topics().createPartitionedTopic(testTopic, testTopicPartitions);

0 commit comments

Comments
 (0)