Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OAK-11416: Docker support for oak-jcr tests with RdbDocumentStore nee… #2010

Merged
merged 3 commits into from
Jan 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
import java.sql.SQLException;
import java.time.Duration;
import java.time.Instant;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.regex.Matcher;
Expand All @@ -44,6 +47,7 @@ public class RdbConnectionUtils {
public static final String USERNAME = System.getProperty("rdb.jdbc-user", "sa");
mbaedke marked this conversation as resolved.
Show resolved Hide resolved
public static final String PASSWD = System.getProperty("rdb.jdbc-passwd", "");
public static final String IMG = System.getProperty("rdb.docker-image", "");
public static final Map<String, String> ENV = parseDockerEnv(System.getProperty("rdb.docker-env", ""));

private static final boolean RDB_AVAILABLE;
private static GenericContainer<?> rdbContainer;
Expand All @@ -67,6 +71,7 @@ public class RdbConnectionUtils {
if (RDB_AVAILABLE) {
rdbContainer = new GenericContainer<>(DockerImageName.parse(IMG))
.withPrivilegedMode(true)
.withEnv(ENV)
.withExposedPorts(exposedPort)
.withStartupTimeout(Duration.ofMinutes(15));
try {
Expand Down Expand Up @@ -148,4 +153,19 @@ private static boolean checkImageAvailability() throws TimeoutException {
private static boolean checkDockerAvailability() {
return DockerClientFactory.instance().isDockerAvailable();
}

private static Map<String, String> parseDockerEnv(String raw) {
Map<String, String> result = new HashMap<>();
StringTokenizer envTokenizer = new StringTokenizer(raw, ",");
while (envTokenizer.hasMoreTokens()) {
String token = envTokenizer.nextToken().trim();
StringTokenizer varTokenizer = new StringTokenizer(token, "=");
if (varTokenizer.countTokens() == 2) {
result.put(varTokenizer.nextToken(), varTokenizer.nextToken());
} else {
LOG.warn("Ignoring unexpected format of docker container environment variable: {}.", token);
}
}
return result;
}
}
Loading