support jdk17 in agent plugin testing, add test case plugin on jdk17 (#55)
This commit is contained in:
parent
02d6b9c2d8
commit
d7f1588a8c
|
|
@ -62,8 +62,9 @@ jobs:
|
|||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: true
|
||||
- uses: actions/setup-java@v1
|
||||
- uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: adopt
|
||||
java-version: 14
|
||||
- name: Run Test
|
||||
uses: ./.github/actions/run
|
||||
|
|
|
|||
|
|
@ -0,0 +1,73 @@
|
|||
# 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: Test
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- '.github/workflows/plugins-*.yaml'
|
||||
- 'apm-application-toolkit/**'
|
||||
- 'apm-commons/**'
|
||||
- 'apm-protocol/**'
|
||||
- 'apm-sniffer/**'
|
||||
- 'test/plugin/**'
|
||||
- '**/pom.xml'
|
||||
- '!**.md'
|
||||
push:
|
||||
branches:
|
||||
- test/ci/*
|
||||
|
||||
concurrency:
|
||||
group: plugins-jdk17-${{ github.event.pull_request.number || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: true
|
||||
- name: Build
|
||||
uses: ./.github/actions/build
|
||||
with:
|
||||
java_version: jdk17
|
||||
|
||||
test:
|
||||
needs: [ build ]
|
||||
name: ${{ matrix.case }}
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 90
|
||||
strategy:
|
||||
matrix:
|
||||
case:
|
||||
- jdk17-with-gson-scenario
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: true
|
||||
- uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '17'
|
||||
- name: Run Test
|
||||
uses: ./.github/actions/run
|
||||
with:
|
||||
test_case: ${{ matrix.case }}
|
||||
java_version: jdk17
|
||||
|
|
@ -90,8 +90,9 @@ jobs:
|
|||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: true
|
||||
- uses: actions/setup-java@v1
|
||||
- uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: adopt
|
||||
java-version: 8
|
||||
- name: Run Plugin Test
|
||||
uses: ./.github/actions/run
|
||||
|
|
|
|||
|
|
@ -81,8 +81,9 @@ jobs:
|
|||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: true
|
||||
- uses: actions/setup-java@v1
|
||||
- uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: adopt
|
||||
java-version: 8
|
||||
- name: Run Plugin Test
|
||||
uses: ./.github/actions/run
|
||||
|
|
|
|||
|
|
@ -83,8 +83,9 @@ jobs:
|
|||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: true
|
||||
- uses: actions/setup-java@v1
|
||||
- uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: adopt
|
||||
java-version: 8
|
||||
- name: Run Plugin Test
|
||||
uses: ./.github/actions/run
|
||||
|
|
|
|||
|
|
@ -96,8 +96,9 @@ jobs:
|
|||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: true
|
||||
- uses: actions/setup-java@v1
|
||||
- uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: adopt
|
||||
java-version: 8
|
||||
- name: Install Oracle Libs
|
||||
if: matrix.case == 'oracle-scenario'
|
||||
|
|
|
|||
|
|
@ -20,17 +20,18 @@ The test framework provides `JVM-container` and `Tomcat-container` base images i
|
|||
|
||||
### JVM-container Image Introduction
|
||||
|
||||
[JVM-container](../../../../../test/plugin/containers/jvm-container) uses `openjdk:8` as the base image. `JVM-container` supports JDK14, which inherits `openjdk:14`.
|
||||
[JVM-container](../../../../../test/plugin/containers/jvm-container) uses `adoptopenjdk/openjdk8:alpine-jre` as the base image. `JVM-container` supports JDK14 and JDK17 as well, which inherits `adoptopenjdk/openjdk8:alpine-jre` and `eclipse-temurin:17-alpine`.
|
||||
The test case project must be packaged as `project-name.zip`, including `startup.sh` and uber jar, by using `mvn clean package`.
|
||||
|
||||
Take the following test projects as examples:
|
||||
* [sofarpc-scenario](../../../../../test/plugin/scenarios/sofarpc-scenario) is a single project case.
|
||||
* [webflux-scenario](../../../../../test/plugin/scenarios/webflux-scenario) is a case including multiple projects.
|
||||
* [jdk14-with-gson-scenario](../../../../../test/plugin/scenarios/jdk14-with-gson-scenario) is a single project case with JDK14.
|
||||
* [jdk17-with-gson-scenario](../../../../../test/plugin/scenarios/jdk17-with-gson-scenario) is a single project case with JDK17.
|
||||
|
||||
### Tomcat-container Image Introduction
|
||||
|
||||
[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.
|
||||
[Tomcat-container](../../../../../test/plugin/containers/tomcat-container) uses `tomcat:8.5-jdk8-openjdk`, `tomcat:8.5-jdk14-openjdk` or `tomcat:8.5-jdk17-openjdk` as the base image.
|
||||
The test case project must be packaged as `project-name.war` by using `mvn package`.
|
||||
|
||||
Take the following test project as an example
|
||||
|
|
|
|||
|
|
@ -31,6 +31,46 @@
|
|||
|
||||
<artifactId>jvm-container</artifactId>
|
||||
<name>SkyWalking JVM Runner Image</name>
|
||||
<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:${java.version}-${project.version}</name>
|
||||
<build>
|
||||
<from>${base.image.java}</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>
|
||||
<run>apk add --no-cache bash curl</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>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
|
|
@ -38,88 +78,24 @@
|
|||
<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:jdk8-${project.version}</name>
|
||||
<build>
|
||||
<from>openjdk:8u102</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>
|
||||
<properties>
|
||||
<base.image.java>adoptopenjdk/openjdk8:alpine</base.image.java>
|
||||
<java.version>jdk8</java.version>
|
||||
</properties>
|
||||
</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-buster</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>
|
||||
<properties>
|
||||
<base.image.java>adoptopenjdk/openjdk14:alpine</base.image.java>
|
||||
<java.version>jdk14</java.version>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>jdk17</id>
|
||||
<properties>
|
||||
<base.image.java>eclipse-temurin:17-alpine</base.image.java>
|
||||
<java.version>jdk17</java.version>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
|
|
|
|||
|
|
@ -16,15 +16,14 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set -ex
|
||||
[[ -n $DEBUG_MODE ]] && export
|
||||
|
||||
function exitOnError() {
|
||||
exitOnError() {
|
||||
echo -e "\033[31m[ERROR] $1\033[0m">&2
|
||||
exitAndClean 1
|
||||
}
|
||||
|
||||
function exitAndClean() {
|
||||
exitAndClean() {
|
||||
[[ -n $DEBUG_MODE ]] && exit $1;
|
||||
|
||||
[[ -f ${SCENARIO_HOME}/data/actualData.yaml ]] && rm -rf ${SCENARIO_HOME}/data/actualData.yaml
|
||||
|
|
@ -32,21 +31,23 @@ function exitAndClean() {
|
|||
exit $1
|
||||
}
|
||||
|
||||
function healthCheck() {
|
||||
healthCheck() {
|
||||
HEALTH_CHECK_URL=$1
|
||||
STATUS_CODE="-1"
|
||||
STATUS=""
|
||||
TIMES=${TIMES:-150}
|
||||
for ((i=1; i<=${TIMES}; i++));
|
||||
i=1
|
||||
while [[ $i -lt ${TIMES} ]];
|
||||
do
|
||||
STATUS_CODE="$(curl --max-time 3 -Is ${HEALTH_CHECK_URL} | head -n 1)"
|
||||
if [[ $STATUS_CODE == *"200"* ]]; then
|
||||
echo "${HEALTH_CHECK_URL}: ${STATUS_CODE}"
|
||||
STATUS=$(curl --max-time 3 -Is ${HEALTH_CHECK_URL} | grep -oE "HTTP/.*\s+200")
|
||||
if [[ -n "$STATUS" ]]; then
|
||||
echo "${HEALTH_CHECK_URL}: ${STATUS}"
|
||||
return 0
|
||||
fi
|
||||
sleep 2
|
||||
i=$(($i + 1))
|
||||
done
|
||||
|
||||
exitOnError "${SCENARIO_NAME}-${SCENARIO_VERSION} url=${HEALTH_CHECK_URL}, status=${STATUS_CODE} health check failed!"
|
||||
exitOnError "${SCENARIO_NAME}-${SCENARIO_VERSION} url=${HEALTH_CHECK_URL}, status=${STATUS} health check failed!"
|
||||
}
|
||||
|
||||
if [[ -z "${SCENARIO_START_SCRIPT}" ]]; then
|
||||
|
|
@ -66,7 +67,7 @@ if [[ ! -f /var/run/${SCENARIO_NAME}/${SCENARIO_START_SCRIPT} ]]; then
|
|||
fi
|
||||
|
||||
echo "To start mock collector"
|
||||
${TOOLS_HOME}/skywalking-mock-collector/bin/collector-startup.sh 1>${LOGS_HOME}/collector.out &
|
||||
bash ${TOOLS_HOME}/skywalking-mock-collector/bin/collector-startup.sh 1>${LOGS_HOME}/collector.out &
|
||||
healthCheck http://localhost:12800/receiveData
|
||||
|
||||
# start applications
|
||||
|
|
@ -82,7 +83,8 @@ export agent_opts="
|
|||
-Dskywalking.agent.authentication=test-token
|
||||
-Dskywalking.meter.report_interval=1
|
||||
-Xms256m -Xmx256m ${agent_opts}"
|
||||
exec /var/run/${SCENARIO_NAME}/${SCENARIO_START_SCRIPT} 1>${LOGS_HOME}/scenario.out &
|
||||
|
||||
bash /var/run/${SCENARIO_NAME}/${SCENARIO_START_SCRIPT} 1>${LOGS_HOME}/scenario.out &
|
||||
|
||||
healthCheck ${SCENARIO_HEALTH_CHECK_URL}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,49 @@
|
|||
|
||||
<artifactId>tomcat-container</artifactId>
|
||||
<name>SkyWalking Tomcat Runner Image</name>
|
||||
<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:${java.version}-${project.version}</name>
|
||||
<build>
|
||||
<from>${base.image.tomcat}</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>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
|
|
@ -38,98 +81,24 @@
|
|||
<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:jdk8-${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>
|
||||
<properties>
|
||||
<base.image.tomcat>tomcat:8.5-jdk8-openjdk</base.image.tomcat>
|
||||
<java.version>jdk8</java.version>
|
||||
</properties>
|
||||
</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:jdk14-${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>
|
||||
<properties>
|
||||
<base.image.tomcat>tomcat:8.5-jdk14-openjdk</base.image.tomcat>
|
||||
<java.version>jdk14</java.version>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>jdk17</id>
|
||||
<properties>
|
||||
<base.image.tomcat>tomcat:8.5-jdk17-openjdk</base.image.tomcat>
|
||||
<java.version>jdk17</java.version>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
|
||||
</project>
|
||||
</project>
|
||||
|
|
@ -157,9 +157,8 @@ sed -i '' '/<\/sourceDirectories>/i\'$'\n''<sourceDirectory>scenarios\/'"$scenar
|
|||
sed -i '/<\/sourceDirectories>/i <sourceDirectory>scenarios\/'"$scenario_name"'<\/sourceDirectory>' ./pom.xml
|
||||
|
||||
if [[ "$force_build" == "on" ]]; then
|
||||
profile=
|
||||
[[ $image_version =~ "jdk14-" ]] && profile="-Pjdk14"
|
||||
${mvnw} --batch-mode -f ${home}/pom.xml clean package -DskipTests ${profile}
|
||||
profile=$(echo ${image_version} | grep -oE "jdk[0-9]+")
|
||||
${mvnw} --batch-mode -f ${home}/pom.xml clean package -DskipTests -P${profile}
|
||||
fi
|
||||
# remove scenario_name into plugin/pom.xml
|
||||
sed -i '' '/<sourceDirectory>scenarios\/'"$scenario_name"'<\/sourceDirectory>/d' ./pom.xml \
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
#!/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 --enable-preview ${agent_opts} ${home}/../libs/jdk17-with-gson-scenario.jar &
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
# 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: jdk17-with-gson-scenario
|
||||
segmentSize: ge 2
|
||||
segments:
|
||||
- segmentId: nq 0
|
||||
spans:
|
||||
- operationName: Gson/ToJson
|
||||
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
|
||||
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
|
||||
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: GET:/case/gson-scenario
|
||||
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'
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
# 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/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:
|
||||
|
|
@ -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>jdk17-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>17</compiler.version>
|
||||
<spring-boot-version>2.5.6</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-jdk17-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>
|
||||
<version>2.5.6</version>
|
||||
</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>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.rabbitmq</groupId>
|
||||
<artifactId>http-client</artifactId>
|
||||
<version>1.1.1.RELEASE</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>jdk17-with-gson-scenario</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>
|
||||
<groupId>com.rabbitmq</groupId>
|
||||
<artifactId>http-client</artifactId>
|
||||
</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
|
||||
</configuration>
|
||||
</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>
|
||||
|
|
@ -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}/jdk17-with-gson-scenario.jar</source>
|
||||
<outputDirectory>./libs</outputDirectory>
|
||||
<fileMode>0775</fileMode>
|
||||
</file>
|
||||
</files>
|
||||
</assembly>
|
||||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,125 @@
|
|||
/*
|
||||
* 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 com.google.gson.GsonBuilder;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.TypeAdapterFactory;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonToken;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.HashMap;
|
||||
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() {
|
||||
var gson = new GsonBuilder()
|
||||
.registerTypeAdapterFactory(new RecordTypeAdapterFactory())
|
||||
.create();
|
||||
Person person = new Person("skywalking", "jdk17");
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
public static class RecordTypeAdapterFactory implements TypeAdapterFactory {
|
||||
|
||||
@Override
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<T> clazz = (Class<T>) type.getRawType();
|
||||
if (!clazz.isRecord()) {
|
||||
return null;
|
||||
}
|
||||
TypeAdapter<T> delegate = gson.getDelegateAdapter(this, type);
|
||||
|
||||
return new TypeAdapter<T>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, T value) throws IOException {
|
||||
delegate.write(out, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T read(JsonReader reader) throws IOException {
|
||||
if (reader.peek() == JsonToken.NULL) {
|
||||
reader.nextNull();
|
||||
return null;
|
||||
} else {
|
||||
var recordComponents = clazz.getRecordComponents();
|
||||
var typeMap = new HashMap<String, TypeToken<?>>();
|
||||
for (int i = 0; i < recordComponents.length; i++) {
|
||||
typeMap.put(recordComponents[i].getName(), TypeToken.get(recordComponents[i].getGenericType()));
|
||||
}
|
||||
var argsMap = new HashMap<String, Object>();
|
||||
reader.beginObject();
|
||||
while (reader.hasNext()) {
|
||||
String name = reader.nextName();
|
||||
argsMap.put(name, gson.getAdapter(typeMap.get(name)).read(reader));
|
||||
}
|
||||
reader.endObject();
|
||||
|
||||
var argTypes = new Class<?>[recordComponents.length];
|
||||
var args = new Object[recordComponents.length];
|
||||
for (int i = 0; i < recordComponents.length; i++) {
|
||||
argTypes[i] = recordComponents[i].getType();
|
||||
args[i] = argsMap.get(recordComponents[i].getName());
|
||||
}
|
||||
Constructor<T> constructor;
|
||||
try {
|
||||
constructor = clazz.getDeclaredConstructor(argTypes);
|
||||
constructor.setAccessible(true);
|
||||
return constructor.newInstance(args);
|
||||
} catch (NoSuchMethodException | InstantiationException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
@ -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>
|
||||
|
|
@ -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.
|
||||
|
||||
2.8.6
|
||||
|
|
@ -13,6 +13,6 @@
|
|||
# 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.
|
||||
mysql.url=jdbc:mysql://mysql-server:3306/test?serverTimezone=CST
|
||||
mysql.url=jdbc:mysql://mysql-server:3306/test?serverTimezone=CST&enabledTLSProtocols=TLSv1.2&useSSL=false
|
||||
mysql.username=root
|
||||
mysql.password=root
|
||||
|
|
|
|||
Loading…
Reference in New Issue