You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by mr...@apache.org on 2023/06/19 07:13:53 UTC
[jackrabbit-oak] branch trunk updated: OAK-10308: Tests using MongoUtils may skip even if Docker is available
This is an automated email from the ASF dual-hosted git repository.
mreutegg pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
The following commit(s) were added to refs/heads/trunk by this push:
new 2283639e03 OAK-10308: Tests using MongoUtils may skip even if Docker is available
new 755416d158 Merge pull request #990 from mreutegg/OAK-10308
2283639e03 is described below
commit 2283639e0359a38ffb900150bf7ba93e0b6616d2
Author: Marcel Reutegger <ma...@gmail.com>
AuthorDate: Thu Jun 15 17:36:25 2023 +0200
OAK-10308: Tests using MongoUtils may skip even if Docker is available
---
.../java/org/apache/jackrabbit/oak/plugins/document/MongoUtils.java | 5 ++++-
.../jackrabbit/oak/plugins/document/mongo/MongoDockerRule.java | 4 ++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/MongoUtils.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/MongoUtils.java
index 3178590eab..0e44843ec4 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/MongoUtils.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/MongoUtils.java
@@ -19,6 +19,7 @@ package org.apache.jackrabbit.oak.plugins.document;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
import org.apache.jackrabbit.oak.plugins.document.mongo.MongoDockerRule;
import org.apache.jackrabbit.oak.plugins.document.util.MongoConnection;
@@ -70,15 +71,17 @@ public class MongoUtils {
// fallback to docker based MongoDB if available
MongoDockerRule dockerRule = new MongoDockerRule();
if (MongoDockerRule.isDockerAvailable()) {
+ AtomicReference<String> host = new AtomicReference<>();
AtomicInteger port = new AtomicInteger();
try {
dockerRule.apply(new Statement() {
@Override
public void evaluate() {
+ host.set(dockerRule.getHost());
port.set(dockerRule.getPort());
}
}, Description.EMPTY).evaluate();
- mongoUrl = "mongodb://localhost:" + port.get() + "/" + DB + "?" + OPTIONS;
+ mongoUrl = "mongodb://" + host + ":" + port.get() + "/" + DB + "?" + OPTIONS;
} catch (Throwable t) {
LOG.warn("Unable to get MongoDB port from Docker", t);
}
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDockerRule.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDockerRule.java
index b983e4e910..114755ccb6 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDockerRule.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDockerRule.java
@@ -103,6 +103,10 @@ public class MongoDockerRule implements TestRule {
return wrappedRule.getContainer().getPortBinding("27017/tcp").getPort();
}
+ public String getHost() {
+ return wrappedRule.getContainer().getPortBinding("27017/tcp").getHost();
+ }
+
public static boolean isDockerAvailable() {
return DOCKER_AVAILABLE;
}