You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2019/10/20 16:12:44 UTC
[skywalking] branch master updated: [test/plugin] immigrate
postgresql scenario (#3644)
This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking.git
The following commit(s) were added to refs/heads/master by this push:
new aa18eb6 [test/plugin] immigrate postgresql scenario (#3644)
aa18eb6 is described below
commit aa18eb695b2b829223db6ff8e2ca021b6b5d95f9
Author: aderm <zh...@163.com>
AuthorDate: Mon Oct 21 00:12:35 2019 +0800
[test/plugin] immigrate postgresql scenario (#3644)
* Modify plugin test run.sh script parameter error
* shell fun error, delete ()
* delete space line
* [test/plugin] immigrate postgresql scenario
* add licene
* format expectedData.yaml & update support-version.list
* change workload from 3 to 1
* add startup.sh
* update startup.sh
* Add verify health-check segment
* remove health-check segment
* update code. 1. context is not effective; 2.format code. 3.change log to slf4j;
* update expectedData.yaml & change log to log4j2
* Add stage case count
* add immigrate postgresql-9.4-scenario
* repair module name & package name
* repair all postgresql-9.4 to postgresql-above9.4.1207
* change module name to postgresql-above9.4.1207
* change stage name
---
Jenkinsfile-Agent-Test | 2 +-
Jenkinsfile-Agent-Test-3 | 11 +-
.../config/expectedData.yaml | 114 +++++++++++++++++++
.../configuration.yml | 29 +++++
.../postgresql-above9.4.1207-scenario/pom.xml | 122 +++++++++++++++++++++
.../src/main/assembly/assembly.xml | 41 +++++++
.../apm/testcase/postgresql/Application.java | 34 ++++++
.../postgresql/controller/CaseController.java | 82 ++++++++++++++
.../testcase/postgresql/controller/ConstSql.java | 27 +++++
.../postgresql/controller/PostgresqlConfig.java | 49 +++++++++
.../postgresql/controller/SQLExecutor.java | 67 +++++++++++
.../src/main/resources/application.yml | 17 +++
.../src/main/resources/log4j2.xml | 31 ++++++
.../support-version.list | 31 ++++++
.../scenarios/postgresql-scenario/bin/startup.sh | 20 ++++
.../postgresql-scenario/config/expectedData.yaml | 115 +++++++++++++++++++
.../postgresql-scenario/configuration.yml | 30 +++++
test/plugin/scenarios/postgresql-scenario/pom.xml | 122 +++++++++++++++++++++
.../src/main/assembly/assembly.xml | 41 +++++++
.../apm/testcase/postgresql/Application.java | 34 ++++++
.../postgresql/controller/CaseController.java | 83 ++++++++++++++
.../testcase/postgresql/controller/ConstSql.java | 27 +++++
.../postgresql/controller/PostgresqlConfig.java | 49 +++++++++
.../postgresql/controller/SQLExecutor.java | 67 +++++++++++
.../src/main/resources/application.yml | 17 +++
.../src/main/resources/log4j2.xml | 31 ++++++
.../postgresql-scenario/support-version.list | 51 +++++++++
27 files changed, 1340 insertions(+), 4 deletions(-)
diff --git a/Jenkinsfile-Agent-Test b/Jenkinsfile-Agent-Test
index 26ba3a0..1af4799 100755
--- a/Jenkinsfile-Agent-Test
+++ b/Jenkinsfile-Agent-Test
@@ -107,4 +107,4 @@ pipeline {
deleteDir()
}
}
-}
\ No newline at end of file
+}
diff --git a/Jenkinsfile-Agent-Test-3 b/Jenkinsfile-Agent-Test-3
index 97bd18f..ec76a56 100755
--- a/Jenkinsfile-Agent-Test-3
+++ b/Jenkinsfile-Agent-Test-3
@@ -54,7 +54,7 @@ pipeline {
sh './mvnw -f test/plugin/pom.xml clean package -DskipTests -Dbuild_id=${BUILD_ID} docker:build'
}
}
- stage('Test Cases Report (21)') {
+ stage('Test Cases Report (73)') {
steps {
echo "reserve."
}
@@ -77,9 +77,14 @@ pipeline {
}
stage('Group2') {
stages {
- stage('reserve stages') {
+ stage('postgresql 9.2.x-9.4.x (36)') {
steps {
- echo "reserve."
+ sh 'bash test/plugin/run.sh --build_id=${BUILD_ID} postgresql-scenario'
+ }
+ }
+ stage('postgresql-9.4.1207+ (16)') {
+ steps {
+ sh 'bash test/plugin/run.sh --build_id=${BUILD_ID} postgresql-above9.4.1207-scenario'
}
}
}
diff --git a/test/plugin/scenarios/postgresql-above9.4.1207-scenario/config/expectedData.yaml b/test/plugin/scenarios/postgresql-above9.4.1207-scenario/config/expectedData.yaml
new file mode 100644
index 0000000..efa343e
--- /dev/null
+++ b/test/plugin/scenarios/postgresql-above9.4.1207-scenario/config/expectedData.yaml
@@ -0,0 +1,114 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you 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.
+registryItems:
+ applications:
+ - {postgresql-above9.4.1207-scenario: nq 0}
+ instances:
+ - {postgresql-above9.4.1207-scenario: 1}
+ operationNames:
+ - postgresql-above9.4.1207-scenario: [/postgresql-scenario/case/postgres, PostgreSQL/JDBI/PreparedStatement/executeWithFlags,
+ PostgreSQL/JDBI/CallableStatement/executeWithFlags, PostgreSQL/JDBI/Statement/execute,
+ PostgreSQL/JDBI/Connection/close]
+segmentItems:
+- applicationCode: postgresql-above9.4.1207-scenario
+ segmentSize: ge 1
+ segments:
+ - segmentId: not null
+ spans:
+ - operationName: PostgreSQL/JDBI/PreparedStatement/executeWithFlags
+ operationId: eq 0
+ parentSpanId: 0
+ spanId: 1
+ tags:
+ - {key: "db.type", value: "sql"}
+ - {key: "db.instance", value: "postgres"}
+ - {key: "db.statement", value: "CREATE TABLE test_007(\nid VARCHAR(1) PRIMARY KEY, \nvalue VARCHAR(1) NOT NULL)"}
+ startTime: nq 0
+ endTime: nq 0
+ isError: false
+ spanLayer: Database
+ spanType: Exit
+ componentName: null
+ componentId: 37
+ peer: postgresql-server:5432
+ peerId: eq 0
+ - operationName: PostgreSQL/JDBI/CallableStatement/executeWithFlags
+ operationId: eq 0
+ parentSpanId: 0
+ spanId: 2
+ tags:
+ - {key: "db.type", value: "sql"}
+ - {key: "db.instance", value: "postgres"}
+ - {key: "db.statement", value: "INSERT INTO test_007(id, value) VALUES(?,?)"}
+ startTime: nq 0
+ endTime: nq 0
+ isError: false
+ spanLayer: Database
+ spanType: Exit
+ componentName: null
+ componentId: 37
+ peer: postgresql-server:5432
+ peerId: eq 0
+ - operationName: PostgreSQL/JDBI/Statement/execute
+ operationId: eq 0
+ parentSpanId: 0
+ spanId: 3
+ tags:
+ - {key: "db.type", value: "sql"}
+ - {key: "db.instance", value: "postgres"}
+ - {key: "db.statement", value: "DROP table test_007"}
+ startTime: nq 0
+ endTime: nq 0
+ isError: false
+ spanLayer: Database
+ spanType: Exit
+ componentName: null
+ componentId: 37
+ peer: postgresql-server:5432
+ peerId: eq 0
+ - operationName: PostgreSQL/JDBI/Connection/close
+ operationId: eq 0
+ parentSpanId: 0
+ spanId: 4
+ tags:
+ - {key: "db.type", value: "sql"}
+ - {key: "db.instance", value: "postgres"}
+ - {key: "db.statement", value: ""}
+ startTime: nq 0
+ endTime: nq 0
+ isError: false
+ spanLayer: Database
+ spanType: Exit
+ componentName: null
+ componentId: 37
+ peer: postgresql-server:5432
+ peerId: eq 0
+ - operationName: /postgresql-scenario/case/postgres
+ operationId: eq 0
+ parentSpanId: -1
+ spanId: 0
+ startTime: nq 0
+ endTime: nq 0
+ spanLayer: Http
+ isError: false
+ spanType: Entry
+ componentName: null
+ componentId: 1
+ tags:
+ - {key: url, value: 'http://localhost:8080/postgresql-scenario/case/postgres'}
+ - {key: http.method, value: GET}
+ peer: null
+ peerId: eq 0
diff --git a/test/plugin/scenarios/postgresql-above9.4.1207-scenario/configuration.yml b/test/plugin/scenarios/postgresql-above9.4.1207-scenario/configuration.yml
new file mode 100644
index 0000000..663a82d
--- /dev/null
+++ b/test/plugin/scenarios/postgresql-above9.4.1207-scenario/configuration.yml
@@ -0,0 +1,29 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+type: jvm
+entryService: http://localhost:8080/postgresql-scenario/case/postgres
+healthCheck: http://localhost:8080/postgresql-scenario/case/healthcheck
+startScript: ./bin/startup.sh
+framework: PostgreSQL
+environment:
+ - POSTGRESQL_SERVER=postgresql-server:5432
+ - POSTGRES_DB=postgres
+ - POSTGRES_USER=postgres
+ - POSTGRES_PASSWORD=postgres
+dependencies:
+ postgresql-server:
+ image: postgres:9.3-alpine
+ hostname: postgresql-server
+
diff --git a/test/plugin/scenarios/postgresql-above9.4.1207-scenario/pom.xml b/test/plugin/scenarios/postgresql-above9.4.1207-scenario/pom.xml
new file mode 100644
index 0000000..2df5d87
--- /dev/null
+++ b/test/plugin/scenarios/postgresql-above9.4.1207-scenario/pom.xml
@@ -0,0 +1,122 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You 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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.skywalking</groupId>
+ <artifactId>postgresql-above9.4.1207-scenario</artifactId>
+ <version>5.0.0</version>
+
+ <name>skywalking-postgresql-above9.4.1207-scenario</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <compiler.version>1.8</compiler.version>
+
+ <test.framework.version>9.4-1206-jdbc42</test.framework.version>
+ <docker.image.version>${test.framework.version}</docker.image.version>
+
+ <spring-boot.version>2.1.4.RELEASE</spring-boot.version>
+ <lombok.version>1.16.20</lombok.version>
+ <log4j.version>2.8.1</log4j.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.postgresql</groupId>
+ <artifactId>postgresql</artifactId>
+ <version>${test.framework.version}</version>
+ </dependency>
+ <!-- spring boot -->
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter</artifactId>
+ <version>${spring-boot.version}</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>spring-boot-starter-logging</artifactId>
+ <groupId>org.springframework.boot</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-web</artifactId>
+ <version>${spring-boot.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-api</artifactId>
+ <version>${log4j.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-core</artifactId>
+ <version>${log4j.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>postgresql-above9.4.1207-scenario</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.6.0</version>
+ <configuration>
+ <source>${compiler.version}</source>
+ <target>${compiler.version}</target>
+ <encoding>${project.build.sourceEncoding}</encoding>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ <version>1.5.9.RELEASE</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>repackage</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>assemble</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <descriptors>
+ <descriptor>src/main/assembly/assembly.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/test/plugin/scenarios/postgresql-above9.4.1207-scenario/src/main/assembly/assembly.xml b/test/plugin/scenarios/postgresql-above9.4.1207-scenario/src/main/assembly/assembly.xml
new file mode 100644
index 0000000..3e7d698
--- /dev/null
+++ b/test/plugin/scenarios/postgresql-above9.4.1207-scenario/src/main/assembly/assembly.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You 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.
+ ~
+ -->
+<assembly
+ xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
+ <formats>
+ <format>zip</format>
+ </formats>
+
+ <fileSets>
+ <fileSet>
+ <directory>./bin</directory>
+ <fileMode>0775</fileMode>
+ </fileSet>
+ </fileSets>
+
+ <files>
+ <file>
+ <source>${project.build.directory}/postgresql-above9.4.1207-scenario.jar</source>
+ <outputDirectory>./libs</outputDirectory>
+ <fileMode>0775</fileMode>
+ </file>
+ </files>
+</assembly>
diff --git a/test/plugin/scenarios/postgresql-above9.4.1207-scenario/src/main/java/org/apache/skywalking/apm/testcase/postgresql/Application.java b/test/plugin/scenarios/postgresql-above9.4.1207-scenario/src/main/java/org/apache/skywalking/apm/testcase/postgresql/Application.java
new file mode 100644
index 0000000..d2f3e64
--- /dev/null
+++ b/test/plugin/scenarios/postgresql-above9.4.1207-scenario/src/main/java/org/apache/skywalking/apm/testcase/postgresql/Application.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.skywalking.apm.testcase.postgresql;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class Application {
+
+ public static void main(String[] args) {
+ try {
+ SpringApplication.run(Application.class, args);
+ } catch (Exception e) {
+ // Never do this
+ }
+ }
+}
diff --git a/test/plugin/scenarios/postgresql-above9.4.1207-scenario/src/main/java/org/apache/skywalking/apm/testcase/postgresql/controller/CaseController.java b/test/plugin/scenarios/postgresql-above9.4.1207-scenario/src/main/java/org/apache/skywalking/apm/testcase/postgresql/controller/CaseController.java
new file mode 100644
index 0000000..f3566c4
--- /dev/null
+++ b/test/plugin/scenarios/postgresql-above9.4.1207-scenario/src/main/java/org/apache/skywalking/apm/testcase/postgresql/controller/CaseController.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.skywalking.apm.testcase.postgresql.controller;
+
+import java.sql.SQLException;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/postgresql-scenario/case")
+public class CaseController {
+
+ private static Logger logger = LogManager.getLogger(CaseController.class);
+
+ @Autowired
+ PostgresqlConfig postgresqlConfig;
+
+ @GetMapping("/healthcheck")
+ public String healthcheck() throws Exception {
+ SQLExecutor sqlExecute = null;
+ try {
+ sqlExecute = new SQLExecutor(postgresqlConfig);
+ sqlExecute.checkPG(ConstSql.TEST_SQL);
+ } catch (SQLException e) {
+ logger.error("Failed to execute sql.", e);
+ throw e;
+ } finally {
+ if (sqlExecute != null) {
+ try {
+ sqlExecute.closeConnection();
+ } catch (SQLException e) {
+ logger.error("Failed to close connection.", e);
+ }
+ }
+ }
+ return "Success";
+ }
+
+ @GetMapping("/postgres")
+ public String postgres() throws SQLException {
+ logger.info("Begin to start execute sql");
+ SQLExecutor sqlExecute = null;
+ try {
+ sqlExecute = new SQLExecutor(postgresqlConfig);
+ sqlExecute.createTable(ConstSql.CREATE_TABLE_SQL);
+ sqlExecute.insertData(ConstSql.INSERT_DATA_SQL, "1", "1");
+ sqlExecute.dropTable(ConstSql.DROP_TABLE_SQL);
+ } catch (SQLException e) {
+ logger.error("Failed to execute sql.", e);
+ throw e;
+ } finally {
+ if (sqlExecute != null) {
+ try {
+ sqlExecute.closeConnection();
+ } catch (SQLException e) {
+ logger.error("Failed to close connection.", e);
+ }
+ }
+ }
+ return "Success";
+ }
+}
+
diff --git a/test/plugin/scenarios/postgresql-above9.4.1207-scenario/src/main/java/org/apache/skywalking/apm/testcase/postgresql/controller/ConstSql.java b/test/plugin/scenarios/postgresql-above9.4.1207-scenario/src/main/java/org/apache/skywalking/apm/testcase/postgresql/controller/ConstSql.java
new file mode 100644
index 0000000..a0a487b
--- /dev/null
+++ b/test/plugin/scenarios/postgresql-above9.4.1207-scenario/src/main/java/org/apache/skywalking/apm/testcase/postgresql/controller/ConstSql.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.skywalking.apm.testcase.postgresql.controller;
+
+public class ConstSql {
+ public static final String TEST_SQL = "SELECT 1";
+ public static final String CREATE_TABLE_SQL = "CREATE TABLE test_007(\n" +
+ "id VARCHAR(1) PRIMARY KEY, \n" +
+ "value VARCHAR(1) NOT NULL)";
+ public static final String INSERT_DATA_SQL = "INSERT INTO test_007(id, value) VALUES(?,?)";
+ public static final String DROP_TABLE_SQL = "DROP table test_007";
+}
diff --git a/test/plugin/scenarios/postgresql-above9.4.1207-scenario/src/main/java/org/apache/skywalking/apm/testcase/postgresql/controller/PostgresqlConfig.java b/test/plugin/scenarios/postgresql-above9.4.1207-scenario/src/main/java/org/apache/skywalking/apm/testcase/postgresql/controller/PostgresqlConfig.java
new file mode 100644
index 0000000..ba7fa48
--- /dev/null
+++ b/test/plugin/scenarios/postgresql-above9.4.1207-scenario/src/main/java/org/apache/skywalking/apm/testcase/postgresql/controller/PostgresqlConfig.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.skywalking.apm.testcase.postgresql.controller;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class PostgresqlConfig {
+
+ @Value("${POSTGRESQL_SERVER}")
+ private String host;
+
+ @Value("${POSTGRES_DB}")
+ private String db;
+
+ @Value("${POSTGRES_USER}")
+ private String user;
+
+ @Value("${POSTGRES_PASSWORD}")
+ private String password;
+
+ public String getUrl() {
+ return "jdbc:postgresql://" + host + "/" + db;
+ }
+
+ public String getUserName() {
+ return user;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+}
diff --git a/test/plugin/scenarios/postgresql-above9.4.1207-scenario/src/main/java/org/apache/skywalking/apm/testcase/postgresql/controller/SQLExecutor.java b/test/plugin/scenarios/postgresql-above9.4.1207-scenario/src/main/java/org/apache/skywalking/apm/testcase/postgresql/controller/SQLExecutor.java
new file mode 100644
index 0000000..fa1f73a
--- /dev/null
+++ b/test/plugin/scenarios/postgresql-above9.4.1207-scenario/src/main/java/org/apache/skywalking/apm/testcase/postgresql/controller/SQLExecutor.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.skywalking.apm.testcase.postgresql.controller;
+
+import java.sql.CallableStatement;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+public class SQLExecutor {
+
+ private Connection connection;
+
+ public SQLExecutor(PostgresqlConfig postgresqlConfig) throws SQLException {
+ try {
+ Class.forName("org.postgresql.Driver");
+ } catch (ClassNotFoundException e) {
+ //
+ }
+ connection = DriverManager.getConnection(postgresqlConfig.getUrl(), postgresqlConfig.getUserName(), postgresqlConfig.getPassword());
+ }
+
+ public void checkPG(String sql) throws SQLException {
+ Statement preparedStatement = connection.createStatement();
+ preparedStatement.execute(sql);
+ }
+
+ public void createTable(String sql) throws SQLException {
+ PreparedStatement preparedStatement = connection.prepareStatement(sql);
+ preparedStatement.execute();
+ }
+
+ public void insertData(String sql, String id, String value) throws SQLException {
+ CallableStatement preparedStatement = connection.prepareCall(sql);
+ preparedStatement.setString(1, id);
+ preparedStatement.setString(2, value);
+ preparedStatement.execute();
+ }
+
+ public void dropTable(String sql) throws SQLException {
+ Statement preparedStatement = connection.createStatement();
+ preparedStatement.execute(sql);
+ }
+
+ public void closeConnection() throws SQLException {
+ if (this.connection != null) {
+ this.connection.close();
+ }
+ }
+}
diff --git a/test/plugin/scenarios/postgresql-above9.4.1207-scenario/src/main/resources/application.yml b/test/plugin/scenarios/postgresql-above9.4.1207-scenario/src/main/resources/application.yml
new file mode 100644
index 0000000..a2f8b0f
--- /dev/null
+++ b/test/plugin/scenarios/postgresql-above9.4.1207-scenario/src/main/resources/application.yml
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you 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.
+server:
+ port: 8080
diff --git a/test/plugin/scenarios/postgresql-above9.4.1207-scenario/src/main/resources/log4j2.xml b/test/plugin/scenarios/postgresql-above9.4.1207-scenario/src/main/resources/log4j2.xml
new file mode 100644
index 0000000..985bd03
--- /dev/null
+++ b/test/plugin/scenarios/postgresql-above9.4.1207-scenario/src/main/resources/log4j2.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You 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.
+ ~
+ -->
+
+<Configuration status="WARN">
+ <Appenders>
+ <Console name="Console" target="SYSTEM_ERR">
+ <PatternLayout charset="UTF-8" pattern="[%d{yyyy-MM-dd HH:mm:ss:SSS}] [%p] - %l - %m%n"/>
+ </Console>
+ </Appenders>
+ <Loggers>
+ <Root level="WARN">
+ <AppenderRef ref="Console"/>
+ </Root>
+ </Loggers>
+</Configuration>
\ No newline at end of file
diff --git a/test/plugin/scenarios/postgresql-above9.4.1207-scenario/support-version.list b/test/plugin/scenarios/postgresql-above9.4.1207-scenario/support-version.list
new file mode 100644
index 0000000..83574bc
--- /dev/null
+++ b/test/plugin/scenarios/postgresql-above9.4.1207-scenario/support-version.list
@@ -0,0 +1,31 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you 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.
+9.4.1207
+9.4.1208
+9.4.1209
+9.4.1210
+9.4.1211
+9.4.1212
+9.4.1208.jre7
+9.4.1208.jre6
+9.4.1209.jre7
+9.4.1209.jre6
+9.4.1210.jre6
+9.4.1210.jre7
+9.4.1211.jre6
+9.4.1211.jre7
+9.4.1212.jre6
+9.4.1212.jre7
diff --git a/test/plugin/scenarios/postgresql-scenario/bin/startup.sh b/test/plugin/scenarios/postgresql-scenario/bin/startup.sh
new file mode 100644
index 0000000..74ce435
--- /dev/null
+++ b/test/plugin/scenarios/postgresql-scenario/bin/startup.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you 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.
+
+home="$(cd "$(dirname $0)"; pwd)"
+
+java -jar ${agent_opts} ${home}/../libs/postgresql-scenario.jar &
diff --git a/test/plugin/scenarios/postgresql-scenario/config/expectedData.yaml b/test/plugin/scenarios/postgresql-scenario/config/expectedData.yaml
new file mode 100644
index 0000000..9fa8c23
--- /dev/null
+++ b/test/plugin/scenarios/postgresql-scenario/config/expectedData.yaml
@@ -0,0 +1,115 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you 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.
+registryItems:
+ applications:
+ - {postgresql-scenario: nq 0}
+ instances:
+ - {postgresql-scenario: 1}
+ operationNames:
+ - postgresql-scenario: [/postgresql-scenario/case/postgres, PostgreSQL/JDBI/PreparedStatement/execute,
+ PostgreSQL/JDBI/CallableStatement/execute, PostgreSQL/JDBI/Statement/execute,
+ PostgreSQL/JDBI/Connection/close]
+ heartbeat: []
+segmentItems:
+- applicationCode: postgresql-scenario
+ segmentSize: ge 1
+ segments:
+ - segmentId: not null
+ spans:
+ - operationName: PostgreSQL/JDBI/PreparedStatement/execute
+ operationId: eq 0
+ parentSpanId: 0
+ spanId: 1
+ tags:
+ - {key: "db.type", value: "sql"}
+ - {key: "db.instance", value: "postgres"}
+ - {key: "db.statement", value: "CREATE TABLE test_007(\nid VARCHAR(1) PRIMARY KEY, \nvalue VARCHAR(1) NOT NULL)"}
+ startTime: nq 0
+ endTime: nq 0
+ isError: false
+ spanLayer: Database
+ spanType: Exit
+ componentName: ''
+ componentId: 37
+ peer: postgresql-server:5432
+ peerId: eq 0
+ - operationName: PostgreSQL/JDBI/CallableStatement/execute
+ operationId: eq 0
+ parentSpanId: 0
+ spanId: 2
+ tags:
+ - {key: "db.type", value: "sql"}
+ - {key: "db.instance", value: "postgres"}
+ - {key: "db.statement", value: "INSERT INTO test_007(id, value) VALUES(?,?)"}
+ startTime: nq 0
+ endTime: nq 0
+ isError: false
+ spanLayer: Database
+ spanType: Exit
+ componentName: ''
+ componentId: 37
+ peer: postgresql-server:5432
+ peerId: eq 0
+ - operationName: PostgreSQL/JDBI/Statement/execute
+ operationId: eq 0
+ parentSpanId: 0
+ spanId: 3
+ tags:
+ - {key: "db.type", value: "sql"}
+ - {key: "db.instance", value: "postgres"}
+ - {key: "db.statement", value: "DROP table test_007"}
+ startTime: nq 0
+ endTime: nq 0
+ isError: false
+ spanLayer: Database
+ spanType: Exit
+ componentName: ''
+ componentId: 37
+ peer: postgresql-server:5432
+ peerId: eq 0
+ - operationName: PostgreSQL/JDBI/Connection/close
+ operationId: eq 0
+ parentSpanId: 0
+ spanId: 4
+ tags:
+ - {key: "db.type", value: "sql"}
+ - {key: "db.instance", value: "postgres"}
+ - {key: "db.statement", value: ""}
+ startTime: nq 0
+ endTime: nq 0
+ isError: false
+ spanLayer: Database
+ spanType: Exit
+ componentName: ''
+ componentId: 37
+ peer: postgresql-server:5432
+ peerId: eq 0
+ - operationName: /postgresql-scenario/case/postgres
+ operationId: eq 0
+ parentSpanId: -1
+ spanId: 0
+ startTime: nq 0
+ endTime: nq 0
+ spanLayer: Http
+ isError: false
+ spanType: Entry
+ componentName: ''
+ componentId: 1
+ tags:
+ - {key: url, value: 'http://localhost:8080/postgresql-scenario/case/postgres'}
+ - {key: http.method, value: GET}
+ peer: null
+ peerId: eq 0
diff --git a/test/plugin/scenarios/postgresql-scenario/configuration.yml b/test/plugin/scenarios/postgresql-scenario/configuration.yml
new file mode 100644
index 0000000..f34ac2d
--- /dev/null
+++ b/test/plugin/scenarios/postgresql-scenario/configuration.yml
@@ -0,0 +1,30 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+
+type: jvm
+entryService: http://localhost:8080/postgresql-scenario/case/postgres
+healthCheck: http://localhost:8080/postgresql-scenario/case/healthcheck
+startScript: ./bin/startup.sh
+framework: PostgreSQL
+environment:
+ - POSTGRESQL_SERVER=postgresql-server:5432
+ - POSTGRES_DB=postgres
+ - POSTGRES_USER=postgres
+ - POSTGRES_PASSWORD=postgres
+dependencies:
+ postgresql-server:
+ image: postgres:9.3-alpine
+ hostname: postgresql-server
+
diff --git a/test/plugin/scenarios/postgresql-scenario/pom.xml b/test/plugin/scenarios/postgresql-scenario/pom.xml
new file mode 100644
index 0000000..eb6b8a4
--- /dev/null
+++ b/test/plugin/scenarios/postgresql-scenario/pom.xml
@@ -0,0 +1,122 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You 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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.skywalking</groupId>
+ <artifactId>postgresql-scenario</artifactId>
+ <version>5.0.0</version>
+
+ <name>skywalking-postgresql-scenario</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <compiler.version>1.8</compiler.version>
+
+ <test.framework.version>9.4-1200-jdbc41</test.framework.version>
+ <docker.image.version>${test.framework.version}</docker.image.version>
+
+ <spring-boot.version>2.1.4.RELEASE</spring-boot.version>
+ <lombok.version>1.16.20</lombok.version>
+ <log4j.version>2.8.1</log4j.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.postgresql</groupId>
+ <artifactId>postgresql</artifactId>
+ <version>${test.framework.version}</version>
+ </dependency>
+ <!-- spring boot -->
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter</artifactId>
+ <version>${spring-boot.version}</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>spring-boot-starter-logging</artifactId>
+ <groupId>org.springframework.boot</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-web</artifactId>
+ <version>${spring-boot.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-api</artifactId>
+ <version>${log4j.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-core</artifactId>
+ <version>${log4j.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>postgresql-scenario</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.6.0</version>
+ <configuration>
+ <source>${compiler.version}</source>
+ <target>${compiler.version}</target>
+ <encoding>${project.build.sourceEncoding}</encoding>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ <version>1.5.9.RELEASE</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>repackage</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>assemble</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <descriptors>
+ <descriptor>src/main/assembly/assembly.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/test/plugin/scenarios/postgresql-scenario/src/main/assembly/assembly.xml b/test/plugin/scenarios/postgresql-scenario/src/main/assembly/assembly.xml
new file mode 100644
index 0000000..195ec65
--- /dev/null
+++ b/test/plugin/scenarios/postgresql-scenario/src/main/assembly/assembly.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You 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.
+ ~
+ -->
+<assembly
+ xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
+ <formats>
+ <format>zip</format>
+ </formats>
+
+ <fileSets>
+ <fileSet>
+ <directory>./bin</directory>
+ <fileMode>0775</fileMode>
+ </fileSet>
+ </fileSets>
+
+ <files>
+ <file>
+ <source>${project.build.directory}/postgresql-scenario.jar</source>
+ <outputDirectory>./libs</outputDirectory>
+ <fileMode>0775</fileMode>
+ </file>
+ </files>
+</assembly>
diff --git a/test/plugin/scenarios/postgresql-scenario/src/main/java/org/apache/skywalking/apm/testcase/postgresql/Application.java b/test/plugin/scenarios/postgresql-scenario/src/main/java/org/apache/skywalking/apm/testcase/postgresql/Application.java
new file mode 100644
index 0000000..d2f3e64
--- /dev/null
+++ b/test/plugin/scenarios/postgresql-scenario/src/main/java/org/apache/skywalking/apm/testcase/postgresql/Application.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.skywalking.apm.testcase.postgresql;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class Application {
+
+ public static void main(String[] args) {
+ try {
+ SpringApplication.run(Application.class, args);
+ } catch (Exception e) {
+ // Never do this
+ }
+ }
+}
diff --git a/test/plugin/scenarios/postgresql-scenario/src/main/java/org/apache/skywalking/apm/testcase/postgresql/controller/CaseController.java b/test/plugin/scenarios/postgresql-scenario/src/main/java/org/apache/skywalking/apm/testcase/postgresql/controller/CaseController.java
new file mode 100644
index 0000000..60e1f48
--- /dev/null
+++ b/test/plugin/scenarios/postgresql-scenario/src/main/java/org/apache/skywalking/apm/testcase/postgresql/controller/CaseController.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.skywalking.apm.testcase.postgresql.controller;
+
+import java.sql.SQLException;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/postgresql-scenario/case")
+public class CaseController {
+
+ private static Logger logger = LogManager.getLogger(CaseController.class);
+
+ @Autowired
+ PostgresqlConfig postgresqlConfig;
+
+ @GetMapping("/healthcheck")
+ public String healthcheck() throws Exception {
+ SQLExecutor sqlExecute = null;
+ try {
+ sqlExecute = new SQLExecutor(postgresqlConfig);
+ sqlExecute.checkPG(ConstSql.TEST_SQL);
+ } catch (SQLException e) {
+ logger.error("Failed to execute sql.", e);
+ throw e;
+ } finally {
+ if (sqlExecute != null) {
+ try {
+ sqlExecute.closeConnection();
+ } catch (SQLException e) {
+ logger.error("Failed to close connection.", e);
+ }
+ }
+ }
+ return "Success";
+ }
+
+ @GetMapping("/postgres")
+ public String postgres() throws SQLException {
+ logger.info("Begin to start execute sql");
+ SQLExecutor sqlExecute = null;
+ try {
+ sqlExecute = new SQLExecutor(postgresqlConfig);
+ sqlExecute.createTable(ConstSql.CREATE_TABLE_SQL);
+ sqlExecute.insertData(ConstSql.INSERT_DATA_SQL, "1", "1");
+ sqlExecute.dropTable(ConstSql.DROP_TABLE_SQL);
+ } catch (SQLException e) {
+ logger.error("Failed to execute sql.", e);
+ throw e;
+ } finally {
+ if (sqlExecute != null) {
+ try {
+ sqlExecute.closeConnection();
+ } catch (SQLException e) {
+ logger.error("Failed to close connection.", e);
+ }
+ }
+ }
+ return "Success";
+ }
+}
+
diff --git a/test/plugin/scenarios/postgresql-scenario/src/main/java/org/apache/skywalking/apm/testcase/postgresql/controller/ConstSql.java b/test/plugin/scenarios/postgresql-scenario/src/main/java/org/apache/skywalking/apm/testcase/postgresql/controller/ConstSql.java
new file mode 100644
index 0000000..a0a487b
--- /dev/null
+++ b/test/plugin/scenarios/postgresql-scenario/src/main/java/org/apache/skywalking/apm/testcase/postgresql/controller/ConstSql.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.skywalking.apm.testcase.postgresql.controller;
+
+public class ConstSql {
+ public static final String TEST_SQL = "SELECT 1";
+ public static final String CREATE_TABLE_SQL = "CREATE TABLE test_007(\n" +
+ "id VARCHAR(1) PRIMARY KEY, \n" +
+ "value VARCHAR(1) NOT NULL)";
+ public static final String INSERT_DATA_SQL = "INSERT INTO test_007(id, value) VALUES(?,?)";
+ public static final String DROP_TABLE_SQL = "DROP table test_007";
+}
diff --git a/test/plugin/scenarios/postgresql-scenario/src/main/java/org/apache/skywalking/apm/testcase/postgresql/controller/PostgresqlConfig.java b/test/plugin/scenarios/postgresql-scenario/src/main/java/org/apache/skywalking/apm/testcase/postgresql/controller/PostgresqlConfig.java
new file mode 100644
index 0000000..ba7fa48
--- /dev/null
+++ b/test/plugin/scenarios/postgresql-scenario/src/main/java/org/apache/skywalking/apm/testcase/postgresql/controller/PostgresqlConfig.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.skywalking.apm.testcase.postgresql.controller;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class PostgresqlConfig {
+
+ @Value("${POSTGRESQL_SERVER}")
+ private String host;
+
+ @Value("${POSTGRES_DB}")
+ private String db;
+
+ @Value("${POSTGRES_USER}")
+ private String user;
+
+ @Value("${POSTGRES_PASSWORD}")
+ private String password;
+
+ public String getUrl() {
+ return "jdbc:postgresql://" + host + "/" + db;
+ }
+
+ public String getUserName() {
+ return user;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+}
diff --git a/test/plugin/scenarios/postgresql-scenario/src/main/java/org/apache/skywalking/apm/testcase/postgresql/controller/SQLExecutor.java b/test/plugin/scenarios/postgresql-scenario/src/main/java/org/apache/skywalking/apm/testcase/postgresql/controller/SQLExecutor.java
new file mode 100644
index 0000000..fa1f73a
--- /dev/null
+++ b/test/plugin/scenarios/postgresql-scenario/src/main/java/org/apache/skywalking/apm/testcase/postgresql/controller/SQLExecutor.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.skywalking.apm.testcase.postgresql.controller;
+
+import java.sql.CallableStatement;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+public class SQLExecutor {
+
+ private Connection connection;
+
+ public SQLExecutor(PostgresqlConfig postgresqlConfig) throws SQLException {
+ try {
+ Class.forName("org.postgresql.Driver");
+ } catch (ClassNotFoundException e) {
+ //
+ }
+ connection = DriverManager.getConnection(postgresqlConfig.getUrl(), postgresqlConfig.getUserName(), postgresqlConfig.getPassword());
+ }
+
+ public void checkPG(String sql) throws SQLException {
+ Statement preparedStatement = connection.createStatement();
+ preparedStatement.execute(sql);
+ }
+
+ public void createTable(String sql) throws SQLException {
+ PreparedStatement preparedStatement = connection.prepareStatement(sql);
+ preparedStatement.execute();
+ }
+
+ public void insertData(String sql, String id, String value) throws SQLException {
+ CallableStatement preparedStatement = connection.prepareCall(sql);
+ preparedStatement.setString(1, id);
+ preparedStatement.setString(2, value);
+ preparedStatement.execute();
+ }
+
+ public void dropTable(String sql) throws SQLException {
+ Statement preparedStatement = connection.createStatement();
+ preparedStatement.execute(sql);
+ }
+
+ public void closeConnection() throws SQLException {
+ if (this.connection != null) {
+ this.connection.close();
+ }
+ }
+}
diff --git a/test/plugin/scenarios/postgresql-scenario/src/main/resources/application.yml b/test/plugin/scenarios/postgresql-scenario/src/main/resources/application.yml
new file mode 100644
index 0000000..a2f8b0f
--- /dev/null
+++ b/test/plugin/scenarios/postgresql-scenario/src/main/resources/application.yml
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you 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.
+server:
+ port: 8080
diff --git a/test/plugin/scenarios/postgresql-scenario/src/main/resources/log4j2.xml b/test/plugin/scenarios/postgresql-scenario/src/main/resources/log4j2.xml
new file mode 100644
index 0000000..985bd03
--- /dev/null
+++ b/test/plugin/scenarios/postgresql-scenario/src/main/resources/log4j2.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You 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.
+ ~
+ -->
+
+<Configuration status="WARN">
+ <Appenders>
+ <Console name="Console" target="SYSTEM_ERR">
+ <PatternLayout charset="UTF-8" pattern="[%d{yyyy-MM-dd HH:mm:ss:SSS}] [%p] - %l - %m%n"/>
+ </Console>
+ </Appenders>
+ <Loggers>
+ <Root level="WARN">
+ <AppenderRef ref="Console"/>
+ </Root>
+ </Loggers>
+</Configuration>
\ No newline at end of file
diff --git a/test/plugin/scenarios/postgresql-scenario/support-version.list b/test/plugin/scenarios/postgresql-scenario/support-version.list
new file mode 100644
index 0000000..ada0541
--- /dev/null
+++ b/test/plugin/scenarios/postgresql-scenario/support-version.list
@@ -0,0 +1,51 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you 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.
+9.2-1002-jdbc4
+9.2-1003-jdbc3
+9.2-1003-jdbc4
+9.2-1004-jdbc3
+9.2-1004-jdbc4
+9.2-1004-jdbc41
+9.3-1100-jdbc3
+9.3-1100-jdbc4
+9.3-1101-jdbc3
+9.3-1101-jdbc4
+9.3-1101-jdbc41
+9.3-1102-jdbc3
+9.3-1102-jdbc4
+9.3-1102-jdbc41
+9.3-1103-jdbc3
+9.3-1103-jdbc4
+9.3-1103-jdbc41
+9.3-1104-jdbc4
+9.3-1104-jdbc41
+9.4-1201-jdbc4
+9.4-1201-jdbc41
+9.4-1202-jdbc4
+9.4-1202-jdbc41
+9.4-1202-jdbc42
+9.4-1203-jdbc4
+9.4-1203-jdbc41
+9.4-1203-jdbc42
+9.4-1204-jdbc4
+9.4-1204-jdbc41
+9.4-1204-jdbc42
+9.4-1205-jdbc4
+9.4-1205-jdbc41
+9.4-1205-jdbc42
+9.4-1206-jdbc4
+9.4-1206-jdbc41
+9.4-1206-jdbc42