提交 635cb472 编写于 作者: G Ga Lam CHOI 提交者: ga-ram

[#7666] Added oracle container wait strategy

上级 6f3fda9e
......@@ -31,6 +31,7 @@
<properties>
<jdk.version>1.8</jdk.version>
<jdk.home>${env.JAVA_8_HOME}</jdk.home>
<plugin.animal-sniffer.skip>true</plugin.animal-sniffer.skip>
</properties>
<dependencies>
......
......@@ -40,7 +40,7 @@ public class Oracle11_Ojdbc6_IT extends Oracle_IT_Base {
@BeforeClass
public static void setup() throws Exception {
logger.info("Setting up oracle db...");
startOracleDB(OracleITConstants.ORACLE_11_X_IMAGE, logger);
startOracleDB(OracleITConstants.ORACLE_11_X_IMAGE);
helper.create(JDBC_API);
}
......
......@@ -18,10 +18,12 @@ package com.navercorp.pinpoint.plugin.jdbc.oracle;
import com.navercorp.pinpoint.pluginit.jdbc.*;
import com.navercorp.pinpoint.pluginit.utils.AgentPath;
import com.navercorp.pinpoint.test.plugin.*;
import org.junit.*;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.containers.wait.strategy.Wait;
@RunWith(PinpointPluginTestSuite.class)
@PinpointAgent(AgentPath.PATH)
......@@ -34,7 +36,9 @@ public class Oracle12_18_Ojdbc8_IT extends Oracle_IT_Base{
@BeforeClass
public static void setup() throws Exception {
logger.info("Setting up oracle db...");
startOracleDB(OracleITConstants.ORACLE_12_X_IMAGE, logger);
startOracleDB(OracleITConstants.ORACLE_12_X_IMAGE, Wait.forLogMessage(".*Database ready to use.*\\n", 1));
helper.create(JDBC_API);
}
......
......@@ -18,10 +18,12 @@ package com.navercorp.pinpoint.plugin.jdbc.oracle;
import com.navercorp.pinpoint.pluginit.jdbc.*;
import com.navercorp.pinpoint.pluginit.utils.AgentPath;
import com.navercorp.pinpoint.test.plugin.*;
import org.junit.*;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.containers.wait.strategy.Wait;
@RunWith(PinpointPluginTestSuite.class)
@PinpointAgent(AgentPath.PATH)
......@@ -35,7 +37,7 @@ public class Oracle19_Ojdbc10_IT extends Oracle_IT_Base {
@BeforeClass
public static void setup() throws Exception {
logger.info("Setting up oracle db...");
startOracleDB(OracleITConstants.ORACLE_18_X_IMAGE, logger);
startOracleDB(OracleITConstants.ORACLE_18_X_IMAGE, Wait.forLogMessage(".*Completed.*", 1));
helper.create(JDBC_API);
}
......
......@@ -23,6 +23,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.containers.wait.strategy.Wait;
@RunWith(PinpointPluginTestSuite.class)
@PinpointAgent(AgentPath.PATH)
......@@ -36,7 +37,7 @@ public class Oracle19_Ojdbc10_IT_ConnectWithGssCredential_IT extends Oracle_IT_B
@BeforeClass
public static void setup() throws Exception {
logger.info("Setting up oracle db...");
startOracleDB(OracleITConstants.ORACLE_18_X_IMAGE, logger);
startOracleDB(OracleITConstants.ORACLE_18_X_IMAGE, Wait.forLogMessage(".*Completed.*", 1));
helper.create(JDBC_API);
}
......
......@@ -18,10 +18,12 @@ package com.navercorp.pinpoint.plugin.jdbc.oracle;
import com.navercorp.pinpoint.pluginit.jdbc.*;
import com.navercorp.pinpoint.pluginit.utils.AgentPath;
import com.navercorp.pinpoint.test.plugin.*;
import org.junit.*;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.containers.wait.strategy.Wait;
@RunWith(PinpointPluginTestSuite.class)
@PinpointAgent(AgentPath.PATH)
......@@ -34,7 +36,7 @@ public class Oracle19_Ojdbc8_ConnectWithGssCredential_IT extends Oracle_IT_Base
@BeforeClass
public static void setup() throws Exception {
logger.info("Setting up oracle db...");
startOracleDB(OracleITConstants.ORACLE_18_X_IMAGE, logger);
startOracleDB(OracleITConstants.ORACLE_18_X_IMAGE, Wait.forLogMessage(".*Completed.*", 1));
helper.create(JDBC_API);
}
......
......@@ -18,10 +18,12 @@ package com.navercorp.pinpoint.plugin.jdbc.oracle;
import com.navercorp.pinpoint.pluginit.jdbc.*;
import com.navercorp.pinpoint.pluginit.utils.AgentPath;
import com.navercorp.pinpoint.test.plugin.*;
import org.junit.*;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.containers.wait.strategy.Wait;
@RunWith(PinpointPluginTestSuite.class)
@PinpointAgent(AgentPath.PATH)
......@@ -34,7 +36,7 @@ public class Oracle19_Ojdbc8_IT extends Oracle_IT_Base {
@BeforeClass
public static void setup() throws Exception {
logger.info("Setting up oracle db...");
startOracleDB(OracleITConstants.ORACLE_18_X_IMAGE, logger);
startOracleDB(OracleITConstants.ORACLE_18_X_IMAGE, Wait.forLogMessage(".*Completed.*", 1));
helper.create(JDBC_API);
}
......
package com.navercorp.pinpoint.plugin.jdbc.oracle;
import org.testcontainers.containers.OracleContainer;
import org.testcontainers.containers.wait.strategy.WaitStrategy;
public class OracleContainerWithWait extends OracleContainer {
public OracleContainerWithWait(String dockerImageVersion) {
super(dockerImageVersion);
}
@Override
protected void waitUntilContainerStarted() {
// wait for Oracle to be fully initialized
WaitStrategy waitStrategy = getWaitStrategy();
if (waitStrategy != null) {
waitStrategy.waitUntilReady(this);
}
// now, the JDBC connection should definitely work without lots of wasteful polling
super.waitUntilContainerStarted();
}
}
......@@ -23,21 +23,40 @@ import org.junit.Before;
import org.slf4j.Logger;
import org.testcontainers.DockerClientFactory;
import org.testcontainers.containers.OracleContainer;
import org.testcontainers.containers.startupcheck.MinimumDurationRunningStartupCheckStrategy;
import org.testcontainers.containers.wait.strategy.HostPortWaitStrategy;
import org.testcontainers.containers.wait.strategy.WaitStrategy;
import java.sql.Driver;
import java.sql.DriverManager;
import java.time.Duration;
import java.util.Properties;
public abstract class Oracle_IT_Base {
private static final JDBCDriverClass driverClass = new OracleJDBCDriverClass();
protected static final OracleJDBCApi JDBC_API = new OracleJDBCApi(driverClass);
protected static OracleItHelper helper;
public static OracleContainer oracle;
public static OracleContainerWithWait oracle;
public static void startOracleDB(String dockerImageVersion, Logger logger) {
Assume.assumeTrue("Docker not enabled", DockerClientFactory.instance().isDockerAvailable());
public static void startOracleDB(String dockerImageVersion) {
oracle = new OracleContainerWithWait(dockerImageVersion);
startOracleDBContainer();
}
public static void startOracleDB(String dockerImageVersion, WaitStrategy waitStrategy) {
oracle = new OracleContainerWithWait(dockerImageVersion);
if (waitStrategy != null) {
oracle.setWaitStrategy(waitStrategy);
oracle.withStartupTimeout(Duration.ofSeconds(180));
oracle.withReuse(true);
}
startOracleDBContainer();
}
oracle = new OracleContainer(dockerImageVersion);
private static void startOracleDBContainer() {
Assume.assumeTrue("Docker not enabled", DockerClientFactory.instance().isDockerAvailable());
oracle.start();
DriverProperties driverProperties = new DriverProperties(oracle.getJdbcUrl(), oracle.getUsername(), oracle.getPassword(), new Properties());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册