From 6c1659c56a75566ef741cf8b5a800111ed07ca27 Mon Sep 17 00:00:00 2001 From: Daming Date: Mon, 24 Aug 2020 20:17:22 +0800 Subject: [PATCH] [plugin/test] Plugin test with jdk14 (#5352) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 Co-authored-by: 吴晟 Wu Sheng Co-authored-by: kezhenxu94 Co-authored-by: kezhenxu94 --- .github/workflows/plugins-jdk14-test.0.yaml | 49 ++++++ .github/workflows/plugins-test.0.yaml | 2 +- .github/workflows/plugins-test.1.yaml | 2 +- .github/workflows/plugins-test.2.yaml | 2 +- .github/workflows/plugins-test.3.yaml | 4 +- docs/en/guides/Plugin-test.md | 11 +- test/plugin/containers/jvm-container/pom.xml | 96 ++++++++++- .../src/main/docker/assembly.xml | 42 +++++ .../{ => src/main}/docker/run.sh | 7 +- test/plugin/containers/pom.xml | 29 ---- .../containers/tomcat-container/pom.xml | 103 +++++++++++- .../src/main/docker/assembly.xml | 46 ++++++ .../{ => src/main}/docker/catalina.sh | 0 .../{ => src/main}/docker/run.sh | 5 +- test/plugin/pom.xml | 18 +-- test/plugin/run.sh | 18 ++- .../resources/compose-start-script.template | 14 +- .../resources/container-start-script.template | 11 +- .../activemq-scenario/configuration.yml | 2 +- .../jdk14-with-gson-scenario/bin/startup.sh} | 18 +-- .../config/expectedData.yaml | 77 +++++++++ .../configuration.yml} | 25 +-- .../jdk14-with-gson-scenario/pom.xml | 149 ++++++++++++++++++ .../src/main/assembly/assembly.xml | 41 +++++ .../apm/testcase/gson/Application.java | 34 ++++ .../gson/controller/CaseController.java | 56 +++++++ .../src/main/resources/application.yaml | 23 +++ .../src/main/resources/log4j2.xml | 30 ++++ .../support-version.list | 19 +++ 29 files changed, 818 insertions(+), 115 deletions(-) create mode 100644 .github/workflows/plugins-jdk14-test.0.yaml create mode 100644 test/plugin/containers/jvm-container/src/main/docker/assembly.xml rename test/plugin/containers/jvm-container/{ => src/main}/docker/run.sh (96%) create mode 100644 test/plugin/containers/tomcat-container/src/main/docker/assembly.xml rename test/plugin/containers/tomcat-container/{ => src/main}/docker/catalina.sh (100%) rename test/plugin/containers/tomcat-container/{ => src/main}/docker/run.sh (96%) rename test/plugin/{containers/jvm-container/docker/Dockerfile => scenarios/jdk14-with-gson-scenario/bin/startup.sh} (65%) create mode 100644 test/plugin/scenarios/jdk14-with-gson-scenario/config/expectedData.yaml rename test/plugin/{containers/tomcat-container/docker/Dockerfile => scenarios/jdk14-with-gson-scenario/configuration.yml} (59%) create mode 100644 test/plugin/scenarios/jdk14-with-gson-scenario/pom.xml create mode 100644 test/plugin/scenarios/jdk14-with-gson-scenario/src/main/assembly/assembly.xml create mode 100644 test/plugin/scenarios/jdk14-with-gson-scenario/src/main/java/test/apache/skywalking/apm/testcase/gson/Application.java create mode 100644 test/plugin/scenarios/jdk14-with-gson-scenario/src/main/java/test/apache/skywalking/apm/testcase/gson/controller/CaseController.java create mode 100644 test/plugin/scenarios/jdk14-with-gson-scenario/src/main/resources/application.yaml create mode 100644 test/plugin/scenarios/jdk14-with-gson-scenario/src/main/resources/log4j2.xml create mode 100644 test/plugin/scenarios/jdk14-with-gson-scenario/support-version.list diff --git a/.github/workflows/plugins-jdk14-test.0.yaml b/.github/workflows/plugins-jdk14-test.0.yaml new file mode 100644 index 000000000..431967a8b --- /dev/null +++ b/.github/workflows/plugins-jdk14-test.0.yaml @@ -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 diff --git a/.github/workflows/plugins-test.0.yaml b/.github/workflows/plugins-test.0.yaml index 8711bc15d..63fa1a227 100644 --- a/.github/workflows/plugins-test.0.yaml +++ b/.github/workflows/plugins-test.0.yaml @@ -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 diff --git a/.github/workflows/plugins-test.1.yaml b/.github/workflows/plugins-test.1.yaml index f9fdd74b9..2b4e1fd17 100644 --- a/.github/workflows/plugins-test.1.yaml +++ b/.github/workflows/plugins-test.1.yaml @@ -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 diff --git a/.github/workflows/plugins-test.2.yaml b/.github/workflows/plugins-test.2.yaml index fd1ef987e..0f5feec79 100644 --- a/.github/workflows/plugins-test.2.yaml +++ b/.github/workflows/plugins-test.2.yaml @@ -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 diff --git a/.github/workflows/plugins-test.3.yaml b/.github/workflows/plugins-test.3.yaml index b038dd8c9..cc15a9a35 100644 --- a/.github/workflows/plugins-test.3.yaml +++ b/.github/workflows/plugins-test.3.yaml @@ -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 diff --git a/docs/en/guides/Plugin-test.md b/docs/en/guides/Plugin-test.md index 2cf26782e..a05e613cb 100644 --- a/docs/en/guides/Plugin-test.md +++ b/docs/en/guides/Plugin-test.md @@ -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 ` + + ()` as the Job `title`, and the scenario directory as the Job `name`, mostly you'll just need to decide which file (`plugins-test..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..yaml`. + ```yaml jobs: PluginsTest: diff --git a/test/plugin/containers/jvm-container/pom.xml b/test/plugin/containers/jvm-container/pom.xml index 6a21a8852..351bae8b9 100644 --- a/test/plugin/containers/jvm-container/pom.xml +++ b/test/plugin/containers/jvm-container/pom.xml @@ -32,8 +32,96 @@ jvm-container SkyWalking JVM Runner Image - - false - skywalking/agent-test-jvm - + + + jdk8 + + true + + + + + io.fabric8 + docker-maven-plugin + 0.33.0 + + + + skywalking/agent-test-jvm:${project.version} + + openjdk:8 + /usr/local/skywalking/scenario + + dir + /usr/local/skywalking + assembly.xml + + + chmod +x /usr/local/skywalking/run.sh + tar -xvf ../tools/skywalking-mock-collector.tar.gz -C ../tools + + ["/usr/local/skywalking/run.sh"] + + + + + + + build + package + + build + + + + + + + + + + jdk14 + + + + io.fabric8 + docker-maven-plugin + 0.33.0 + + + + skywalking/agent-test-jvm:jdk14-${project.version} + + openjdk:14 + /usr/local/skywalking/scenario + + dir + /usr/local/skywalking + assembly.xml + + + yum install -y unzip + chmod +x /usr/local/skywalking/run.sh + tar -xvf ../tools/skywalking-mock-collector.tar.gz -C ../tools + + ["/usr/local/skywalking/run.sh"] + + + + + + + build + package + + build + + + + + + + + + diff --git a/test/plugin/containers/jvm-container/src/main/docker/assembly.xml b/test/plugin/containers/jvm-container/src/main/docker/assembly.xml new file mode 100644 index 000000000..59b68de66 --- /dev/null +++ b/test/plugin/containers/jvm-container/src/main/docker/assembly.xml @@ -0,0 +1,42 @@ + + + + + + dir + + + + + ${project.basedir}/../../agent-test-tools/dist + tools + + + + + + ${project.basedir}/src/main/docker/run.sh + / + + + + diff --git a/test/plugin/containers/jvm-container/docker/run.sh b/test/plugin/containers/jvm-container/src/main/docker/run.sh similarity index 96% rename from test/plugin/containers/jvm-container/docker/run.sh rename to test/plugin/containers/jvm-container/src/main/docker/run.sh index b3169d8bd..273fa4c0a 100644 --- a/test/plugin/containers/jvm-container/docker/run.sh +++ b/test/plugin/containers/jvm-container/src/main/docker/run.sh @@ -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 diff --git a/test/plugin/containers/pom.xml b/test/plugin/containers/pom.xml index fec697b1b..7416ddc11 100644 --- a/test/plugin/containers/pom.xml +++ b/test/plugin/containers/pom.xml @@ -36,33 +36,4 @@ tomcat-container jvm-container - - - true - skywalking/${project.name} - - - - - - com.spotify - docker-maven-plugin - ${docker-maven-plugin.version} - - - ${docker.image.name}:${BUILD_NO} - ${project.basedir}/docker - ${skip.docker} - - - / - ${project.basedir}/../../agent-test-tools/dist - skywalking-mock-collector.tar.gz - skywalking-validator.jar - - - - - - diff --git a/test/plugin/containers/tomcat-container/pom.xml b/test/plugin/containers/tomcat-container/pom.xml index 190c46d97..751f22ad1 100644 --- a/test/plugin/containers/tomcat-container/pom.xml +++ b/test/plugin/containers/tomcat-container/pom.xml @@ -32,9 +32,104 @@ tomcat-container SkyWalking Tomcat Runner Image - - false - skywalking/agent-test-tomcat - + + + jdk8 + + true + + + + + io.fabric8 + docker-maven-plugin + 0.33.0 + + + + skywalking/agent-test-tomcat:${project.version} + + tomcat:8.5.57-jdk8-openjdk + /usr/local/skywalking/scenario + + "" + + + dir + / + assembly.xml + + + chmod +x /run.sh + chmod +x /usr/local/tomcat/bin/catalina.sh + tar -xvf ../tools/skywalking-mock-collector.tar.gz -C ../tools + + ["/run.sh"] + + + + + + + build + package + + build + + + + + + + + + + jdk14 + + + + io.fabric8 + docker-maven-plugin + 0.33.0 + + + + skywalking/agent-test-tomcat:jd414-${project.version} + + tomcat:8.5.57-jdk14-openjdk + /usr/local/skywalking/scenario + + "" + + + dir + / + assembly.xml + + + chmod +x /run.sh + chmod +x /usr/local/tomcat/bin/catalina.sh + tar -xvf ../tools/skywalking-mock-collector.tar.gz -C ../tools + + ["/run.sh"] + + + + + + + build + package + + build + + + + + + + + + diff --git a/test/plugin/containers/tomcat-container/src/main/docker/assembly.xml b/test/plugin/containers/tomcat-container/src/main/docker/assembly.xml new file mode 100644 index 000000000..571457c62 --- /dev/null +++ b/test/plugin/containers/tomcat-container/src/main/docker/assembly.xml @@ -0,0 +1,46 @@ + + + + + + dir + + + + + ${project.basedir}/../../agent-test-tools/dist + usr/local/skywalking/tools + + + + + + ${project.basedir}/src/main/docker/run.sh + ./ + + + ${project.basedir}/src/main/docker/catalina.sh + usr/local/tomcat/bin + + + + diff --git a/test/plugin/containers/tomcat-container/docker/catalina.sh b/test/plugin/containers/tomcat-container/src/main/docker/catalina.sh similarity index 100% rename from test/plugin/containers/tomcat-container/docker/catalina.sh rename to test/plugin/containers/tomcat-container/src/main/docker/catalina.sh diff --git a/test/plugin/containers/tomcat-container/docker/run.sh b/test/plugin/containers/tomcat-container/src/main/docker/run.sh similarity index 96% rename from test/plugin/containers/tomcat-container/docker/run.sh rename to test/plugin/containers/tomcat-container/src/main/docker/run.sh index d8056eb89..921905547 100644 --- a/test/plugin/containers/tomcat-container/docker/run.sh +++ b/test/plugin/containers/tomcat-container/src/main/docker/run.sh @@ -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 diff --git a/test/plugin/pom.xml b/test/plugin/pom.xml index d93df7bb4..07b5a830d 100644 --- a/test/plugin/pom.xml +++ b/test/plugin/pom.xml @@ -37,7 +37,7 @@ - 1.8 + 8 ${java.version} ${java.version} @@ -49,11 +49,7 @@ 1.18.10 1.24 - 3.8.0 - 0.4.13 - - 1.0.0 - true + 3.8.1 @@ -107,16 +103,6 @@ ${project.build.sourceEncoding} - - com.spotify - docker-maven-plugin - ${docker-maven-plugin.version} - - skywalking/${project.name} - ${project.basedir}/docker - ${skip.docker} - - diff --git a/test/plugin/run.sh b/test/plugin/run.sh index a76822e7e..fd149ccb2 100755 --- a/test/plugin/run.sh +++ b/test/plugin/run.sh @@ -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!" diff --git a/test/plugin/runner-helper/src/main/resources/compose-start-script.template b/test/plugin/runner-helper/src/main/resources/compose-start-script.template index 1e6a52832..947eb199c 100644 --- a/test/plugin/runner-helper/src/main/resources/compose-start-script.template +++ b/test/plugin/runner-helper/src/main/resources/compose-start-script.template @@ -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 diff --git a/test/plugin/runner-helper/src/main/resources/container-start-script.template b/test/plugin/runner-helper/src/main/resources/container-start-script.template index 06a3c1364..108fb0bf2 100644 --- a/test/plugin/runner-helper/src/main/resources/container-start-script.template +++ b/test/plugin/runner-helper/src/main/resources/container-start-script.template @@ -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 diff --git a/test/plugin/scenarios/activemq-scenario/configuration.yml b/test/plugin/scenarios/activemq-scenario/configuration.yml index ab22076a7..fa7463e93 100644 --- a/test/plugin/scenarios/activemq-scenario/configuration.yml +++ b/test/plugin/scenarios/activemq-scenario/configuration.yml @@ -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} diff --git a/test/plugin/containers/jvm-container/docker/Dockerfile b/test/plugin/scenarios/jdk14-with-gson-scenario/bin/startup.sh similarity index 65% rename from test/plugin/containers/jvm-container/docker/Dockerfile rename to test/plugin/scenarios/jdk14-with-gson-scenario/bin/startup.sh index 740a4e413..761c94eb1 100644 --- a/test/plugin/containers/jvm-container/docker/Dockerfile +++ b/test/plugin/scenarios/jdk14-with-gson-scenario/bin/startup.sh @@ -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 & \ No newline at end of file diff --git a/test/plugin/scenarios/jdk14-with-gson-scenario/config/expectedData.yaml b/test/plugin/scenarios/jdk14-with-gson-scenario/config/expectedData.yaml new file mode 100644 index 000000000..3bbd67924 --- /dev/null +++ b/test/plugin/scenarios/jdk14-with-gson-scenario/config/expectedData.yaml @@ -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' diff --git a/test/plugin/containers/tomcat-container/docker/Dockerfile b/test/plugin/scenarios/jdk14-with-gson-scenario/configuration.yml similarity index 59% rename from test/plugin/containers/tomcat-container/docker/Dockerfile rename to test/plugin/scenarios/jdk14-with-gson-scenario/configuration.yml index 87ef9baf7..39e3a2b73 100644 --- a/test/plugin/containers/tomcat-container/docker/Dockerfile +++ b/test/plugin/scenarios/jdk14-with-gson-scenario/configuration.yml @@ -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: diff --git a/test/plugin/scenarios/jdk14-with-gson-scenario/pom.xml b/test/plugin/scenarios/jdk14-with-gson-scenario/pom.xml new file mode 100644 index 000000000..e268befac --- /dev/null +++ b/test/plugin/scenarios/jdk14-with-gson-scenario/pom.xml @@ -0,0 +1,149 @@ + + + + + org.apache.skywalking.apm.testcase + jdk14-with-gson-scenario + 1.0.0 + jar + + 4.0.0 + + + UTF-8 + 14 + 2.2.6.RELEASE + 2.8.5 + ${test.framework.version} + 2.6.2 + 4.3.8.RELEASE + 8.1.0 + + + skywalking-jdk14-scenario + + + + + org.springframework.boot + spring-boot-dependencies + ${spring-boot-version} + pom + import + + + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-logging + + + + + org.springframework.boot + spring-boot-starter-log4j2 + + + + org.apache.skywalking + apm-toolkit-trace + ${apm-toolkit-trace.version} + + + + com.google.code.gson + gson + ${test.framework.version} + + + + + jdk14-with-gson-scenario + + + + maven-compiler-plugin + + --enable-preview + + + + maven-surefire-plugin + + --enable-preview + + + + maven-failsafe-plugin + + --enable-preview + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + maven-compiler-plugin + + ${compiler.version} + ${compiler.version} + ${project.build.sourceEncoding} + + + + org.apache.maven.plugins + maven-assembly-plugin + + + assemble + package + + single + + + + src/main/assembly/assembly.xml + + ./target/ + + + + + + + \ No newline at end of file diff --git a/test/plugin/scenarios/jdk14-with-gson-scenario/src/main/assembly/assembly.xml b/test/plugin/scenarios/jdk14-with-gson-scenario/src/main/assembly/assembly.xml new file mode 100644 index 000000000..e0d864e25 --- /dev/null +++ b/test/plugin/scenarios/jdk14-with-gson-scenario/src/main/assembly/assembly.xml @@ -0,0 +1,41 @@ + + + + + zip + + + + + ./bin + 0775 + + + + + + ${project.build.directory}/jdk14-with-gson-scenario.jar + ./libs + 0775 + + + diff --git a/test/plugin/scenarios/jdk14-with-gson-scenario/src/main/java/test/apache/skywalking/apm/testcase/gson/Application.java b/test/plugin/scenarios/jdk14-with-gson-scenario/src/main/java/test/apache/skywalking/apm/testcase/gson/Application.java new file mode 100644 index 000000000..00341933b --- /dev/null +++ b/test/plugin/scenarios/jdk14-with-gson-scenario/src/main/java/test/apache/skywalking/apm/testcase/gson/Application.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package 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 + } + } +} diff --git a/test/plugin/scenarios/jdk14-with-gson-scenario/src/main/java/test/apache/skywalking/apm/testcase/gson/controller/CaseController.java b/test/plugin/scenarios/jdk14-with-gson-scenario/src/main/java/test/apache/skywalking/apm/testcase/gson/controller/CaseController.java new file mode 100644 index 000000000..966409fc4 --- /dev/null +++ b/test/plugin/scenarios/jdk14-with-gson-scenario/src/main/java/test/apache/skywalking/apm/testcase/gson/controller/CaseController.java @@ -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"); + } + } +} diff --git a/test/plugin/scenarios/jdk14-with-gson-scenario/src/main/resources/application.yaml b/test/plugin/scenarios/jdk14-with-gson-scenario/src/main/resources/application.yaml new file mode 100644 index 000000000..9c7f5df3a --- /dev/null +++ b/test/plugin/scenarios/jdk14-with-gson-scenario/src/main/resources/application.yaml @@ -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 \ No newline at end of file diff --git a/test/plugin/scenarios/jdk14-with-gson-scenario/src/main/resources/log4j2.xml b/test/plugin/scenarios/jdk14-with-gson-scenario/src/main/resources/log4j2.xml new file mode 100644 index 000000000..9849ed5a8 --- /dev/null +++ b/test/plugin/scenarios/jdk14-with-gson-scenario/src/main/resources/log4j2.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/plugin/scenarios/jdk14-with-gson-scenario/support-version.list b/test/plugin/scenarios/jdk14-with-gson-scenario/support-version.list new file mode 100644 index 000000000..22eacf467 --- /dev/null +++ b/test/plugin/scenarios/jdk14-with-gson-scenario/support-version.list @@ -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 \ No newline at end of file