Skip to content

Commit 329c8c0

Browse files
authored
[fix] [test] fix flaky test MetadataStoreStatsTest.testMetadataStoreStats (apache#19433)
1 parent 459a7a5 commit 329c8c0

File tree

4 files changed

+7
-1
lines changed

4 files changed

+7
-1
lines changed

managed-ledger/src/test/java/org/apache/bookkeeper/test/BookKeeperClusterTestCase.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ public void tearDown() throws Exception {
207207
}
208208
// stop zookeeper service
209209
try {
210+
// cleanup for metrics.
211+
metadataStore.close();
210212
stopZKCluster();
211213
} catch (Exception e) {
212214
LOG.error("Got Exception while trying to stop ZKCluster", e);

pulsar-metadata/src/test/java/org/apache/pulsar/metadata/CounterTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ public void testCounterDoesNotAutoReset(String provider, Supplier<String> urlSup
8787
// Delete all the empty container nodes
8888
zks.checkContainers();
8989

90+
@Cleanup
9091
MetadataStoreExtended store2 = MetadataStoreExtended.create(metadataUrl, MetadataStoreConfig.builder().build());
9192
@Cleanup
9293
CoordinationService cs2 = new CoordinationServiceImpl(store2);

pulsar-metadata/src/test/java/org/apache/pulsar/metadata/impl/MetadataStoreFactoryImplTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import static org.testng.Assert.assertEquals;
2222
import static org.testng.Assert.assertTrue;
23+
import lombok.Cleanup;
2324
import org.apache.pulsar.metadata.api.GetResult;
2425
import org.apache.pulsar.metadata.api.MetadataStore;
2526
import org.apache.pulsar.metadata.api.MetadataStoreConfig;
@@ -55,7 +56,8 @@ public void resetMetadataStoreProperty() {
5556

5657

5758
@Test
58-
public void testCreate() throws MetadataStoreException{
59+
public void testCreate() throws Exception{
60+
@Cleanup
5961
MetadataStore instance = MetadataStoreFactoryImpl.create(
6062
"custom://localhost",
6163
MetadataStoreConfig.builder().build());

pulsar-package-management/bookkeeper-storage/src/test/java/org/apache/pulsar/packages/management/storage/bookkeeper/bookkeeper/test/MockedBookKeeperTestCase.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ protected void stopBookKeeper() throws Exception {
131131
}
132132

133133
protected void stopMetadataStore() throws Exception {
134+
metadataStore.close();
134135
metadataStore.setAlwaysFail(new MetadataStoreException("error"));
135136
}
136137

0 commit comments

Comments
 (0)