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 MariaDB
- Loading branch information
Showing
8 changed files
with
80 additions
and
54 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
...ns-it/mariadb-jdbc-it/src/test/java/com/navercorp/pinpoint/plugin/jdbc/MariaDBServer.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,54 @@ | ||
package com.navercorp.pinpoint.plugin.jdbc; | ||
|
||
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.MariaDBContainer; | ||
import org.testcontainers.containers.output.OutputFrame; | ||
|
||
import java.util.Properties; | ||
import java.util.function.Consumer; | ||
|
||
public class MariaDBServer implements SharedTestLifeCycle { | ||
private final Logger logger = LogManager.getLogger(getClass()); | ||
private MariaDBContainer mariaDB; | ||
|
||
public static final String DATABASE_NAME = "test"; | ||
public static final String USERNAME = "root"; | ||
public static final String PASSWORD = ""; | ||
|
||
@Override | ||
public Properties beforeAll() { | ||
Assume.assumeTrue("Docker not enabled", DockerClientFactory.instance().isDockerAvailable()); | ||
|
||
mariaDB = new MariaDBContainer(); | ||
mariaDB.withLogConsumer(new Consumer<OutputFrame>() { | ||
@Override | ||
public void accept(OutputFrame outputFrame) { | ||
logger.info(outputFrame.getUtf8String()); | ||
} | ||
}); | ||
mariaDB.withDatabaseName(DATABASE_NAME); | ||
mariaDB.withUsername(USERNAME); | ||
mariaDB.withPassword(PASSWORD); | ||
mariaDB.withInitScript("jdbc/mariadb/init.sql"); | ||
// mariaDB.withUrlParam("noAccessToProcedureBodies", "true"); | ||
mariaDB.start(); | ||
|
||
int port = mariaDB.getMappedPort(3306); | ||
Properties properties = new Properties(); | ||
properties.setProperty("JDBC_URL", mariaDB.getJdbcUrl()); | ||
properties.setProperty("URL", mariaDB.getHost() + ":" + port); | ||
|
||
return properties; | ||
} | ||
|
||
@Override | ||
public void afterAll() { | ||
if (mariaDB != null) { | ||
mariaDB.stop(); | ||
} | ||
} | ||
} |
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