Skip to content

Commit

Permalink
OAK-11062: document-store: refine skipping of MongoDB tests (MongoCon…
Browse files Browse the repository at this point in the history
…nectionFactory) (#1677)
  • Loading branch information
reschke authored Sep 1, 2024
1 parent 8629b87 commit 6c84e5c
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@
import java.util.List;

import org.apache.jackrabbit.guava.common.collect.Lists;

import org.apache.jackrabbit.oak.commons.properties.SystemPropertySupplier;
import org.apache.jackrabbit.oak.plugins.document.mongo.MongoDockerRule;
import org.apache.jackrabbit.oak.plugins.document.util.MongoConnection;
import org.jetbrains.annotations.Nullable;
import org.junit.rules.ExternalResource;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static org.junit.Assume.assumeFalse;
import static org.junit.Assume.assumeNotNull;

public class MongoConnectionFactory extends ExternalResource {
Expand All @@ -35,6 +38,10 @@ public class MongoConnectionFactory extends ExternalResource {

private final List<MongoConnection> connections = Lists.newArrayList();

private static final Logger LOG = LoggerFactory.getLogger(MongoConnectionFactory.class);

private static final boolean SKIP_MONGO = SystemPropertySupplier.create("oak.skipMongo", false).loggingTo(LOG).get();

@Override
public Statement apply(Statement base, Description description) {
Statement s = super.apply(base, description);
Expand All @@ -51,6 +58,8 @@ public MongoConnection getConnection() {

@Nullable
public MongoConnection getConnection(String dbName) {
// skip test when told so (OAK-11062)
assumeFalse(SKIP_MONGO);
// first try MongoDB running on configured host and port
MongoConnection c = MongoUtils.getConnection(dbName);
if (c == null && MongoDockerRule.isDockerAvailable()) {
Expand Down

0 comments on commit 6c84e5c

Please sign in to comment.