Skip to content
Snippets Groups Projects
Commit 0ad49003 authored by Vincent Massol's avatar Vincent Massol
Browse files

[Misc] Added comments for the DOOD use case

parent 154ca702
No related branches found
No related tags found
No related merge requests found
......@@ -72,8 +72,12 @@ protected void start(GenericContainer container, TestConfiguration testConfigura
protected void mountFromHostToContainer(GenericContainer container, String sourceDirectory,
String targetDirectory)
{
// File mounting is awfully slow on Mac OSX. For example starting Tomcat with XWiki mounted takes
// Note 1: File mounting is awfully slow on Mac OSX. For example starting Tomcat with XWiki mounted takes
// 45s+, while doing a COPY first and then starting Tomcat takes 8s (+5s for the copy).
// Note 2: For the DOOD use case, we also do the copy instead of the volume mounting since that would require
// to have the sourceDirectory path mounted from the host and this would put and leave files on the host which
// would not work with parallel executions (think about multiple CI jobs executing in parallel on the same host)
// and would also not be clean.
String osName = System.getProperty("os.name").toLowerCase();
if (IN_A_CONTAINER || osName.startsWith("mac os x")) {
MountableFile mountableDirectory = MountableFile.forHostPath(sourceDirectory);
......
......@@ -105,11 +105,7 @@ private void startMySQLContainer(JdbcDatabaseContainer databaseContainer, TestCo
.withUsername(DBUSERNAME)
.withPassword(DBPASSWORD);
if (testConfiguration.isDatabaseDataSaved()) {
// This allows re-running the test with the database already provisioned without having to redo
// the provisioning. Running "mvn clean" will remove the database data.
databaseContainer.withFileSystemBind("./target/mysql", "/var/lib/mysql");
}
mountDatabaseDataIfNeeded(databaseContainer, "./target/mysql", "/var/lib/mysql", testConfiguration);
// Note: the "explicit-defaults-for-timestamp" parameter has been introduced in MySQL 5.6.6+ only and using it
// in older versions make MySQL fail to start.
......@@ -176,11 +172,8 @@ private void startPostgreSQLContainer(TestConfiguration testConfiguration)
.withUsername(DBUSERNAME)
.withPassword(DBPASSWORD);
if (testConfiguration.isDatabaseDataSaved()) {
// This allows re-running the test with the database already provisioned without having to redo
// the provisioning. Running "mvn clean" will remove the database data.
databaseContainer.withFileSystemBind("./target/postgres", "/var/lib/postgresql/data");
}
mountDatabaseDataIfNeeded(databaseContainer, "./target/postgres", "/var/lib/postgresql/data",
testConfiguration);
databaseContainer.addEnv("POSTGRES_ROOT_PASSWORD", DBPASSWORD);
databaseContainer.addEnv("POSTGRES_INITDB_ARGS", "--encoding=UTF8");
......@@ -188,6 +181,19 @@ private void startPostgreSQLContainer(TestConfiguration testConfiguration)
startDatabaseContainer(databaseContainer, 5432, testConfiguration);
}
private void mountDatabaseDataIfNeeded(JdbcDatabaseContainer databaseContainer, String hostPath,
String containerPath, TestConfiguration testConfiguration)
{
if (testConfiguration.isDatabaseDataSaved()) {
// Note 1: This allows re-running the test with the database already provisioned without having to redo
// the provisioning. Running "mvn clean" will remove the database data.
// Note 2: This won't work in the DOOD use case. For that to work we would need to copy the data instead
// of mounting the volume but the time to do that would be counter productive and cost in execution time
// when the goal is to win time...
databaseContainer.withFileSystemBind(hostPath, containerPath);
}
}
private void startOracleContainer(TestConfiguration testConfiguration)
{
JdbcDatabaseContainer databaseContainer;
......
......@@ -157,6 +157,8 @@ private void startContainer()
.forStatusCode(200).withStartupTimeout(Duration.of(480, SECONDS)));
if (this.testConfiguration.isOffline()) {
// Note: This won't work in the DOOD use case. For that to work we would need to copy the data instead
// of mounting the volume but the time it would take would be too costly.
String repoLocation = this.repositoryResolver.getSession().getLocalRepository().getBasedir().toString();
this.servletContainer.withFileSystemBind(repoLocation, "/root/.m2/repository");
}
......@@ -165,9 +167,13 @@ private void startContainer()
// inside the container
String cloverDatabase = System.getProperty("maven.clover.cloverDatabase");
if (cloverDatabase != null) {
// Note: The Clover instrumentation puts the full path to the clover database location inside the java
// Note 1: The Clover instrumentation puts the full path to the clover database location inside the java
// source files which execute inside the docker container. Thus we need to make that exact same full path
// available inside the container...
// Note 2: For this to work in DOOD (Docker Outside Of Docker), the container in which this code is
// running will need to have mapped the volume pointed to by the "maven.clover.cloverDatabase" system
// property. It'll also need to make sure that it's removed before the build executes so that it doesn't
// execute with Clover data from a previous run.
this.servletContainer.withFileSystemBind(cloverDatabase, cloverDatabase);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment