forked from pinpoint-apm/pinpoint
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[pinpoint-apm#8965] Apply SharedTestLifeCycle to Oracle
- Loading branch information
Showing
16 changed files
with
253 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
...-it/oracledb-it/src/test/java/com/navercorp/pinpoint/plugin/jdbc/oracle/OracleServer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package com.navercorp.pinpoint.plugin.jdbc.oracle; | ||
|
||
import com.navercorp.pinpoint.pluginit.jdbc.DriverProperties; | ||
import com.navercorp.pinpoint.pluginit.jdbc.JDBCDriverClass; | ||
import com.navercorp.pinpoint.pluginit.jdbc.testcontainers.DatabaseContainers; | ||
import com.navercorp.pinpoint.test.plugin.shared.SharedTestLifeCycle; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.junit.Assume; | ||
import org.testcontainers.DockerClientFactory; | ||
import org.testcontainers.containers.OracleContainer; | ||
import org.testcontainers.containers.wait.strategy.WaitStrategy; | ||
|
||
import java.time.Duration; | ||
import java.util.Objects; | ||
import java.util.Properties; | ||
|
||
public class OracleServer implements SharedTestLifeCycle { | ||
private final Logger logger = LogManager.getLogger(getClass()); | ||
private final String dockerImageVersion; | ||
private final WaitStrategy waitStrategy; | ||
|
||
private OracleContainer oracle; | ||
|
||
public OracleServer(String dockerImageVersion, WaitStrategy waitStrategy) { | ||
this.dockerImageVersion = Objects.requireNonNull(dockerImageVersion, "dockerImageVersion"); | ||
this.waitStrategy = Objects.requireNonNull(waitStrategy, "waitStrategy"); | ||
} | ||
|
||
@Override | ||
public Properties beforeAll() { | ||
Assume.assumeTrue("Docker not enabled", DockerClientFactory.instance().isDockerAvailable()); | ||
|
||
logger.info("Setting up oracle db... {}", dockerImageVersion); | ||
|
||
startOracleDB(dockerImageVersion, waitStrategy); | ||
logger.info("initSchema"); | ||
initSchema(); | ||
|
||
|
||
return DatabaseContainers.toProperties(oracle); | ||
} | ||
|
||
private void initSchema() { | ||
DriverProperties driverProperties = new DriverProperties(oracle.getJdbcUrl(), oracle.getUsername(), oracle.getPassword(), new Properties()); | ||
OracleItHelper helper = new OracleItHelper(driverProperties); | ||
JDBCDriverClass driverClass = new OracleJDBCDriverClass(); | ||
OracleJDBCApi JDBC_API = new OracleJDBCApi(driverClass); | ||
try { | ||
helper.create(JDBC_API); | ||
} catch (Exception e) { | ||
throw new RuntimeException("schema init error", e); | ||
} | ||
} | ||
|
||
private void startOracleDB(String dockerImageVersion, WaitStrategy waitStrategy) { | ||
Assume.assumeTrue("Docker not enabled", DockerClientFactory.instance().isDockerAvailable()); | ||
oracle = new OracleContainerWithWait(dockerImageVersion); | ||
|
||
if (waitStrategy != null) { | ||
oracle.setWaitStrategy(waitStrategy); | ||
oracle.withStartupTimeout(Duration.ofSeconds(300)); | ||
oracle.addEnv("DBCA_ADDITIONAL_PARAMS", "-initParams sga_target=0M pga_aggreegate_target=0M"); | ||
oracle.withReuse(true); | ||
} | ||
|
||
oracle.start(); | ||
} | ||
|
||
@Override | ||
public void afterAll() { | ||
if (oracle != null) { | ||
oracle.stop(); | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
.../oracledb-it/src/test/java/com/navercorp/pinpoint/plugin/jdbc/oracle/OracleServer11x.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.navercorp.pinpoint.plugin.jdbc.oracle; | ||
|
||
import org.testcontainers.containers.wait.strategy.Wait; | ||
|
||
public class OracleServer11x extends OracleServer { | ||
public OracleServer11x() { | ||
super(OracleITConstants.ORACLE_11_X_IMAGE, Wait.defaultWaitStrategy()); | ||
} | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
.../oracledb-it/src/test/java/com/navercorp/pinpoint/plugin/jdbc/oracle/OracleServer12x.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.navercorp.pinpoint.plugin.jdbc.oracle; | ||
|
||
import org.testcontainers.containers.wait.strategy.Wait; | ||
|
||
public class OracleServer12x extends OracleServer { | ||
public OracleServer12x() { | ||
super(OracleITConstants.ORACLE_12_X_IMAGE, Wait.forLogMessage(".*Database ready to use.*\\n", 1)); | ||
} | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
.../oracledb-it/src/test/java/com/navercorp/pinpoint/plugin/jdbc/oracle/OracleServer19x.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.navercorp.pinpoint.plugin.jdbc.oracle; | ||
|
||
import org.testcontainers.containers.wait.strategy.Wait; | ||
|
||
public class OracleServer19x extends OracleServer { | ||
public OracleServer19x() { | ||
super(OracleITConstants.ORACLE_18_X_IMAGE, Wait.forLogMessage(".*Completed.*", 1)); | ||
} | ||
|
||
} |
Oops, something went wrong.