[plugin/test] Plugin test with jdk14 (#5352)

* plugin test with jdk14

* introduce jdk14 container

* remove docker:build

* remove BUILD_NO and introduct image_version

* Update docs/en/guides/Plugin-test.md

Co-authored-by: kezhenxu94 <kezhenxu94@163.com>

Co-authored-by: 吴晟 Wu Sheng <wu.sheng@foxmail.com>
Co-authored-by: kezhenxu94 <kezhenxu94@apache.org>
Co-authored-by: kezhenxu94 <kezhenxu94@163.com>
This commit is contained in:
Daming 2020-08-24 20:17:22 +08:00 committed by GitHub
parent 450a7ec4e0
commit 6c1659c56a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 818 additions and 115 deletions

View File

@ -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.
name: PluginsJDK14Test
on:
pull_request:
push:
branches:
- master
tags:
- 'v*'
jobs:
PluginsJDK14Test:
name: jdk14
runs-on: ubuntu-18.04
timeout-minutes: 90
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: actions/setup-java@v1
with:
java-version: 8
- name: Build SkyWalking Agent
run: ./mvnw --batch-mode clean package -DskipTests -Pagent
- name: Build Docker image
run: ./mvnw --batch-mode -f test/plugin/pom.xml clean package -DskipTests -Pjdk14
- uses: actions/setup-java@v1
with:
java-version: 14
- name: jdk14-with-gson-scenario (1)
run: bash test/plugin/run.sh --image_version=jdk14-1.0.0 jdk14-with-gson-scenario
- name: Report Coverage
run: bash -x tools/coverage/report.sh

View File

@ -66,7 +66,7 @@ jobs:
- name: Build SkyWalking Agent
run: ./mvnw --batch-mode clean package -DskipTests -Pagent
- name: Build Docker image
run: ./mvnw --batch-mode -f test/plugin/pom.xml clean package -DskipTests docker:build -DBUILD_NO=local
run: ./mvnw --batch-mode -f test/plugin/pom.xml clean package -DskipTests
- name: ${{ matrix.case.title }}
run: bash test/plugin/run.sh ${{ matrix.case.name }}
- name: Report Coverage

View File

@ -59,7 +59,7 @@ jobs:
- name: Build SkyWalking Agent
run: ./mvnw --batch-mode clean package -DskipTests -Pagent
- name: Build Docker image
run: ./mvnw --batch-mode -f test/plugin/pom.xml clean package -DskipTests docker:build -DBUILD_NO=local
run: ./mvnw --batch-mode -f test/plugin/pom.xml clean package -DskipTests
- name: ${{ matrix.case.title }}
run: bash test/plugin/run.sh ${{ matrix.case.name }}
- name: Report Coverage

View File

@ -66,7 +66,7 @@ jobs:
- name: Build SkyWalking Agent
run: ./mvnw --batch-mode clean package -DskipTests -Pagent
- name: Build Docker image
run: ./mvnw --batch-mode -f test/plugin/pom.xml clean package -DskipTests docker:build -DBUILD_NO=local
run: ./mvnw --batch-mode -f test/plugin/pom.xml clean package -DskipTests
- name: ${{ matrix.case.title }}
run: bash test/plugin/run.sh ${{ matrix.case.name }}
- name: Report Coverage

View File

@ -66,7 +66,7 @@ jobs:
- name: Build SkyWalking Agent
run: ./mvnw --batch-mode clean package -DskipTests -Pagent
- name: Build Docker image
run: ./mvnw --batch-mode -f test/plugin/pom.xml clean package -DskipTests docker:build -DBUILD_NO=local
run: ./mvnw --batch-mode -f test/plugin/pom.xml clean package -DskipTests
- name: ${{ matrix.case.title }}
run: bash test/plugin/run.sh ${{ matrix.case.name }}
- name: Report Coverage
@ -86,7 +86,7 @@ jobs:
- name: Build SkyWalking Agent
run: ./mvnw --batch-mode clean package -DskipTests -Pagent
- name: Build Docker image
run: ./mvnw --batch-mode -f test/plugin/pom.xml clean package -DskipTests docker:build -DBUILD_NO=local
run: ./mvnw --batch-mode -f test/plugin/pom.xml clean package -DskipTests
- name: Oracle 10.2.0.4.0 (1)
run: |
curl -O https://skyapm.github.io/ci-assist/jars/ojdbc14-10.2.0.4.0.jar

View File

@ -10,26 +10,27 @@ Every plugin maintained in the main repo requires corresponding test cases, also
## Environment Requirements
1. MacOS/Linux
2. jdk 8+
2. JDK 8+
3. Docker
4. Docker Compose
## Case Base Image Introduction
The test framework provides `JVM-container` and `Tomcat-container` base images. You could choose the suitable one for your test case, if either is suitable, **recommend choose `JVM-container`**.
The test framework provides `JVM-container` and `Tomcat-container` base images including JDK8, JDK14. You could choose the suitable one for your test case, if both are suitable, **`JVM-container` is preferred**.
### JVM-container Image Introduction
[JVM-container](../../../test/plugin/containers/jvm-container) uses `openjdk:8` as the base image.
[JVM-container](../../../test/plugin/containers/jvm-container) uses `openjdk:8` as the base image. `JVM-container` has supported JDK14, which inherits `openjdk:14`.
The test case project is required to be packaged as `project-name.zip`, including `startup.sh` and uber jar, by using `mvn clean package`.
Take the following test projects as good examples
* [sofarpc-scenario](../../../test/plugin/scenarios/sofarpc-scenario) as a single project case.
* [webflux-scenario](../../../test/plugin/scenarios/webflux-scenario) as a case including multiple projects.
* [jdk14-with-gson-scenario](../../../test/plugin/scenarios/jdk14-with-gson-scenario) as a single project case with JDK14.
### Tomcat-container Image Introduction
[Tomcat-container](../../../test/plugin/containers/tomcat-container) uses `tomcat:8.5.42-jdk8-openjdk` as the base image.
[Tomcat-container](../../../test/plugin/containers/tomcat-container) uses `tomcat:8.5.57-jdk8-openjdk` or `tomcat:8.5.57-jdk14-openjdk` as the base image.
The test case project is required to be packaged as `project-name.war` by using `mvn package`.
Take the following test project as a good example
@ -509,6 +510,8 @@ Based on your plugin's name, please add the test case into file `.github/workflo
Every test case is a Github Actions Job. Please use the `<scenario name> + <version range> + (<supported version count>)` as the Job `title`, and the scenario directory as the Job `name`,
mostly you'll just need to decide which file (`plugins-test.<n>.yaml`) to add your test case, and simply put one line (as follows) in it, take the existed cases as examples.
If a test case required to run in JDK 14 environment, please add you test case into file `plugins-jdk14-test.<n>.yaml`.
```yaml
jobs:
PluginsTest:

View File

@ -32,8 +32,96 @@
<artifactId>jvm-container</artifactId>
<name>SkyWalking JVM Runner Image</name>
<properties>
<skip.docker>false</skip.docker>
<docker.image.name>skywalking/agent-test-jvm</docker.image.name>
</properties>
<profiles>
<profile>
<id>jdk8</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.33.0</version>
<configuration>
<images>
<image>
<name>skywalking/agent-test-jvm:${project.version}</name>
<build>
<from>openjdk:8</from>
<workdir>/usr/local/skywalking/scenario</workdir>
<assembly>
<mode>dir</mode>
<targetDir>/usr/local/skywalking</targetDir>
<descriptor>assembly.xml</descriptor>
</assembly>
<runCmds>
<run>chmod +x /usr/local/skywalking/run.sh</run>
<run>tar -xvf ../tools/skywalking-mock-collector.tar.gz -C ../tools</run>
</runCmds>
<cmd>["/usr/local/skywalking/run.sh"]</cmd>
</build>
</image>
</images>
</configuration>
<executions>
<execution>
<id>build</id>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>jdk14</id>
<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.33.0</version>
<configuration>
<images>
<image>
<name>skywalking/agent-test-jvm:jdk14-${project.version}</name>
<build>
<from>openjdk:14</from>
<workdir>/usr/local/skywalking/scenario</workdir>
<assembly>
<mode>dir</mode>
<targetDir>/usr/local/skywalking</targetDir>
<descriptor>assembly.xml</descriptor>
</assembly>
<runCmds>
<run>yum install -y unzip</run>
<run>chmod +x /usr/local/skywalking/run.sh</run>
<run>tar -xvf ../tools/skywalking-mock-collector.tar.gz -C ../tools</run>
</runCmds>
<cmd>["/usr/local/skywalking/run.sh"]</cmd>
</build>
</image>
</images>
</configuration>
<executions>
<execution>
<id>build</id>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -0,0 +1,42 @@
<?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>dir</format>
</formats>
<fileSets>
<fileSet>
<directory>${project.basedir}/../../agent-test-tools/dist</directory>
<outputDirectory>tools</outputDirectory>
</fileSet>
</fileSets>
<files>
<file>
<source>${project.basedir}/src/main/docker/run.sh</source>
<outputDirectory>/</outputDirectory>
</file>
</files>
</assembly>

View File

@ -16,7 +16,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
[[ -n $DEBUG_MODE ]] && set -ex
set -ex
[[ -n $DEBUG_MODE ]] && export
function exitOnError() {
echo -e "\033[31m[ERROR] $1\033[0m">&2
@ -85,7 +86,7 @@ exec /var/run/${SCENARIO_NAME}/${SCENARIO_START_SCRIPT} 1>${LOGS_HOME}/scenario.
healthCheck ${SCENARIO_HEALTH_CHECK_URL}
echo "To visit entry service"
`echo curl ${SCENARIO_EXTEND_ENTRY_HEADER} -s --max-time 3 ${SCENARIO_ENTRY_SERVICE}`
`echo curl ${SCENARIO_EXTEND_ENTRY_HEADER} -s --max-time 3 ${SCENARIO_ENTRY_SERVICE}` || true
sleep 5
echo "To receive actual data"
@ -97,7 +98,7 @@ java -jar \
-Xmx256m -Xms256m \
-DcaseName="${SCENARIO_NAME}-${SCENARIO_VERSION}" \
-DtestCasePath=${SCENARIO_HOME}/data/ \
${TOOLS_HOME}/skywalking-validator-tools.jar 1>${LOGS_HOME}/validatolr.out
${TOOLS_HOME}/skywalking-validator.jar 1>${LOGS_HOME}/validatolr.out
status=$?
if [[ $status -eq 0 ]]; then

View File

@ -36,33 +36,4 @@
<module>tomcat-container</module>
<module>jvm-container</module>
</modules>
<properties>
<skip.docker>true</skip.docker>
<docker.image.name>skywalking/${project.name}</docker.image.name>
</properties>
<build>
<plugins>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>${docker-maven-plugin.version}</version>
<configuration>
<!--suppress UnresolvedMavenProperty -->
<imageName>${docker.image.name}:${BUILD_NO}</imageName>
<dockerDirectory>${project.basedir}/docker</dockerDirectory>
<skipDocker>${skip.docker}</skipDocker>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.basedir}/../../agent-test-tools/dist</directory>
<include>skywalking-mock-collector.tar.gz</include>
<include>skywalking-validator.jar</include>
</resource>
</resources>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -32,9 +32,104 @@
<artifactId>tomcat-container</artifactId>
<name>SkyWalking Tomcat Runner Image</name>
<properties>
<skip.docker>false</skip.docker>
<docker.image.name>skywalking/agent-test-tomcat</docker.image.name>
</properties>
<profiles>
<profile>
<id>jdk8</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.33.0</version>
<configuration>
<images>
<image>
<name>skywalking/agent-test-tomcat:${project.version}</name>
<build>
<from>tomcat:8.5.57-jdk8-openjdk</from>
<workdir>/usr/local/skywalking/scenario</workdir>
<env>
<CATALINA_OPTS>""</CATALINA_OPTS>
</env>
<assembly>
<mode>dir</mode>
<targetDir>/</targetDir>
<descriptor>assembly.xml</descriptor>
</assembly>
<runCmds>
<run>chmod +x /run.sh</run>
<run>chmod +x /usr/local/tomcat/bin/catalina.sh</run>
<run>tar -xvf ../tools/skywalking-mock-collector.tar.gz -C ../tools</run>
</runCmds>
<cmd>["/run.sh"]</cmd>
</build>
</image>
</images>
</configuration>
<executions>
<execution>
<id>build</id>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>jdk14</id>
<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.33.0</version>
<configuration>
<images>
<image>
<name>skywalking/agent-test-tomcat:jd414-${project.version}</name>
<build>
<from>tomcat:8.5.57-jdk14-openjdk</from>
<workdir>/usr/local/skywalking/scenario</workdir>
<env>
<CATALINA_OPTS>""</CATALINA_OPTS>
</env>
<assembly>
<mode>dir</mode>
<targetDir>/</targetDir>
<descriptor>assembly.xml</descriptor>
</assembly>
<runCmds>
<run>chmod +x /run.sh</run>
<run>chmod +x /usr/local/tomcat/bin/catalina.sh</run>
<run>tar -xvf ../tools/skywalking-mock-collector.tar.gz -C ../tools</run>
</runCmds>
<cmd>["/run.sh"]</cmd>
</build>
</image>
</images>
</configuration>
<executions>
<execution>
<id>build</id>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -0,0 +1,46 @@
<?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>dir</format>
</formats>
<fileSets>
<fileSet>
<directory>${project.basedir}/../../agent-test-tools/dist</directory>
<outputDirectory>usr/local/skywalking/tools</outputDirectory>
</fileSet>
</fileSets>
<files>
<file>
<source>${project.basedir}/src/main/docker/run.sh</source>
<outputDirectory>./</outputDirectory>
</file>
<file>
<source>${project.basedir}/src/main/docker/catalina.sh</source>
<outputDirectory>usr/local/tomcat/bin</outputDirectory>
</file>
</files>
</assembly>

View File

@ -16,7 +16,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
[[ -n $DEBUG_MODE ]] && set -ex
set -ex
[[ -n $DEBUG_MODE ]] && export
function exitOnError() {
echo -e "\033[31m[ERROR] $1\033[0m">&2
@ -84,7 +85,7 @@ java -jar \
-Xmx256m -Xms256m \
-DcaseName="${SCENARIO_NAME}-${SCENARIO_VERSION}" \
-DtestCasePath=${SCENARIO_HOME}/data/ \
${TOOLS_HOME}/skywalking-validator-tools.jar 1>${LOGS_HOME}/validator.out
${TOOLS_HOME}/skywalking-validator.jar 1>${LOGS_HOME}/validator.out
status=$?
if [[ $status -eq 0 ]]; then

View File

@ -37,7 +37,7 @@
</modules>
<properties>
<java.version>1.8</java.version>
<java.version>8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
@ -49,11 +49,7 @@
<lombok.version>1.18.10</lombok.version>
<snakeyaml.version>1.24</snakeyaml.version>
<maven-compiler-plugin.version>3.8.0</maven-compiler-plugin.version>
<docker-maven-plugin.version>0.4.13</docker-maven-plugin.version>
<docker.image.version>1.0.0</docker.image.version>
<skip.docker>true</skip.docker>
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
</properties>
<dependencies>
@ -107,16 +103,6 @@
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>${docker-maven-plugin.version}</version>
<configuration>
<imageName>skywalking/${project.name}</imageName>
<dockerDirectory>${project.basedir}/docker</dockerDirectory>
<skipDocker>${skip.docker}</skipDocker>
</configuration>
</plugin>
</plugins>
</build>

View File

@ -28,7 +28,9 @@ mvnw=${home}/../../mvnw
agent_home="${home}"/../../skywalking-agent
jacoco_home="${home}"/../jacoco
scenarios_home="${home}/scenarios"
num_of_testcases=0
num_of_testcases=
image_version="1.0.0"
print_help() {
echo "Usage: run.sh [OPTION] SCENARIO_NAME"
@ -51,6 +53,13 @@ parse_commandline() {
--debug)
debug_mode="on";
;;
--image_version)
image_version="$2"
shift
;;
--image_version=*)
image_version="${_key##--image_version=}"
;;
-h|--help)
print_help
exit 0
@ -81,7 +90,7 @@ printSystemInfo(){
}
do_cleanup() {
images=$(docker images -q "skywalking/agent-test-*:${BUILD_NO:=local}")
images=$(docker images -q "skywalking/agent-test-*")
[[ -n "${images}" ]] && docker rmi -f ${images}
images=$(docker images -qf "dangling=true")
[[ -n "${images}" ]] && docker rmi -f ${images}
@ -131,7 +140,7 @@ if [[ ! -d ${agent_home} ]]; then
echo "[WARN] SkyWalking Agent not exists"
${mvnw} --batch-mode -f ${home}/../../pom.xml -Pagent -DskipTests clean package
fi
[[ "$force_build" == "on" ]] && ${mvnw} --batch-mode -f ${home}/pom.xml clean package -DskipTests -DBUILD_NO=${BUILD_NO:=local} docker:build
[[ "$force_build" == "on" ]] && ${mvnw} --batch-mode -f ${home}/pom.xml clean package -DskipTests
workspace="${home}/workspace/${scenario_name}"
[[ -d ${workspace} ]] && rm -rf $workspace
@ -145,7 +154,6 @@ fi
echo "start submit job"
scenario_home=${scenarios_home}/${scenario_name} && cd ${scenario_home}
supported_version_file=${scenario_home}/support-version.list
if [[ ! -f $supported_version_file ]]; then
exitWithMessage "cannot found 'support-version.list' in directory ${scenario_name}"
@ -189,7 +197,7 @@ do
-Dagent.dir=${_agent_home} \
-Djacoco.home=${jacoco_home} \
-Ddebug.mode=${debug_mode} \
-Ddocker.image.version=${BUILD_NO:=local} \
-Ddocker.image.version=${image_version} \
${plugin_runner_helper} 1>${case_work_logs_dir}/helper.log
[[ $? -ne 0 ]] && exitWithMessage "${testcase_name}, generate script failure!"

View File

@ -16,22 +16,22 @@
-->
compose_file="${docker_compose_file}"
project_name=$(echo "${build_id}" |awk '{print tolower($0)}')
project_name=$(echo "${build_id}" |sed -e "s/\.//g" |awk '{print tolower($0)}')
docker_container_name="${docker_container_name}_1"
<#noparse>
container_name="${project_name}_${docker_container_name}"
docker-compose -p ${project_name} -f ${compose_file} up -d
container=`docker ps -qf "name=${container_name}"`
if [[ -z "${container}" ]]; then
container_id=`docker ps -qf "name=${container_name}"`
if [[ -z "${container_id}" ]]; then
echo "docker startup failure!" >&2
status=1
else
status=`docker wait ${container}`
if [[ $status -ne 0 ]]; then
docker logs ${container} >&2
fi
status=`docker wait ${container_id}`
[[ $status -ne 0 ]] && docker logs ${container_id} >&2
docker logs ${container_id} >${SCENARIO_HOME}/logs/container.log
docker-compose -p ${project_name} -f ${compose_file} kill
docker-compose -p ${project_name} -f ${compose_file} rm -f

View File

@ -15,7 +15,7 @@
~ limitations under the License.
-->
docker run \
docker run -d \
--memory=1024m \
--name ${docker_container_name} \
--env SCENARIO_NAME=${scenario_name} \
@ -36,17 +36,20 @@ docker run \
-v ${agent_home}:/usr/local/skywalking/scenario/agent \
-v ${scenario_home}:/usr/local/skywalking/scenario \
-v ${jacoco_home}:/jacoco \
${docker_image_name}:${docker_image_version} 1>${scenario_home}/logs/container.log
${docker_image_name}:${docker_image_version}
status="$?"
sleep 3
container_name=`docker ps -aqf "name=${docker_container_name}"`
<#noparse>
status=$(docker wait ${container_name})
if [[ -z ${container_name} ]]; then
echo "docker startup failure!" >&2
status=1
else
[[ $status -ne 0 ]] && docker logs ${container_name} >&2
docker logs ${container_name} >${SCENARIO_HOME}/logs/container.log
docker container rm -f $container_name
fi
</#noparse>

View File

@ -19,7 +19,7 @@ entryService: http://localhost:8080/activemq-scenario/case/activemq
healthCheck: http://localhost:8080/activemq-scenario/case/healthCheck
startScript: ./bin/startup.sh
environment:
- activemq.server=tcp://activemq-server:61616
- activemq.server=tcp://activemq-server:61616
dependencies:
activemq-server:
image: rmohr/activemq:${CASE_SERVER_IMAGE_VERSION}

View File

@ -1,3 +1,5 @@
#!/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
@ -14,18 +16,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
FROM openjdk:8
MAINTAINER zhangxin@apache.org
home="$(cd "$(dirname $0)"; pwd)"
WORKDIR /usr/local/skywalking/tools
COPY run.sh /
RUN chmod +x /run.sh
COPY skywalking-validator.jar /usr/local/skywalking/tools/skywalking-validator-tools.jar
COPY skywalking-mock-collector.tar.gz /usr/local/skywalking/tools
RUN tar -xvf skywalking-mock-collector.tar.gz -C /usr/local/skywalking/tools
WORKDIR /usr/local/skywalking/scenario
CMD ["/run.sh"]
java -jar --enable-preview ${agent_opts} ${home}/../libs/jdk14-with-gson-scenario.jar &

View File

@ -0,0 +1,77 @@
# 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.
segmentItems:
- serviceName: jdk14-with-gson-scenario
segmentSize: ge 2
segments:
- segmentId: nq 0
spans:
- operationName: Gson/ToJson
operationId: 0
parentSpanId: 0
spanId: 1
spanLayer: Unknown
tags:
- {key: length, value: not null}
startTime: nq 0
endTime: nq 0
componentId: 55
isError: false
spanType: Local
peer: ' '
skipAnalysis: 'false'
- operationName: Gson/FromJson
operationId: 0
parentSpanId: 0
spanId: 2
spanLayer: Unknown
tags:
- {key: length, value: not null}
startTime: nq 0
endTime: nq 0
componentId: 55
isError: false
spanType: Local
peer: ''
skipAnalysis: 'false'
- operationName: /person/action
operationId: 0
parentSpanId: 0
spanId: 3
spanLayer: Unknown
startTime: nq 0
endTime: nq 0
componentId: 0
isError: false
spanType: Local
peer: ''
skipAnalysis: 'false'
tags:
- {key: key, value: value}
- operationName: /case/gson-scenario
operationId: 0
spanId: 0
spanLayer: Http
startTime: nq 0
endTime: nq 0
componentId: 14
isError: false
spanType: Entry
peer: ''
tags:
- {key: url, value: 'http://localhost:8080/gson-scenario/case/gson-scenario'}
- {key: http.method, value: GET}
skipAnalysis: 'false'

View File

@ -14,20 +14,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
FROM tomcat:8.5.42-jdk8-openjdk
MAINTAINER zhangxin@apache.org
WORKDIR /usr/local/skywalking/tools
ENV CATALINA_OPTS ""
COPY run.sh /
COPY catalina.sh /usr/local/tomcat/bin/
COPY skywalking-validator.jar /usr/local/skywalking/tools/skywalking-validator-tools.jar
COPY skywalking-mock-collector.tar.gz /usr/local/skywalking/tools
RUN tar -xvf skywalking-mock-collector.tar.gz -C /usr/local/skywalking/tools
RUN chmod +x /usr/local/tomcat/bin/catalina.sh && chmod +x /run.sh
WORKDIR /usr/local/skywalking/scenario
CMD ["/run.sh"]
type: jvm
entryService: http://localhost:8080/gson-scenario/case/gson-scenario
healthCheck: http://localhost:8080/gson-scenario/case/healthCheck
startScript: ./bin/startup.sh
runningMode: with_optional
withPlugins: apm-gson-2.x-plugin-*.jar
environment:
dependencies:

View File

@ -0,0 +1,149 @@
<?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>jdk14-with-gson-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>14</compiler.version>
<spring-boot-version>2.2.6.RELEASE</spring-boot-version>
<test.framework.version>2.8.5</test.framework.version>
<docker.image.version>${test.framework.version}</docker.image.version>
<log4j.version>2.6.2</log4j.version>
<spring.version>4.3.8.RELEASE</spring.version>
<apm-toolkit-trace.version>8.1.0</apm-toolkit-trace.version>
</properties>
<name>skywalking-jdk14-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>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>
<dependency>
<groupId>org.apache.skywalking</groupId>
<artifactId>apm-toolkit-trace</artifactId>
<version>${apm-toolkit-trace.version}</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${test.framework.version}</version>
</dependency>
</dependencies>
<build>
<finalName>jdk14-with-gson-scenario</finalName>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgs>--enable-preview</compilerArgs>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>--enable-preview</argLine>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<argLine>--enable-preview</argLine>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<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>

View File

@ -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}/jdk14-with-gson-scenario.jar</source>
<outputDirectory>./libs</outputDirectory>
<fileMode>0775</fileMode>
</file>
</files>
</assembly>

View File

@ -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 test.apache.skywalking.apm.testcase.gson;
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
}
}
}

View File

@ -0,0 +1,56 @@
/*
* 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 test.apache.skywalking.apm.testcase.gson.controller;
import com.google.gson.Gson;
import org.apache.skywalking.apm.toolkit.trace.ActiveSpan;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/case")
public class CaseController {
private static final String SUCCESS = "Success";
@RequestMapping("/gson-scenario")
@ResponseBody
public String gsonCase() {
Gson gson = new Gson();
Person person = new Person("skywalking", "jdk14");
gson.fromJson(gson.toJson(person), Person.class);
person.action();
return SUCCESS;
}
@RequestMapping("/healthCheck")
@ResponseBody
public String healthCheck() {
return SUCCESS;
}
public record Person(String name, String uuid) {
@Trace(operationName = "/person/action")
public void action() {
ActiveSpan.tag("key", "value");
}
}
}

View File

@ -0,0 +1,23 @@
#
# 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: /gson-scenario
logging:
config: classpath:log4j2.xml

View File

@ -0,0 +1,30 @@
<?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>

View File

@ -0,0 +1,19 @@
# 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.
# lists your version here
2.8.6