提交 530804d0 编写于 作者: D Daming 提交者: wu-sheng

[test/plugin] support jvm-container (#3584)

* provides a jvm-container
上级 1b1e80b7
......@@ -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
......@@ -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"]
#!/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
......@@ -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
......
......@@ -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 \
......
......@@ -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" :
......
......@@ -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());
......
......@@ -34,10 +34,12 @@ public interface IConfiguration {
@Deprecated
String testFramework();
String entryService();
String healthCheck();
String startScript();
String entryService();
String dockerImageName();
String dockerContainerName();
......
......@@ -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} \
</#if>
--env SCENARIO_ENTRY_SERVICE=${entry_service} \
--env SCENARIO_HEALTH_CHECK_URL=${health_check} \
-v ${agent_home}:/usr/local/skywalking/scenario/agent \
......
......@@ -25,6 +25,11 @@ services:
</#list>
</#if>
environment:
<#if environments?size \gt 0>
<#list environments as env>
- ${env}
</#list>
</#if>
- SCENARIO_NAME:${scenario_name}
- SCENARIO_VERSION:${scenario_version}
- SCENARIO_ENTRY_SERVICE:${entry_service}
......
# 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}
# 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
#!/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 &
<?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">
<parent>
<groupId>org.apache.skywalking</groupId>
<artifactId>jetty-scenario</artifactId>
<version>5.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-dist</artifactId>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>assemble</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/main/assembly/assembly.xml</descriptor>
</descriptors>
<outputDirectory>../target/</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
~ this work for additional information regarding copyright ownership.
~ The ASF licenses this file to You under the Apache License, Version 2.0
~ (the "License"); you may not use this file except in compliance with
~ the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~
-->
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>./bin</directory>
<fileMode>0775</fileMode>
</fileSet>
</fileSets>
<files>
<file>
<source>../jettyclient-scenario/target/jettyclient-scenario.jar</source>
<outputDirectory>./libs</outputDirectory>
<fileMode>0775</fileMode>
</file>
<file>
<source>../jettyserver-scenario/target/jettyserver-scenario.jar</source>
<outputDirectory>./libs</outputDirectory>
<fileMode>0775</fileMode>
</file>
</files>
</assembly>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
~ this work for additional information regarding copyright ownership.
~ The ASF licenses this file to You under the Apache License, Version 2.0
~ (the "License"); you may not use this file except in compliance with
~ the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~
-->
<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">
<parent>
<groupId>org.apache.skywalking</groupId>
<artifactId>jetty-scenario</artifactId>
<version>5.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jettyclient-scenario</artifactId>
<properties>
<spring.version>4.3.8.RELEASE</spring.version>
<spring-boot-version>1.5.2.RELEASE</spring-boot-version>
</properties>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-client</artifactId>
<version>${jettyclient.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>${spring-boot-version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jcl</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<version>${spring-boot-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring-boot-version}</version>
</dependency>
</dependencies>
<build>
<finalName>jettyclient-scenario</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.5.9.RELEASE</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<url>http://repo.spring.io/snapshot</url>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<url>http://repo.spring.io/milestone</url>
</pluginRepository>
</pluginRepositories>
</project>
\ No newline at end of file
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
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
/*
* 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";
}
}
# 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
<?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="debug">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout charset="UTF-8" pattern="[%d{yyyy-MM-dd HH:mm:ss:SSS}] [%p] - %l - %m%n"/>
</Console>
</Appenders>
<Loggers>
<Root level="debug">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>
<?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">
<parent>
<artifactId>jetty-scenario</artifactId>
<groupId>org.apache.skywalking</groupId>
<version>5.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jettyserver-scenario</artifactId>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>${jettyserver.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>${jettyserver.version}</version>
</dependency>
</dependencies>
<build>
<finalName>jettyserver-scenario</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.apache.skywalking.apm.testcase.jettyserver.Application</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
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();
}
}
/*
* 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) {
}
}
}
<?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">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.skywalking</groupId>
<artifactId>jetty-scenario</artifactId>
<packaging>pom</packaging>
<version>5.0.0</version>
<modules>
<module>jettyclient-scenario</module>
<module>jettyserver-scenario</module>
<module>jetty-dist</module>
</modules>
<name>skywalking-jetty-scenario</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<test.framework.version>9.0.0.v20130308</test.framework.version>
<jettyserver.version>${test.framework.version}</jettyserver.version>
<jettyclient.version>${test.framework.version}</jettyclient.version>
<log4j.version>2.6.2</log4j.version>
</properties>
<build>
<finalName>jetty-scenario</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
# 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
#!/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 ))
# ]
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册