Skip to content

Commit ee7dc68

Browse files
authored
[fix][test] Make NamespacesTest.cleanupAfterMethod tolerant of transient infra failures (#25641)
1 parent 6edd35d commit ee7dc68

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,18 @@ public void cleanup() throws Exception {
186186
}
187187

188188
@AfterMethod(alwaysRun = true)
189-
public void cleanupAfterMethod() throws Exception{
190-
// cleanup.
189+
public void cleanupAfterMethod() {
190+
// Best-effort cleanup. Transient infra failures (e.g. ZK session expiry from a
191+
// long-running test or GC pause) can make the admin call fail here; log and
192+
// continue so the test method's actual result is preserved.
191193
Set<String> existsNsSetAferSetup = Stream.concat(testLocalNamespaces.stream(), testGlobalNamespaces.stream())
192194
.map(Objects::toString).collect(Collectors.toSet());
193-
cleanupNamespaceByPredicate(this.testTenant, v -> !existsNsSetAferSetup.contains(v));
194-
cleanupNamespaceByPredicate(this.testOtherTenant, v -> !existsNsSetAferSetup.contains(v));
195+
try {
196+
cleanupNamespaceByPredicate(this.testTenant, v -> !existsNsSetAferSetup.contains(v));
197+
cleanupNamespaceByPredicate(this.testOtherTenant, v -> !existsNsSetAferSetup.contains(v));
198+
} catch (Exception e) {
199+
log.warn().exception(e).log("Failed to clean up namespaces after test method");
200+
}
195201
}
196202

197203
protected void customizeNewPulsarClientBuilder(ClientBuilder clientBuilder) {

0 commit comments

Comments
 (0)