diff --git a/Jenkinsfile-Agent-Test b/Jenkinsfile-Agent-Test index 8cc864cd6adb22d9200997d973903919c5180b56..bf898c2a2acaf43d1ed306a10e3cd6ef2ec07b19 100755 --- a/Jenkinsfile-Agent-Test +++ b/Jenkinsfile-Agent-Test @@ -54,23 +54,40 @@ pipeline { sh './mvnw -f test/plugin/pom.xml clean package -DskipTests -Dbuild_id=${BUILD_ID} docker:build' } } + stage ('Run Agent Plugin Tests') { + parallel { + stage ('Group1') { + stages { + stage('httpclient 4.3.x-4.5.x') { + steps { + sh 'bash test/plugin/run.sh --build_id=${BUILD_ID} httpclient-4.3.x-scenario' + } + } - stage('httpclient 4.3.x-4.5.x') { - steps { - sh 'bash test/plugin/run.sh --build_id=${BUILD_ID} httpclient-4.3.x-scenario' - } - } - - stage('ehcache 2.8.x-2.10.x') { - steps { - sh 'bash test/plugin/run.sh --build_id=${BUILD_ID} ehcache-2.x-scenario' + stage('ehcache 2.8.x-2.10.x') { + steps { + sh 'bash test/plugin/run.sh --build_id=${BUILD_ID} ehcache-2.x-scenario' + } + } + } + } + stage ('Group2') { + stages { + stage('jetty 9.x') { + steps { + sh 'bash test/plugin/run.sh --build_id=${BUILD_ID} jetty-scenario' + } + } + } + } } } } post { always { + sh 'bash test/plugin/run.sh --build_id=${BUILD_ID} --cleanup' deleteDir() } } -} +} \ No newline at end of file diff --git a/test/plugin/containers/jvm-container/docker/Dockerfile b/test/plugin/containers/jvm-container/docker/Dockerfile index 60131b57616cfbeb401375759d252e1e3488b4e9..175eb53ef124833b7a622bbe50922ff3d7fe1344 100644 --- a/test/plugin/containers/jvm-container/docker/Dockerfile +++ b/test/plugin/containers/jvm-container/docker/Dockerfile @@ -14,11 +14,18 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM openjdk:7 +FROM openjdk:8 MAINTAINER zhangxin@apache.org -ADD docker-entrypoint.sh / -RUN chmod +x /docker-entrypoint.sh +WORKDIR /usr/local/skywalking/tools -ENTRYPOINT ["/docker-entrypoint.sh"] -RUN ["/bin/bash"] +COPY run.sh / +RUN chmod +x /run.sh + +COPY skywalking-validator-tools.jar /usr/local/skywalking/tools +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"] diff --git a/test/plugin/containers/jvm-container/docker/run.sh b/test/plugin/containers/jvm-container/docker/run.sh new file mode 100644 index 0000000000000000000000000000000000000000..4ba21aa2857c3040f727f12de88b620b7f10b818 --- /dev/null +++ b/test/plugin/containers/jvm-container/docker/run.sh @@ -0,0 +1,99 @@ +#!/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. + + +function exitOnError() { + echo -e "\033[31m[ERROR] $1\033[0m">&2 + exitAndClean 1 +} + +function exitAndClean() { + [[ -f ${SCENARIO_HOME}/data/actualData.yaml ]] && rm -rf ${SCENARIO_HOME}/data/actualData.yaml + [[ -d ${SCENARIO_HOME}/logs ]] && rm -rf ${SCENARIO_HOME}/logs + [[ -d ${SCENARIO_HOME}/package ]] && rm -rf ${SCENARIO_HOME}/package + exit $1 +} + +function healthCheck() { + HEALTH_CHECK_URL=$1 + + for ((i=1; i<=30; i++)); + do + STATUS_CODE="$(curl -Is ${HEALTH_CHECK_URL} | head -n 1)" + if [[ $STATUS_CODE == *"200"* ]]; then + echo "${HEALTH_CHECK_URL}: ${STATUS_CODE}" + return 0 + fi + sleep 2 + done + + exitOnError "${SCENARIO_NAME}-${SCENARIO_VERSION} health check failed!" +} + +if [[ -z "${SCENARIO_START_SCRIPT}" ]]; then + exitOnError "The name of startup script cannot be empty!" +fi + +TOOLS_HOME=/usr/local/skywalking/tools +SCENARIO_HOME=/usr/local/skywalking/scenario + +unzip -q ${SCENARIO_HOME}/*.zip -d /var/run/ +if [[ ! -f /var/run/${SCENARIO_NAME}/${SCENARIO_START_SCRIPT} ]]; then + exitOnError "The required startup script not exists!" +fi + +echo "To start mock collector" +${TOOLS_HOME}/skywalking-mock-collector/bin/collector-startup.sh 1>/dev/null & +healthCheck http://localhost:12800/receiveData + +# start applications +export agent_opts="-javaagent:${SCENARIO_HOME}/agent/skywalking-agent.jar + -Dskywalking.collector.grpc_channel_check_interval=2 + -Dskywalking.collector.app_and_service_register_check_interval=2 + -Dskywalking.collector.discovery_check_interval=2 + -Dskywalking.collector.backend_service=localhost:19876 + -Dskywalking.agent.service_name=${SCENARIO_NAME} + -Dskywalking.logging.dir=/usr/local/skywalking/scenario/logs + -Xms256m -Xmx256m ${agent_opts}" +exec /var/run/${SCENARIO_NAME}/${SCENARIO_START_SCRIPT} 1>/dev/null & +healthCheck ${SCENARIO_HEALTH_CHECK_URL} + +echo "To visit entry service" +curl -s ${SCENARIO_ENTRY_SERVICE} +sleep 5 + +echo "To receive actual data" +curl -s http://localhost:12800/receiveData > ${SCENARIO_HOME}/data/actualData.yaml +[[ ! -f ${SCENARIO_HOME}/data/actualData.yaml ]] && exitOnError "${SCENARIO_NAME}-${SCENARIO_VERSION}, 'actualData.yaml' Not Found!" + +echo "To validate" +java -jar \ + -Dv2=true \ + -Xmx256m -Xms256m \ + -DtestDate="`date +%Y-%m-%d-%H-%M`" \ + -DtestCasePath=${SCENARIO_HOME}/data/ \ + ${TOOLS_HOME}/skywalking-validator-tools.jar 1>/dev/null +status=$? + +if [[ $status -eq 0 ]]; then + echo "Scenario[${SCENARIO_NAME}-${SCENARIO_VERSION}] passed!" >&2 +else + cat ${SCENARIO_HOME}/data/actualData.yaml >&2 + exitOnError "Scenario[${SCENARIO_NAME}-${SCENARIO_VERSION}] failed!" +fi +exitAndClean $status diff --git a/test/plugin/containers/tomcat-container/docker/run.sh b/test/plugin/containers/tomcat-container/docker/run.sh index dc27bb6dd979773e07e93e0a182f035e48f0f306..644864325e042cf04197d8fd59fd6e4cb37d6a5f 100644 --- a/test/plugin/containers/tomcat-container/docker/run.sh +++ b/test/plugin/containers/tomcat-container/docker/run.sh @@ -30,7 +30,7 @@ function exitAndClean() { function healthCheck() { HEALTH_CHECK_URL=$1 - for ((i=1; i<=10; i++)); + for ((i=1; i<=30; i++)); do STATUS_CODE="$(curl -Is ${HEALTH_CHECK_URL} | head -n 1)" if [[ $STATUS_CODE == *"200"* ]]; then diff --git a/test/plugin/run.sh b/test/plugin/run.sh index 896da3a969bb6caf7bd8c84e11b405ec4adedf4a..a49f1a3e6d98492ee55ecaca92cecc5612dc59ba 100644 --- a/test/plugin/run.sh +++ b/test/plugin/run.sh @@ -21,6 +21,7 @@ scenario_name="" parallel_run_size=1 force_build="off" build_id="latest" +cleanup="off" mvnw=${home}/../../mvnw agent_home=${home}"/../../skywalking-agent" @@ -32,6 +33,7 @@ print_help() { echo -e "\t-f, --force_build \t\t do force to build Plugin-Test tools and images" echo -e "\t--build_id, \t\t\t specify Plugin_Test's image tag. Defalt: latest" echo -e "\t--parallel_run_size, \t\t parallel size of test cases. Default: 1" + echo -e "\t--cleanup, \t\t\t remove the related images and directories" } parse_commandline() { @@ -44,6 +46,10 @@ parse_commandline() { force_build="on" shift ;; + --cleanup) + cleanup="on" + shift + ;; --build_id) test $# -lt 2 && exitWithMessage "Missing value for the optional argument '$_key'." build_id="$2" @@ -82,10 +88,6 @@ exitWithMessage() { } exitAndClean() { - if [[ "${build_id}" =~ "latest" ]]; then - docker images -q "skywalking/agent-test-*:${build_id}" | xargs -r docker rmi -f - fi - elapsed=$(( `date +%s` - $start_stamp )) num_of_testcases="`ls -l ${task_state_house} |grep -c FINISH`" printf "Scenarios: %s, Testcases: %d, parallel_run_size: %d, Elapsed: %02d:%02d:%02d \n" \ @@ -105,9 +107,20 @@ waitForAvailable() { fi } -start_stamp=`date +%s` ### start +do_cleanup() { + docker images -q "skywalking/agent-test-*:${build_id}" | xargs -r docker rmi -f + [[ -d ${home}/dist ]] && rm -rf ${home}/dist + [[ -d ${home}/workspce ]] && rm -rf ${home}/workspace +} + +start_stamp=`date +%s` parse_commandline "$@" +if [[ "$cleanup" == "on" ]]; then + do_cleanup + exit 0 +fi + if [[ ! -d ${agent_home} ]]; then echo "[WARN] SkyWalking Agent not exists" ${mvnw} -f ${home}/../../pom.xml -Pagent -DskipTests clean package @@ -149,9 +162,8 @@ do cp ./config/expectedData.yaml ${case_work_base}/data # echo "build ${testcase_name}" - ${mvnw} clean package -Dtest.framework.version=${version} - - mv ./target/${scenario_name}.war ${case_work_base} + ${mvnw} clean package -Dtest.framework.version=${version} && \ + mv ./target/${scenario_name}.* ${case_work_base} java -jar \ -Xmx256m -Xms256m \ diff --git a/test/plugin/runner/src/main/java/org/apache/skywalking/plugin/test/helper/ConfigurationImpl.java b/test/plugin/runner/src/main/java/org/apache/skywalking/plugin/test/helper/ConfigurationImpl.java index c83e054018a5d54abd66eba380f4ac7ab691fab6..9a81d98ac677c42273c612504ee00f8306bb5061 100644 --- a/test/plugin/runner/src/main/java/org/apache/skywalking/plugin/test/helper/ConfigurationImpl.java +++ b/test/plugin/runner/src/main/java/org/apache/skywalking/plugin/test/helper/ConfigurationImpl.java @@ -87,6 +87,11 @@ public class ConfigurationImpl implements IConfiguration { return this.configuration.getHealthCheck(); } + @Override + public String startScript() { + return this.configuration.getStartScript(); + } + @Override public String dockerImageName() { switch (this.configuration.getType().toLowerCase()) { case "tomcat" : diff --git a/test/plugin/runner/src/main/java/org/apache/skywalking/plugin/test/helper/DockerContainerRunningGenerator.java b/test/plugin/runner/src/main/java/org/apache/skywalking/plugin/test/helper/DockerContainerRunningGenerator.java index 57158ad63f9ac656f1f9f3bc16007c111df11d6b..b9d43556225537a6b3f84401aba3127fd38963c7 100644 --- a/test/plugin/runner/src/main/java/org/apache/skywalking/plugin/test/helper/DockerContainerRunningGenerator.java +++ b/test/plugin/runner/src/main/java/org/apache/skywalking/plugin/test/helper/DockerContainerRunningGenerator.java @@ -43,8 +43,9 @@ public class DockerContainerRunningGenerator extends AbstractRunningGenerator { root.put("scenario_name", configuration.scenarioName()); root.put("scenario_version", configuration.scenarioVersion()); - root.put("entry_service", configuration.entryService()); root.put("health_check", configuration.healthCheck()); + root.put("start_script", configuration.startScript()); + root.put("entry_service", configuration.entryService()); root.put("test_framework", configuration.testFramework()); root.put("docker_image_name", configuration.dockerImageName()); root.put("docker_image_version", configuration.dockerImageVersion()); diff --git a/test/plugin/runner/src/main/java/org/apache/skywalking/plugin/test/helper/IConfiguration.java b/test/plugin/runner/src/main/java/org/apache/skywalking/plugin/test/helper/IConfiguration.java index 416ea8578bbd8d2dab0ce14f01de6b3c7e220faa..038e2f56355bf7cf609e8d2517792cf7831b0710 100644 --- a/test/plugin/runner/src/main/java/org/apache/skywalking/plugin/test/helper/IConfiguration.java +++ b/test/plugin/runner/src/main/java/org/apache/skywalking/plugin/test/helper/IConfiguration.java @@ -34,10 +34,12 @@ public interface IConfiguration { @Deprecated String testFramework(); - String entryService(); - String healthCheck(); + String startScript(); + + String entryService(); + String dockerImageName(); String dockerContainerName(); diff --git a/test/plugin/runner/src/main/resources/container-start-script.template b/test/plugin/runner/src/main/resources/container-start-script.template index 7a07fa359da77b7f94000b65e127856867e0af5d..4c599af3bf372c8e50ea30a6fbdc534a15d2f543 100644 --- a/test/plugin/runner/src/main/resources/container-start-script.template +++ b/test/plugin/runner/src/main/resources/container-start-script.template @@ -21,6 +21,9 @@ docker run \ --env SCENARIO_NAME=${scenario_name} \ --env SCENARIO_VERSION=${scenario_version} \ --env SCENARIO_SUPPORT_FRAMEWORK=${scenario_name} \ + <#if start_script??> + --env SCENARIO_START_SCRIPT=${start_script} \ + --env SCENARIO_ENTRY_SERVICE=${entry_service} \ --env SCENARIO_HEALTH_CHECK_URL=${health_check} \ -v ${agent_home}:/usr/local/skywalking/scenario/agent \ diff --git a/test/plugin/runner/src/main/resources/docker-compose.template b/test/plugin/runner/src/main/resources/docker-compose.template index 41cd5e3972e678ac60ce1c3ede4ea2aff06f555d..cdecb5ceeeec92645df8993ec4fd1f2ac1592a2a 100644 --- a/test/plugin/runner/src/main/resources/docker-compose.template +++ b/test/plugin/runner/src/main/resources/docker-compose.template @@ -25,6 +25,11 @@ services: environment: + <#if environments?size \gt 0> + <#list environments as env> + - ${env} + + - SCENARIO_NAME:${scenario_name} - SCENARIO_VERSION:${scenario_version} - SCENARIO_ENTRY_SERVICE:${entry_service} diff --git a/test/plugin/scenarios/jetty-scenario/config/expectedData.yaml b/test/plugin/scenarios/jetty-scenario/config/expectedData.yaml new file mode 100644 index 0000000000000000000000000000000000000000..247ff97913651fa7ff485fee4d01da10e39304c8 --- /dev/null +++ b/test/plugin/scenarios/jetty-scenario/config/expectedData.yaml @@ -0,0 +1,89 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +registryItems: + applications: + - {jettyserver-scenario: nq 0} + - {jettyclient-scenario: nq 0} + instances: + - {jettyserver-scenario: 1} + - {jettyclient-scenario: 1} + operationNames: + - jettyserver-scenario: [/jettyserver-case/case/receiveContext-0] + - jettyclient-scenario: [/jettyserver-case/case/receiveContext-0, + /jettyclient-case/case/jettyclient-case, + /jettyclient-case/case/healthCheck] +segmentItems: +- applicationCode: jettyserver-scenario + segmentSize: 1 + segments: + - segmentId: not null + spans: + - operationName: /jettyserver-case/case/receiveContext-0 + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 19 + componentName: '' + isError: false + spanType: Entry + peer: '' + peerId: 0 + tags: + - {key: url, value: 'http://localhost:18080/jettyserver-case/case/receiveContext-0'} + - {key: http.method, value: GET} + refs: + - {parentEndpointId: 0, parentEndpoint: /jettyclient-case/case/jettyclient-case, networkAddressId: 0, entryEndpointId: 0, refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: "${jettyclient-scenario[0]}", parentServiceInstanceId: nq 0, networkAddress: 'localhost:18080', entryEndpoint: /jettyclient-case/case/jettyclient-case, entryServiceInstanceId: nq 0 } +- applicationCode: jettyclient-scenario + segmentSize: 2 + segments: + - segmentId: not null + spans: + - operationName: /jettyserver-case/case/receiveContext-0 + operationId: 0 + parentSpanId: 0 + spanId: 1 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 18 + componentName: null + isError: false + spanType: Exit + peer: localhost:18080 + peerId: 0 + tags: + - {key: http.method, value: GET} + - {key: url, value: 'http://localhost:18080/jettyserver-case/case/receiveContext-0'} + - operationName: /jettyclient-case/case/jettyclient-case + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: gt 0 + componentName: '' + isError: false + spanType: Entry + peer: null + peerId: 0 + tags: + - {key: url, value: 'http://localhost:8080/jettyclient-case/case/jettyclient-case'} + - {key: http.method, value: GET} + diff --git a/test/plugin/scenarios/jetty-scenario/configuration.yml b/test/plugin/scenarios/jetty-scenario/configuration.yml new file mode 100644 index 0000000000000000000000000000000000000000..e0dc5770bca4179faa3eb42b4860ef77c36c3f68 --- /dev/null +++ b/test/plugin/scenarios/jetty-scenario/configuration.yml @@ -0,0 +1,21 @@ +# 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/jettyclient-case/case/jettyclient-case +healthCheck: http://localhost:8080/jettyclient-case/case/healthCheck +startScript: ./bin/startup.sh +framework: jettyclient diff --git a/test/plugin/containers/jvm-container/docker/docker-entrypoint.sh b/test/plugin/scenarios/jetty-scenario/jetty-dist/bin/startup.sh similarity index 67% rename from test/plugin/containers/jvm-container/docker/docker-entrypoint.sh rename to test/plugin/scenarios/jetty-scenario/jetty-dist/bin/startup.sh index 9446ea6b1fb511fa29d043931585426503d3c088..32666b78dafec1d47745bf60ac062577d20ea001 100644 --- a/test/plugin/containers/jvm-container/docker/docker-entrypoint.sh +++ b/test/plugin/scenarios/jetty-scenario/jetty-dist/bin/startup.sh @@ -1,5 +1,5 @@ -#!/bin/sh - +#!/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 @@ -16,13 +16,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -/usr/local/skywalking-agent-scenario/skywalking-mock-collector/collector-startup.sh & -sleep 30 -# start applications -exec "$@" & -sleep 60 -curl ${SCENARIO_ENTRY_SERVICE} -sleep 40 -curl http://localhost:12800/receiveData > ${SCENARIO_DATA}/${SCENARIO_NAME}_${SCENARIO_VERSION}/actualData.yaml -# -echo "Scenario[${SCENARIO_NAME}, ${SCENARIO_VERSION}] build successfully!" +home="$(cd "$(dirname $0)"; pwd)" + +java -jar ${agent_opts} "-Dskywalking.agent.service_name=jettyserver-scenario" ${home}/../libs/jettyserver-scenario.jar & +sleep 1 + +java -jar ${agent_opts} "-Dskywalking.agent.service_name=jettyclient-scenario" ${home}/../libs/jettyclient-scenario.jar & diff --git a/test/plugin/scenarios/jetty-scenario/jetty-dist/pom.xml b/test/plugin/scenarios/jetty-scenario/jetty-dist/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..eaf44f92713d0cc4630d101136e775c60f388cd8 --- /dev/null +++ b/test/plugin/scenarios/jetty-scenario/jetty-dist/pom.xml @@ -0,0 +1,54 @@ + + + + + org.apache.skywalking + jetty-scenario + 5.0.0 + + 4.0.0 + + jetty-dist + + + + + org.apache.maven.plugins + maven-assembly-plugin + + + assemble + package + + single + + + + src/main/assembly/assembly.xml + + ../target/ + + + + + + + diff --git a/test/plugin/scenarios/jetty-scenario/jetty-dist/src/main/assembly/assembly.xml b/test/plugin/scenarios/jetty-scenario/jetty-dist/src/main/assembly/assembly.xml new file mode 100644 index 0000000000000000000000000000000000000000..6c159e3a7dfccd27783286c9ac54d823a069df99 --- /dev/null +++ b/test/plugin/scenarios/jetty-scenario/jetty-dist/src/main/assembly/assembly.xml @@ -0,0 +1,46 @@ + + + + + zip + + + + + ./bin + 0775 + + + + + + ../jettyclient-scenario/target/jettyclient-scenario.jar + ./libs + 0775 + + + ../jettyserver-scenario/target/jettyserver-scenario.jar + ./libs + 0775 + + + \ No newline at end of file diff --git a/test/plugin/scenarios/jetty-scenario/jettyclient-scenario/pom.xml b/test/plugin/scenarios/jetty-scenario/jettyclient-scenario/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..1f20c7d621dc773239a175fe7bc363a90d523ee5 --- /dev/null +++ b/test/plugin/scenarios/jetty-scenario/jettyclient-scenario/pom.xml @@ -0,0 +1,107 @@ + + + + + org.apache.skywalking + jetty-scenario + 5.0.0 + + 4.0.0 + + jettyclient-scenario + + 4.3.8.RELEASE + 1.5.2.RELEASE + + + + + org.eclipse.jetty + jetty-client + ${jettyclient.version} + + + + org.springframework.boot + spring-boot-starter + ${spring-boot-version} + + + org.apache.logging.log4j + log4j-api + ${log4j.version} + + + org.apache.logging.log4j + log4j-core + ${log4j.version} + + + org.apache.logging.log4j + log4j-slf4j-impl + ${log4j.version} + + + org.apache.logging.log4j + log4j-jcl + ${log4j.version} + + + org.springframework.boot + spring-boot-starter-tomcat + ${spring-boot-version} + + + org.springframework.boot + spring-boot-starter-web + ${spring-boot-version} + + + + + jettyclient-scenario + + + org.springframework.boot + spring-boot-maven-plugin + 1.5.9.RELEASE + + + + repackage + + + + + + + + + + spring-snapshots + http://repo.spring.io/snapshot + + + spring-milestones + http://repo.spring.io/milestone + + + \ No newline at end of file diff --git a/test/plugin/scenarios/jetty-scenario/jettyclient-scenario/src/main/java/org/apache/skywalking/apm/testcase/jettyclient/Application.java b/test/plugin/scenarios/jetty-scenario/jettyclient-scenario/src/main/java/org/apache/skywalking/apm/testcase/jettyclient/Application.java new file mode 100644 index 0000000000000000000000000000000000000000..9cd73210662ab53a97f5057b842a5a0efc4ac7c4 --- /dev/null +++ b/test/plugin/scenarios/jetty-scenario/jettyclient-scenario/src/main/java/org/apache/skywalking/apm/testcase/jettyclient/Application.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.skywalking.apm.testcase.jettyclient; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.support.SpringBootServletInitializer; +import org.springframework.context.annotation.ComponentScan; + +@EnableAutoConfiguration +@SpringBootApplication +@ComponentScan("org.apache.skywalking.apm.testcase.jettyclient") +public class Application extends SpringBootServletInitializer { + + public static void main(String[] args) { + try { + SpringApplication.run(Application.class, args); + } catch (Exception e) { + // Never do this + } + } +} \ No newline at end of file diff --git a/test/plugin/scenarios/jetty-scenario/jettyclient-scenario/src/main/java/org/apache/skywalking/apm/testcase/jettyclient/controller/CaseController.java b/test/plugin/scenarios/jetty-scenario/jettyclient-scenario/src/main/java/org/apache/skywalking/apm/testcase/jettyclient/controller/CaseController.java new file mode 100644 index 0000000000000000000000000000000000000000..fea948a28e455ee995ffb98453ad5656761bc185 --- /dev/null +++ b/test/plugin/scenarios/jetty-scenario/jettyclient-scenario/src/main/java/org/apache/skywalking/apm/testcase/jettyclient/controller/CaseController.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.skywalking.apm.testcase.jettyclient.controller; + +import javax.annotation.PostConstruct; +import org.eclipse.jetty.client.HttpClient; +import org.eclipse.jetty.client.api.Response; +import org.eclipse.jetty.client.api.Result; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.PropertySource; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +@RequestMapping("/case") +@PropertySource("classpath:application.properties") +public class CaseController { + + @Value(value = "${jettyServer.host:localhost}") + private String jettyServerHost; + + private HttpClient client = new HttpClient(); + + @PostConstruct + public void init() throws Exception { + client.start(); + } + + @RequestMapping("/jettyclient-case") + @ResponseBody + public String jettyClientScenario() throws Exception { + client.newRequest("http://" + jettyServerHost + ":18080/jettyserver-case/case/receiveContext-0").send(); + return "Success"; + } + + @RequestMapping("/healthCheck") + @ResponseBody + public String healthCheck() throws Exception { + return "Success"; + } +} diff --git a/test/plugin/scenarios/jetty-scenario/jettyclient-scenario/src/main/resources/application.properties b/test/plugin/scenarios/jetty-scenario/jettyclient-scenario/src/main/resources/application.properties new file mode 100644 index 0000000000000000000000000000000000000000..bf20bf2a45de9439eed32fa407cc72d5fbb5f5ab --- /dev/null +++ b/test/plugin/scenarios/jetty-scenario/jettyclient-scenario/src/main/resources/application.properties @@ -0,0 +1,18 @@ +# 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 +server.contextPath=/jettyclient-case \ No newline at end of file diff --git a/test/plugin/scenarios/jetty-scenario/jettyclient-scenario/src/main/resources/log4j2.xml b/test/plugin/scenarios/jetty-scenario/jettyclient-scenario/src/main/resources/log4j2.xml new file mode 100644 index 0000000000000000000000000000000000000000..35159a6e16717d17a119c26bcdd19b6b1018c455 --- /dev/null +++ b/test/plugin/scenarios/jetty-scenario/jettyclient-scenario/src/main/resources/log4j2.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + diff --git a/test/plugin/scenarios/jetty-scenario/jettyserver-scenario/pom.xml b/test/plugin/scenarios/jetty-scenario/jettyserver-scenario/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..e443811a2bbb189449ca3eb761b5ca85ad52e54d --- /dev/null +++ b/test/plugin/scenarios/jetty-scenario/jettyserver-scenario/pom.xml @@ -0,0 +1,80 @@ + + + + + jetty-scenario + org.apache.skywalking + 5.0.0 + + 4.0.0 + + jettyserver-scenario + + + + org.eclipse.jetty + jetty-server + ${jettyserver.version} + + + org.eclipse.jetty + jetty-servlet + ${jettyserver.version} + + + + + jettyserver-scenario + + + org.apache.maven.plugins + maven-shade-plugin + 3.1.0 + + + package + + shade + + + + + *:* + + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + + + + + + org.apache.skywalking.apm.testcase.jettyserver.Application + + + + + + + + + + \ No newline at end of file diff --git a/test/plugin/scenarios/jetty-scenario/jettyserver-scenario/src/main/java/org/apache/skywalking/apm/testcase/jettyserver/Application.java b/test/plugin/scenarios/jetty-scenario/jettyserver-scenario/src/main/java/org/apache/skywalking/apm/testcase/jettyserver/Application.java new file mode 100644 index 0000000000000000000000000000000000000000..8fb2622e8c482f778605d12684ee068032d60eed --- /dev/null +++ b/test/plugin/scenarios/jetty-scenario/jettyserver-scenario/src/main/java/org/apache/skywalking/apm/testcase/jettyserver/Application.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.skywalking.apm.testcase.jettyserver; + +import java.net.InetSocketAddress; +import org.apache.skywalking.apm.testcase.jettyserver.servlet.CaseServlet; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.servlet.ServletContextHandler; + +public class Application { + + public static void main(String[] args) throws Exception { + Server jettyServer = new Server(new InetSocketAddress("0.0.0.0", + Integer.valueOf(18080))); + String contextPath = "/jettyserver-case"; + ServletContextHandler servletContextHandler = new ServletContextHandler(ServletContextHandler.NO_SESSIONS); + servletContextHandler.setContextPath(contextPath); + servletContextHandler.addServlet(CaseServlet.class, CaseServlet.SERVLET_PATH); + jettyServer.setHandler(servletContextHandler); + jettyServer.start(); + } +} diff --git a/test/plugin/scenarios/jetty-scenario/jettyserver-scenario/src/main/java/org/apache/skywalking/apm/testcase/jettyserver/servlet/CaseServlet.java b/test/plugin/scenarios/jetty-scenario/jettyserver-scenario/src/main/java/org/apache/skywalking/apm/testcase/jettyserver/servlet/CaseServlet.java new file mode 100644 index 0000000000000000000000000000000000000000..f44bad27970273e4381bc02edd553ab3f63ee1d9 --- /dev/null +++ b/test/plugin/scenarios/jetty-scenario/jettyserver-scenario/src/main/java/org/apache/skywalking/apm/testcase/jettyserver/servlet/CaseServlet.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.skywalking.apm.testcase.jettyserver.servlet; + +import java.io.IOException; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +public class CaseServlet extends HttpServlet{ + public static String SERVLET_PATH = "/case/receiveContext-0"; + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + } + } +} diff --git a/test/plugin/scenarios/jetty-scenario/pom.xml b/test/plugin/scenarios/jetty-scenario/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..ff315e90d4c4137850cee3007d4469e15aceb5c4 --- /dev/null +++ b/test/plugin/scenarios/jetty-scenario/pom.xml @@ -0,0 +1,63 @@ + + + + 4.0.0 + + org.apache.skywalking + jetty-scenario + pom + 5.0.0 + + jettyclient-scenario + jettyserver-scenario + jetty-dist + + + skywalking-jetty-scenario + + + UTF-8 + + 9.0.0.v20130308 + + ${test.framework.version} + ${test.framework.version} + + 2.6.2 + + + + jetty-scenario + + + org.apache.maven.plugins + maven-compiler-plugin + 3.6.0 + + 1.8 + 1.8 + ${project.build.sourceEncoding} + + + + + + diff --git a/test/plugin/scenarios/jetty-scenario/support-version.list b/test/plugin/scenarios/jetty-scenario/support-version.list new file mode 100644 index 0000000000000000000000000000000000000000..8479160ad623e91e4e64c405173c8e32dd97402c --- /dev/null +++ b/test/plugin/scenarios/jetty-scenario/support-version.list @@ -0,0 +1,79 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +9.4.8.v20171121 +9.4.7.v20170914 +9.4.6.v20170531 +9.4.5.v20170502 +9.4.4.v20170414 +9.4.3.v20170317 +9.4.2.v20170220 +9.4.1.v20170120 +9.4.0.v20161208 +9.3.22.v20171030 +9.3.21.v20170918 +9.3.20.v20170531 +9.3.19.v20170502 +9.3.18.v20170406 +9.3.17.v20170317 +9.3.16.v20170120 +9.3.15.v20161220 +9.3.14.v20161028 +9.3.13.v20161014 +9.3.12.v20160915 +9.3.11.v20160721 +9.3.10.v20160621 +9.3.9.v20160517 +9.3.8.v20160314 +9.3.7.v20160115 +9.3.6.v20151106 +9.3.5.v20151012 +9.3.4.v20151007 +9.3.3.v20150827 +9.3.2.v20150730 +9.3.1.v20150714 +9.3.0.v20150612 +9.2.23.v20171218 +9.2.22.v20170606 +9.2.21.v20170120 +9.2.20.v20161216 +9.2.19.v20160908 +9.2.18.v20160721 +9.2.17.v20160517 +9.2.16.v20160414 +9.2.15.v20160210 +9.2.14.v20151106 +9.2.13.v20150730 +9.2.12.v20150709 +9.2.11.v20150529 +9.2.10.v20150310 +9.2.9.v20150224 +9.2.8.v20150217 +9.2.7.v20150116 +9.2.6.v20141205 +9.2.5.v20141112 +9.2.4.v20141103 +9.2.3.v20140905 +9.2.2.v20140723 +9.2.1.v20140609 +9.2.0.v20140526 +9.1.6.v20160112 +9.1.5.v20140505 +9.1.4.v20140401 +9.1.3.v20140225 +9.1.2.v20140210 +9.1.1.v20140108 +9.1.0.v20131115 diff --git a/test/plugin/script/run.m4 b/test/plugin/script/run.m4 deleted file mode 100644 index dd7441de4023b4d23c0928f9df3c943fead66bd2..0000000000000000000000000000000000000000 --- a/test/plugin/script/run.m4 +++ /dev/null @@ -1,149 +0,0 @@ -#!/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. -# -# ARG_OPTIONAL_BOOLEAN([build_agent], [], [no comment], [off]) -# ARG_OPTIONAL_BOOLEAN([build_scenario], [], [no comment], [off]) -# ARG_OPTIONAL_SINGLE([agent_home], [], [no comment]) -# ARG_OPTIONAL_SINGLE([parallel_run_size], [], [The size of running testcase at the same time], 1) -# ARG_POSITIONAL_INF([scenarios], [The scenario that you want to running]) -# DEFINE_SCRIPT_DIR([scenarios_home], [SCENARIO HOME]) -# ARG_HELP([The general script's help msg]) -# ARGBASH_GO -# [ - -home="$(cd "$(dirname $0)"; pwd)" - -mvnw=${home}/../../mvnw -agent_home=${home}"/../../skywalking-agent" -scenarios_home="${home}/scenarios" - -workspace="${home}/workspace" -task_state_house="${workspace}/.states" - - -plugin_autotest_helper="${home}/dist/plugin-autotest-helper.jar" - -prepareAndClean() { - echo "prepare and clear" - [[ -d ${workspace} ]] && rm -fr ${workspace} - - mkdir -p ${workspace}/{.states,testcases} - - if [[ ${#_arg_scenarios[@]} -lt 1 ]]; then - _arg_scenarios=`ls ./scenarios/|sed -e "s/\t/\n/g"` - fi - - # docker prune - docker container prune -f - docker network prune -f - docker volume prune -f -# docker image prune -f - - # build plugin/test - ${mvnw} clean package -DskipTests docker:build - if [[ ! -f ${plugin_autotest_helper} ]]; then - echo -e "\033[31mplugin/test build failure\033[0m" # ]] - exit 1; - fi -} - -waitForAvailable() { - while [[ `ls -l ${task_state_house} |grep -c RUNNING` -ge ${_arg_parallel_run_size} ]] - do - sleep 2 - done - - if [[ `ls -l ${task_state_house} |grep -c FAILURE` -gt 0 ]]; then - exit 1 - fi -} - -################################################ -start_stamp=`date +%s` - -prepareAndClean ## prepare to start - -echo "start submit job" -num_of_scenarios=0 -for scenario_name in ${_arg_scenarios} -do - scenario_home=${scenarios_home}/${scenario_name} && cd ${scenario_home} - - supported_version_file=${scenario_home}/support-version.list - if [[ ! -f $supported_version_file ]]; then - echo -e "\033[31m[ERROR] cannot found 'support-version.list' in directory ${scenario_name}\033[0m" # to escape ]] - continue - fi - - echo "scenario.name=${scenario_name}" - num_of_scenarios=$((num_of_scenarios+1)) - - supported_versions=`grep -v -E "^$|^#" ${supported_version_file}` - for version in ${supported_versions} - do - testcase_name="${scenario_name}-${version}" - - # testcase working directory, there are logs, reports, and packages. - case_work_base=${workspace}/testcases/${scenario_name}/${testcase_name} - mkdir -p ${case_work_base}/{data,packages,logs,reports} - - case_work_logs_dir=${case_work_base}/logs - - # copy expectedData.yml - cp ./config/expectedData.yaml ${case_work_base}/data - -# echo "build ${testcase_name}" - ${mvnw} clean package -P${testcase_name} > ${case_work_logs_dir}/build.log - - mv ./target/${scenario_name}.war ${case_work_base}/packages - - java -Dconfigure.file=${scenario_home}/configuration.yml \ - -Dscenario.home=${case_work_base} \ - -Dscenario.name=${scenario_name} \ - -Dscenario.version=${version} \ - -Doutput.dir=${case_work_base} \ - -Dagent.dir=${agent_home} \ - -jar ${plugin_autotest_helper} 1>${case_work_logs_dir}/helper.log 2>&2 - - [[ $? -ne 0 ]] && echo -e "\033[31m[ERROR] ${testcase_name}, generate script failure! \033[0m" && continue # ]] - - waitForAvailable - echo "start container of testcase.name=${testcase_name}" - bash ${case_work_base}/scenario.sh ${task_state_house} 1>${case_work_logs_dir}/${testcase_name}.log 2>&2 & - done - - echo -e "\033[33m${scenario_name} has already sumbitted\033[0m" # to escape ]] -done - -# wait to finish -while [[ `ls -l ${task_state_house} |grep -c RUNNING` -gt 0 ]]; do - sleep 1 -done - -if [[ `ls -l ${task_state_house} |grep -c FAILURE` -gt 0 ]]; then - exit 1 -fi - -elapsed=$(( `date +%s` - $start_stamp )) -num_of_testcases="`ls -l ${task_state_house} |grep -c FINISH`" - -printf "Scenarios: %d, Testcases: %d, parallel_run_size: %d, Elapsed: %02d:%02d:%02d \n" \ - ${num_of_scenarios} "${num_of_testcases}" "${_arg_parallel_run_size}" \ - $(( ${elapsed}/3600 )) $(( ${elapsed}%3600/60 )) $(( ${elapsed}%60 )) - -# ]