forked from pinpoint-apm/pinpoint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[pinpoint-apm#11681] add dameng-jdbc plugin
- Loading branch information
Showing
25 changed files
with
1,559 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Copyright 2024 NAVER Corp. | ||
~ | ||
~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
~ you may not use this file except in compliance with the License. | ||
~ You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
--> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>com.navercorp.pinpoint</groupId> | ||
<artifactId>pinpoint-plugins-it</artifactId> | ||
<version>3.1.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>pinpoint-dameng-jdbc-driver-plugin-it</artifactId> | ||
|
||
<packaging>jar</packaging> | ||
|
||
<properties> | ||
<jdk.version>1.8</jdk.version> | ||
<jdk.home>${env.JAVA_8_HOME}</jdk.home> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.dameng</groupId> | ||
<artifactId>DmJdbcDriver18</artifactId> | ||
</dependency> | ||
<!-- testcontainers --> | ||
<dependency> | ||
<groupId>org.testcontainers</groupId> | ||
<artifactId>testcontainers</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.navercorp.pinpoint</groupId> | ||
<artifactId>pinpoint-plugin-it-utils</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.navercorp.pinpoint</groupId> | ||
<artifactId>pinpoint-plugin-it-utils-jdbc</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.navercorp.pinpoint</groupId> | ||
<artifactId>pinpoint-dameng-jdbc-driver-plugin</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<skip>true</skip> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
<configuration> | ||
<jvm>${env.JAVA_8_HOME}/bin/java</jvm> | ||
<testFailureIgnore>true</testFailureIgnore> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
103 changes: 103 additions & 0 deletions
103
...s-it/dameng-jdbc-it/src/test/java/com/navercorp/pinpoint/it/plugin/jdbc/DamengServer.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,103 @@ | ||
package com.navercorp.pinpoint.it.plugin.jdbc; | ||
|
||
import com.navercorp.pinpoint.it.plugin.utils.LogOutputStream; | ||
import com.navercorp.pinpoint.it.plugin.utils.jdbc.DriverProperties; | ||
import com.navercorp.pinpoint.test.plugin.shared.SharedTestLifeCycle; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.apache.logging.log4j.util.Strings; | ||
import org.junit.jupiter.api.Assumptions; | ||
import org.testcontainers.DockerClientFactory; | ||
import org.testcontainers.containers.Container; | ||
import org.testcontainers.containers.GenericContainer; | ||
import org.testcontainers.containers.wait.strategy.Wait; | ||
import org.testcontainers.images.builder.Transferable; | ||
import org.testcontainers.utility.DockerImageName; | ||
import org.testcontainers.utility.MountableFile; | ||
|
||
import java.util.Properties; | ||
|
||
/** | ||
* @author yjqg6666 | ||
*/ | ||
public class DamengServer implements SharedTestLifeCycle { | ||
private final Logger logger = LogManager.getLogger(getClass()); | ||
|
||
public static final DockerImageName DM_IMAGE = DockerImageName.parse("yjqg6666/dameng-server:v8-20240715"); | ||
|
||
private GenericContainer<?> dm; | ||
|
||
protected static final String USER = "SYSDBA"; | ||
protected static final String PASSWORD = "SYSDBA001"; | ||
private static final int PORT = 5236; | ||
|
||
@Override | ||
public Properties beforeAll() { | ||
Assumptions.assumeTrue(DockerClientFactory.instance().isDockerAvailable(), "Docker not enabled"); | ||
|
||
dm = new GenericContainer(DM_IMAGE) | ||
.withExposedPorts(PORT) | ||
.withPrivilegedMode(true) | ||
.withReuse(false) | ||
.withEnv("LD_LIBRARY_PATH", "/opt/dmdbms/bin") | ||
.withEnv("UNICODE_FLAG", "1") | ||
.withEnv("INSTANCE_NAME", "DM8CI") | ||
.waitingFor(Wait.forLogMessage(".*SYSTEM IS READY.*\\n", 1)); | ||
dm.withLogConsumer(new LogOutputStream(logger::info)); | ||
dm.start(); | ||
|
||
sourceInitSql(); | ||
|
||
int port = dm.getMappedPort(PORT); | ||
String url = "jdbc:dm://" + dm.getHost() + ":" + port; | ||
System.setProperty(DriverProperties.URL, url); | ||
System.setProperty(DriverProperties.HOST, dm.getHost()); | ||
System.setProperty(DriverProperties.PORT, String.valueOf(port)); | ||
System.setProperty(DriverProperties.USER, USER); | ||
System.setProperty(DriverProperties.PASSWARD, PASSWORD); | ||
|
||
Properties properties = new Properties(); | ||
properties.setProperty(DriverProperties.URL, url); | ||
properties.setProperty(DriverProperties.HOST, dm.getHost()); | ||
properties.setProperty(DriverProperties.PORT, String.valueOf(port)); | ||
properties.setProperty(DriverProperties.USER, USER); | ||
properties.setProperty(DriverProperties.PASSWARD, PASSWORD); | ||
return properties; | ||
} | ||
|
||
@Override | ||
public void afterAll() { | ||
if (dm != null) { | ||
dm.stop(); | ||
} | ||
} | ||
|
||
private void sourceInitSql() { | ||
|
||
String dst = "/tmp/citest_init.sql"; | ||
dm.copyFileToContainer(MountableFile.forClasspathResource("jdbc/dameng/init.sql"), dst); | ||
|
||
String cmd = "/tmp/citest_init_sql"; | ||
String content = String.format("#!/bin/sh\n/opt/dmdbms/bin/disql %s/%s < %s", USER, PASSWORD, dst); | ||
int filemode = 000755; //can not be 755 in oct. | ||
dm.copyFileToContainer(Transferable.of(content, filemode), cmd); | ||
|
||
boolean ok = true; | ||
String msg = Strings.EMPTY; | ||
try { | ||
Container.ExecResult execResult = dm.execInContainer(cmd); | ||
if (execResult.getExitCode() != 0) { | ||
ok = false; | ||
msg = execResult.getStderr(); | ||
} | ||
System.out.println(execResult.getStdout()); | ||
} catch (Exception e) { | ||
ok = false; | ||
msg = e.getMessage(); | ||
} | ||
if (!ok) { | ||
System.err.println("Source init.sql failed, cause:" + msg); | ||
} | ||
} | ||
|
||
} |
57 changes: 57 additions & 0 deletions
57
...ng-jdbc-it/src/test/java/com/navercorp/pinpoint/it/plugin/jdbc/Dameng_18_DriverClass.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,57 @@ | ||
/* | ||
* Copyright 2024 NAVER Corp. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.navercorp.pinpoint.it.plugin.jdbc; | ||
|
||
import com.navercorp.pinpoint.it.plugin.utils.jdbc.AbstractJDBCDriverClass; | ||
|
||
import java.sql.CallableStatement; | ||
import java.sql.Connection; | ||
import java.sql.Driver; | ||
import java.sql.PreparedStatement; | ||
import java.sql.Statement; | ||
|
||
/** | ||
* @author yjqg6666 | ||
*/ | ||
public class Dameng_18_DriverClass extends AbstractJDBCDriverClass { | ||
|
||
@Override | ||
public Class<Driver> getDriver() { | ||
return forName("dm.jdbc.driver.DmDriver"); | ||
} | ||
|
||
@Override | ||
public Class<Connection> getConnection() { | ||
return forName("dm.jdbc.driver.DmdbConnection"); | ||
} | ||
|
||
@Override | ||
public Class<Statement> getStatement() { | ||
return forName("dm.jdbc.driver.DmdbStatement"); | ||
|
||
} | ||
|
||
@Override | ||
public Class<PreparedStatement> getPreparedStatement() { | ||
return forName("dm.jdbc.driver.DmdbPreparedStatement"); | ||
} | ||
|
||
@Override | ||
public Class<CallableStatement> getCallableStatement() { | ||
return forName("dm.jdbc.driver.DmdbCallableStatement"); | ||
} | ||
} |
Oops, something went wrong.