MongoDocumentStoreMetricsTest fails sporadically
@@ -25,6 +25,7 @@ import java.util.concurrent.TimeUnit;
import org.apache.jackrabbit.oak.plugins.document.AbstractMongoConnectionTest;
import org.apache.jackrabbit.oak.plugins.document.Collection;
import org.apache.jackrabbit.oak.plugins.document.UpdateOp;
+import org.apache.jackrabbit.oak.plugins.document.util.MongoConnection;
import org.apache.jackrabbit.oak.stats.DefaultStatisticsProvider;
import org.apache.jackrabbit.oak.stats.StatisticsProvider;
import org.junit.After;
@@ -34,6 +35,7 @@ import static org.apache.jackrabbit.oak.plugins.document.mongo.MongoDocumentNode
import static org.apache.jackrabbit.oak.stats.StatsOptions.METRICS_ONLY;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeNotNull;
public class MongoDocumentStoreMetricsTest extends AbstractMongoConnectionTest {
@@ -48,9 +50,12 @@ public class MongoDocumentStoreMetricsTest extends AbstractMongoConnectionTest {
}
@Test
- public void updateCounters() throws Exception {
+ public void updateCounters() {
+ MongoConnection connection = connectionFactory.getConnection();
+ assumeNotNull(connection);
MongoDocumentStore store = new MongoDocumentStore(
- mongoConnection.getDB(), newMongoDocumentNodeStoreBuilder());
+ connection.getDB(), newMongoDocumentNodeStoreBuilder());
+ try {
MongoDocumentStoreMetrics metrics = new MongoDocumentStoreMetrics(store, statsProvider);
metrics.run();
// document for root node
@@ -66,6 +71,9 @@ public class MongoDocumentStoreMetricsTest extends AbstractMongoConnectionTest {
metrics.run();
assertEquals(11, getCount("MongoDB.nodes.count"));
+ } finally {
+ store.dispose();
+ }
}
private long getCount(String name) {
