提交 17da2e2e 编写于 作者: A aderm 提交者: wu-sheng

[test/plugin] immigrate test oracle scenario. (#4006)

* [test/plugin] immigrate test oracle scenario.

* repair ojdbc14.jar download url.

* 1.update ojdbc14.jar site;2.Adjust task position.

* fix curl download problem by add -L.

* Merge run steps.
上级 6963acd6
......@@ -445,7 +445,7 @@ jobs:
- name: Run elasticsearch-6.x-scenario 6.7.1-6.8.4 (7)
run: bash test/plugin/run.sh elasticsearch-6.x-scenario
Kafka:
Oracle_Kafka:
runs-on: ubuntu-18.04
timeout-minutes: 90
strategy:
......@@ -465,8 +465,13 @@ jobs:
java-version: 8
- name: Build SkyWalking Agent
run: ./mvnw clean package -DskipTests -Pagent >/dev/null
- name: Build the Docker image
run: ./mvnw -f test/plugin/pom.xml clean package -DskipTests docker:build -DBUILD_NO=local >/dev/null
- name: Run oracle 10.2.0.4.0 (1)
run: |
curl -L -o ./skywalking-agent/plugins/apm-oracle-10.x-plugin-1.0.1.jar https://github.com/SkyAPM/java-plugin-extensions/releases/download/1.0.1/apm-oracle-10.x-plugin-1.0.1.jar
curl -O https://skyapm.github.io/ci-assist/jars/ojdbc14-10.2.0.4.0.jar
./mvnw install:install-file -Dfile=ojdbc14-10.2.0.4.0.jar -DgroupId=com.oracle -DartifactId=ojdbc14 -Dversion=10.2.0.4.0 -Dpackaging=jar
./mvnw -f test/plugin/pom.xml clean package -DskipTests docker:build -DBUILD_NO=local >/dev/null
bash test/plugin/run.sh oracle-scenario
- name: Run kafka 0.11.0.0-2.3.0 (16)
run: bash test/plugin/run.sh kafka-scenario
......
#!/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/oracle-scenario.jar &
\ No newline at end of file
# 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:
- {oracle-scenario: nq 0}
instances:
- {oracle-scenario: 1}
operationNames:
- oracle-scenario: [Oracle/JDBI/Connection/close, Oracle/JDBI/PreparedStatement/executeQuery,
Oracle/JDBI/PreparedStatement/execute, Oracle/JDBI/Statement/execute,
/oracle-scenario/case/oracle]
segmentItems:
- applicationCode: oracle-scenario
segmentSize: ge 1
segments:
- segmentId: not null
spans:
- operationName: Oracle/JDBI/Statement/execute
operationId: 0
parentSpanId: 0
spanId: 1
spanLayer: Database
startTime: nq 0
endTime: nq 0
componentId: 34
componentName: ''
isError: false
spanType: Exit
peer: oracle-server:1521
peerId: 0
tags:
- {key: db.type, value: sql}
- {key: db.instance, value: xe}
- key: db.statement
value: "CREATE TABLE test_007(\nid VARCHAR(1) PRIMARY KEY, \nvalue VARCHAR(1)\
\ NOT NULL)"
- operationName: Oracle/JDBI/PreparedStatement/execute
operationId: 0
parentSpanId: 0
spanId: 2
spanLayer: Database
startTime: nq 0
endTime: nq 0
componentId: 34
componentName: ''
isError: false
spanType: Exit
peer: oracle-server:1521
peerId: 0
tags:
- {key: db.type, value: sql}
- {key: db.instance, value: xe}
- {key: db.statement, value: 'INSERT INTO test_007(id, value) VALUES(?,?)'}
- operationName: Oracle/JDBI/PreparedStatement/executeQuery
operationId: 0
parentSpanId: 0
spanId: 3
spanLayer: Database
startTime: nq 0
endTime: nq 0
componentId: 34
componentName: ''
isError: false
spanType: Exit
peer: oracle-server:1521
peerId: 0
tags:
- {key: db.type, value: sql}
- {key: db.instance, value: xe}
- {key: db.statement, value: 'SELECT id, value FROM test_007 WHERE id=?'}
- operationName: Oracle/JDBI/Statement/execute
operationId: 0
parentSpanId: 0
spanId: 4
spanLayer: Database
startTime: nq 0
endTime: nq 0
componentId: 34
componentName: ''
isError: false
spanType: Exit
peer: oracle-server:1521
peerId: 0
tags:
- {key: db.type, value: sql}
- {key: db.instance, value: xe}
- {key: db.statement, value: 'DROP table test_007'}
- operationName: Oracle/JDBI/Connection/close
operationId: 0
parentSpanId: 0
spanId: 5
spanLayer: Database
tags:
- {key: db.type,value: sql}
- {key: db.instance,value: xe}
- {key: db.statement,value: ''}
startTime: nq 0
endTime: nq 0
componentId: 34
componentName: ''
isError: false
spanType: Exit
peer: oracle-server:1521
peerId: 0
- operationName: /oracle-scenario/case/oracle
operationId: 0
parentSpanId: -1
spanId: 0
spanLayer: Http
startTime: nq 0
endTime: nq 0
componentId: 1
componentName: ''
isError: false
spanType: Entry
peer: ''
peerId: 0
tags:
- {key: url, value: 'http://localhost:8080/oracle-scenario/case/oracle'}
- {key: http.method, value: GET}
# 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/oracle-scenario/case/oracle
healthCheck: http://localhost:8080/oracle-scenario/case/healthCheck
startScript: ./bin/startup.sh
framework: oracle-scenario
environment:
- oracle.address=oracle-server:1521
- oracle.username=system
- oracle.password=oracle
dependencies:
oracle-server:
image: deepdiver/docker-oracle-xe-11g
hostname: oracle-server
expose:
- "1521"
<?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">
<groupId>org.apache.skywalking.apm.testcase</groupId>
<artifactId>oracle-scenario</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<modelVersion>4.0.0</modelVersion>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<compiler.version>1.8</compiler.version>
<test.framework.version>10.2.0.4.0</test.framework.version>
<spring-boot-version>2.1.6.RELEASE</spring-boot-version>
</properties>
<name>skywalking-oracle-scenario</name>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot-version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>${test.framework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
</dependencies>
<build>
<finalName>oracle-scenario</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${compiler.version}</source>
<target>${compiler.version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</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>
<outputDirectory>./target/</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
<?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}/oracle-scenario.jar</source>
<outputDirectory>./libs</outputDirectory>
<fileMode>0775</fileMode>
</file>
</files>
</assembly>
/*
* 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.oracle;
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
}
}
}
/*
* 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.oracle.controller;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.annotation.PostConstruct;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@RestController
@RequestMapping("/case")
public class CaseController {
private static final Logger logger = LogManager.getLogger(CaseController.class);
@Value("${oracle.address}")
private String oracleHostAndPort;
@Value("${oracle.username}")
private String oracleUsername;
@Value("${oracle.password}")
private String oraclePassword;
private String connectURL;
private static final String TEST_EXIST_SQL = "SELECT * FROM dual";
private static final String CREATE_TABLE_SQL = "CREATE TABLE test_007(\n" +
"id VARCHAR(1) PRIMARY KEY, \n" +
"value VARCHAR(1) NOT NULL)";
private static final String INSERT_DATA_SQL = "INSERT INTO test_007(id, value) VALUES(?,?)";
private static final String QUERY_DATA_SQL = "SELECT id, value FROM test_007 WHERE id=?";
private static final String DROP_TABLE_SQL = "DROP table test_007";
private static final String SUCCESS = "Success";
@PostConstruct
public void setUp() throws ClassNotFoundException {
Class.forName("oracle.jdbc.driver.OracleDriver");
connectURL = "jdbc:oracle:thin:@" + oracleHostAndPort + ":xe";
}
@RequestMapping("/oracle")
@ResponseBody
public String testcase() {
Connection connection = null;
try {
// create table by using statement
connection = DriverManager.getConnection(connectURL, oracleUsername, oraclePassword);
Statement statement = connection.createStatement();
statement.execute(CREATE_TABLE_SQL);
statement.close();
// insert table by using PreparedStatement
PreparedStatement insertDataPreparedStatement = connection.prepareStatement(INSERT_DATA_SQL);
insertDataPreparedStatement.setString(1, "1");
insertDataPreparedStatement.setString(2, "1");
insertDataPreparedStatement.execute();
insertDataPreparedStatement.close();
// query data by using PreparedStatement
PreparedStatement queryDataPreparedStatement = connection.prepareStatement(QUERY_DATA_SQL);
queryDataPreparedStatement.setString(1, "1");
ResultSet resultSet = queryDataPreparedStatement.executeQuery();
resultSet.next();
logger.info("Query id[{}]: value={}", "1", resultSet.getString(2));
queryDataPreparedStatement.close();
// drop table by using statement
Statement dropTableStatement = connection.createStatement();
dropTableStatement.execute(DROP_TABLE_SQL);
dropTableStatement.close();
} catch (SQLException e) {
String message = "Failed to execute sql";
logger.error(message);
throw new RuntimeException(message);
} finally {
if (connection != null) {
try {
connection.close();
} catch (SQLException e) {
String message = "Failed to close connection";
logger.error(message);
throw new RuntimeException(message);
}
}
}
return SUCCESS;
}
@RequestMapping("/healthCheck")
@ResponseBody
public String healthCheck() {
Connection connection = null;
try {
connection = DriverManager.getConnection(connectURL, oracleUsername, oraclePassword);
PreparedStatement preparedStatement = connection.prepareStatement(TEST_EXIST_SQL);
preparedStatement.execute();
preparedStatement.close();
} catch (SQLException e) {
String message = "Failed to execute sql";
logger.error(message);
throw new RuntimeException(message);
} finally {
if (connection != null) {
try {
connection.close();
} catch (SQLException e) {
String message = "Failed to close connection";
logger.error(message);
throw new RuntimeException(message);
}
}
}
return SUCCESS;
}
}
#
# 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
servlet:
context-path: /oracle-scenario
logging:
config: classpath:log4j2.xml
\ No newline at end of file
<?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
# 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
# "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.
10.2.0.4.0
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册