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 MySql
- Loading branch information
Showing
9 changed files
with
75 additions
and
60 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
54 changes: 54 additions & 0 deletions
54
...-driver-plugin-it/src/test/java/com/navercorp/pinpoint/plugin/jdbc/mysql/MySqlServer.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.mysql; | ||
|
||
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.MySQLContainer; | ||
import org.testcontainers.containers.output.OutputFrame; | ||
|
||
import java.util.Properties; | ||
import java.util.function.Consumer; | ||
|
||
public class MySqlServer implements SharedTestLifeCycle { | ||
private final Logger logger = LogManager.getLogger(getClass()); | ||
|
||
public static final String DATABASE_NAME = "test"; | ||
public static final String USERNAME = "root"; | ||
public static final String PASSWORD = ""; | ||
|
||
private MySQLContainer mysqlDB = new MySQLContainer(); | ||
|
||
@Override | ||
public Properties beforeAll() { | ||
Assume.assumeTrue("Docker not enabled", DockerClientFactory.instance().isDockerAvailable()); | ||
|
||
mysqlDB = new MySQLContainer(); | ||
mysqlDB.withLogConsumer(new Consumer<OutputFrame>() { | ||
@Override | ||
public void accept(OutputFrame outputFrame) { | ||
logger.info(outputFrame.getUtf8String()); | ||
} | ||
}); | ||
mysqlDB.withDatabaseName(DATABASE_NAME); | ||
mysqlDB.withUsername(USERNAME); | ||
mysqlDB.withPassword(PASSWORD); | ||
mysqlDB.withInitScript("init.sql"); | ||
// mysqlDB. | ||
mysqlDB.withUrlParam("serverTimezone", "UTC"); | ||
mysqlDB.withUrlParam("useSSL", "false"); | ||
mysqlDB.start(); | ||
|
||
Properties properties = new Properties(); | ||
properties.setProperty("JDBC_URL", mysqlDB.getJdbcUrl()); | ||
return properties; | ||
} | ||
|
||
@Override | ||
public void afterAll() { | ||
if (mysqlDB != null) { | ||
mysqlDB.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