diff --git a/Jenkinsfile-Agent-Test-3 b/Jenkinsfile-Agent-Test-3 index dfa346541b05766ce9cfb59eddeb08f05d2b049a..f728c80f4fb3f9c6930c7ff978e81b8b8d4c83ac 100755 --- a/Jenkinsfile-Agent-Test-3 +++ b/Jenkinsfile-Agent-Test-3 @@ -67,7 +67,7 @@ pipeline { sh './mvnw -f test/plugin/pom.xml clean package -DskipTests docker:build' } } - stage('Test Cases Report (140)') { + stage('Test Cases Report (160)') { steps { echo "Test Cases Report" } @@ -82,6 +82,12 @@ pipeline { parallel { stage('Group1') { stages { + stage('hystrix 1.4.20-1.5.12 (20)') { + steps { + sh 'bash test/plugin/run.sh hystrix-scenario' + } + } + stage('postgresql 9.2.x-9.4.x (36)') { steps { sh 'bash test/plugin/run.sh postgresql-scenario' diff --git a/docs/en/guides/Plugin-test.md b/docs/en/guides/Plugin-test.md index 193cc992c7830eb68cfff00cee16b0973b03d098..eb7d04024c296839e2ec9282cd93e177a3f80a89 100644 --- a/docs/en/guides/Plugin-test.md +++ b/docs/en/guides/Plugin-test.md @@ -648,9 +648,10 @@ elasticsearch 5.x | 3 | 142.15 ### Workload 3 -#### Group 1 (2291.912s) +#### Group 1 (3090.912s) scenario name | versions | elapsed time (sec) ---|---|--- +hystrix-scenario | 20 | 799.00 postgresql 9.2.x-9.4.x | 36 | 1243.03 sofarpc 5.4.0-5.6.2 | 23 | 817.77 spring 3.0.x | 8 | 231.11 diff --git a/test/plugin/scenarios/hystrix-scenario/bin/startup.sh b/test/plugin/scenarios/hystrix-scenario/bin/startup.sh new file mode 100644 index 0000000000000000000000000000000000000000..3a985cebfcf5f2572a19989a2fb6df2ed46e935f --- /dev/null +++ b/test/plugin/scenarios/hystrix-scenario/bin/startup.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +home="$(cd "$(dirname $0)"; pwd)" + +java -jar ${agent_opts} ${home}/../libs/hystrix-scenario.jar & \ No newline at end of file diff --git a/test/plugin/scenarios/hystrix-scenario/config/expectedData.yaml b/test/plugin/scenarios/hystrix-scenario/config/expectedData.yaml new file mode 100644 index 0000000000000000000000000000000000000000..66ccf5d1b9852d50bac898221bc5fefe6ed955e6 --- /dev/null +++ b/test/plugin/scenarios/hystrix-scenario/config/expectedData.yaml @@ -0,0 +1,98 @@ +# 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: + - {hystrix-scenario: 2} + instances: + - {hystrix-scenario: 1} + operationNames: + - hystrix-scenario: [/case/hystrix-scenario] + heartbeat: [] +segmentItems: +- applicationCode: hystrix-scenario + segmentSize: ge 1 + segments: + - segmentId: not null + spans: + - operationName: Hystrix/TestACommand/Execution + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Unknown + startTime: nq 0 + endTime: nq 0 + componentId: 29 + componentName: '' + isError: false + spanType: Local + peer: '' + peerId: 0 + logs: + - logEvent: + - {key: event, value: error} + - {key: error.kind, value: java.lang.InterruptedException} + - {key: message, value: not null} + - {key: stack, value: not null} + refs: + - {parentEndpointId: 0, parentEndpoint: /case/hystrix-scenario, networkAddressId: 0, entryEndpointId: 0, refType: CrossThread, parentSpanId: 0, parentTraceSegmentId: '${hystrix-scenario[2]}', parentServiceInstanceId: nq 0, networkAddress: '', entryEndpoint: /case/hystrix-scenario, entryServiceInstanceId: nq 0 } + - segmentId: not null + spans: + - operationName: Hystrix/TestACommand/Fallback + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Unknown + startTime: nq 0 + endTime: nq 0 + componentId: 29 + componentName: '' + isError: false + spanType: Local + peer: '' + peerId: 0 + refs: + - {parentEndpointId: 0, parentEndpoint: Hystrix/TestACommand/Execution, networkAddressId: 0, entryEndpointId: 0, refType: CrossThread, parentSpanId: 0, parentTraceSegmentId: '${hystrix-scenario[0]}', parentServiceInstanceId: nq 0, networkAddress: '', entryEndpoint: /case/hystrix-scenario, entryServiceInstanceId: nq 0} + - segmentId: not null + spans: + - operationName: Hystrix/TestBCommand/Execution + operationId: 0 + parentSpanId: 0 + spanId: 1 + spanLayer: Unknown + startTime: nq 0 + endTime: nq 0 + componentId: 29 + componentName: '' + isError: false + spanType: Local + peer: '' + peerId: 0 + - operationName: /case/hystrix-scenario + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 14 + componentName: '' + isError: false + spanType: Entry + peer: '' + peerId: 0 + tags: + - {key: url, value: 'http://localhost:8080/hystrix-scenario/case/hystrix-scenario'} + - {key: http.method, value: GET} diff --git a/test/plugin/scenarios/hystrix-scenario/configuration.yml b/test/plugin/scenarios/hystrix-scenario/configuration.yml new file mode 100644 index 0000000000000000000000000000000000000000..b944fb61c79cc1c7d12e173ddeb71f4184ce4d0d --- /dev/null +++ b/test/plugin/scenarios/hystrix-scenario/configuration.yml @@ -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. + +type: jvm +entryService: http://localhost:8080/hystrix-scenario/case/hystrix-scenario +healthCheck: http://localhost:8080/hystrix-scenario/case/healthCheck +startScript: ./bin/startup.sh +framework: hystrix-scenario +environment: +dependencies: \ No newline at end of file diff --git a/test/plugin/scenarios/hystrix-scenario/pom.xml b/test/plugin/scenarios/hystrix-scenario/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..8aedab1b17b51f3bc55a095a52a123acf1797b40 --- /dev/null +++ b/test/plugin/scenarios/hystrix-scenario/pom.xml @@ -0,0 +1,123 @@ + + + + + org.apache.skywalking.apm.testcase + hystrix-scenario + 1.0.0 + jar + + 4.0.0 + + + UTF-8 + 1.8 + + 1.4.20 + 2.1.6.RELEASE + + + skywalking-hystrix-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 + + + jul-to-slf4j + org.slf4j + + + + + com.netflix.hystrix + hystrix-core + ${test.framework.version} + + + + + hystrix-scenario + + + 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/ + + + + + + + diff --git a/test/plugin/scenarios/hystrix-scenario/src/main/assembly/assembly.xml b/test/plugin/scenarios/hystrix-scenario/src/main/assembly/assembly.xml new file mode 100644 index 0000000000000000000000000000000000000000..1549c13d5c14c322ca932d95cbe3bbd1b5b6c341 --- /dev/null +++ b/test/plugin/scenarios/hystrix-scenario/src/main/assembly/assembly.xml @@ -0,0 +1,41 @@ + + + + + zip + + + + + ./bin + 0775 + + + + + + ${project.build.directory}/hystrix-scenario.jar + ./libs + 0775 + + + diff --git a/test/plugin/scenarios/hystrix-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/hystrix/Application.java b/test/plugin/scenarios/hystrix-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/hystrix/Application.java new file mode 100644 index 0000000000000000000000000000000000000000..9525e9c36b756a65d663c62c9113b227486a0172 --- /dev/null +++ b/test/plugin/scenarios/hystrix-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/hystrix/Application.java @@ -0,0 +1,35 @@ +/* + * 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.hystrix; + +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/hystrix-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/hystrix/controller/CaseController.java b/test/plugin/scenarios/hystrix-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/hystrix/controller/CaseController.java new file mode 100644 index 0000000000000000000000000000000000000000..0ba67165b23349e95e34188970382861876bef26 --- /dev/null +++ b/test/plugin/scenarios/hystrix-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/hystrix/controller/CaseController.java @@ -0,0 +1,92 @@ +/* + * 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.hystrix.controller; + +import com.netflix.hystrix.HystrixCommand; +import com.netflix.hystrix.HystrixInvokable; +import com.netflix.hystrix.strategy.HystrixPlugins; +import com.netflix.hystrix.strategy.executionhook.HystrixCommandExecutionHook; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; +import javax.annotation.PostConstruct; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +@RequestMapping("/case") +public class CaseController { + + private static final Logger logger = LogManager.getLogger(CaseController.class); + + private static final String SUCCESS = "Success"; + + @PostConstruct + public void setUp() { + HystrixPlugins.getInstance().registerCommandExecutionHook(new HystrixCommandExecutionHook() { + @Override public void onStart(HystrixInvokable commandInstance) { + logger.info("[hookA] onStart: " + Thread.currentThread().getId()); + super.onStart(commandInstance); + } + + @Override public void onExecutionStart(HystrixInvokable commandInstance) { + logger.info("[hookA] onExecutionStart: " + Thread.currentThread().getId()); + super.onExecutionStart(commandInstance); + } + + @Override public void onExecutionSuccess(HystrixInvokable commandInstance) { + logger.info("[hookA] onExecutionSuccess: " + Thread.currentThread().getId()); + super.onExecutionSuccess(commandInstance); + } + + @Override public Exception onExecutionError(HystrixInvokable commandInstance, Exception e) { + logger.info("[hookA] onExecutionError: " + Thread.currentThread().getId()); + return super.onExecutionError(commandInstance, e); + } + + @Override public Exception onRunError(HystrixCommand commandInstance, Exception e) { + logger.info("[hookA] onRunError: " + Thread.currentThread().getId()); + return super.onRunError(commandInstance, e); + } + }); + } + + @RequestMapping("/hystrix-scenario") + @ResponseBody + public String testcase() throws InterruptedException, ExecutionException { + List> fs = new ArrayList>(); + fs.add(new TestBCommand("World").queue()); + logger.info(new TestACommand("World").execute()); + for (Future f : fs) { + logger.info(f.get()); + } + return SUCCESS; + } + + @RequestMapping("/healthCheck") + @ResponseBody + public String healthCheck() { + return SUCCESS; + } + +} diff --git a/test/plugin/scenarios/hystrix-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/hystrix/controller/TestACommand.java b/test/plugin/scenarios/hystrix-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/hystrix/controller/TestACommand.java new file mode 100644 index 0000000000000000000000000000000000000000..035de811222c301bea8b6448c278a8d8ea9a3150 --- /dev/null +++ b/test/plugin/scenarios/hystrix-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/hystrix/controller/TestACommand.java @@ -0,0 +1,61 @@ +/* + * 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.hystrix.controller; + +import com.netflix.hystrix.HystrixCommand; +import com.netflix.hystrix.HystrixCommandGroupKey; +import com.netflix.hystrix.HystrixCommandProperties; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class TestACommand extends HystrixCommand { + private Logger logger = LogManager.getLogger(TestACommand.class); + + private String name; + + protected TestACommand(String name) { + super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("TestACommand")) + .andCommandPropertiesDefaults( + HystrixCommandProperties.Setter() + .withExecutionTimeoutInMilliseconds(1000) + ) + ); + this.name = name; + } + + @Override + protected String run() throws Exception { + Thread.sleep(2001); + try { + logger.info("start run: " + +Thread.currentThread().getId()); + return "Hello " + name + "!"; + } finally { + logger.info("start end"); + } + } + + @Override + protected String getFallback() { + try { + logger.info("getFallback run: " + Thread.currentThread().getId()); + return "failed"; + } finally { + logger.info("getFallback end"); + } + } +} diff --git a/test/plugin/scenarios/hystrix-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/hystrix/controller/TestBCommand.java b/test/plugin/scenarios/hystrix-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/hystrix/controller/TestBCommand.java new file mode 100644 index 0000000000000000000000000000000000000000..0166df7beb331d7cb88c7402f18e59213a8d8e25 --- /dev/null +++ b/test/plugin/scenarios/hystrix-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/hystrix/controller/TestBCommand.java @@ -0,0 +1,64 @@ +/* + * 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.hystrix.controller; + +import com.netflix.hystrix.HystrixCommand; +import com.netflix.hystrix.HystrixCommandGroupKey; +import com.netflix.hystrix.HystrixCommandProperties; +import com.netflix.hystrix.HystrixCommandProperties.ExecutionIsolationStrategy; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class TestBCommand extends HystrixCommand { + private Logger logger = LogManager.getLogger(TestACommand.class); + + private String name; + + protected TestBCommand(String name) { + super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("TestBCommand")) + .andCommandPropertiesDefaults( + HystrixCommandProperties.Setter() + .withExecutionTimeoutInMilliseconds(1000) + ).andCommandPropertiesDefaults( + HystrixCommandProperties.Setter() + .withExecutionIsolationStrategy(ExecutionIsolationStrategy.SEMAPHORE) + ) + ); + this.name = name; + } + + @Override + protected String run() throws Exception { + try { + logger.info("start run: " + Thread.currentThread().getId()); + return "Hello " + name + "!"; + } finally { + logger.info("start end"); + } + } + + @Override + protected String getFallback() { + try { + logger.info("getFallback run: " + Thread.currentThread().getId()); + return "failed"; + } finally { + logger.info("getFallback end"); + } + } +} diff --git a/test/plugin/scenarios/hystrix-scenario/src/main/resources/application.yaml b/test/plugin/scenarios/hystrix-scenario/src/main/resources/application.yaml new file mode 100644 index 0000000000000000000000000000000000000000..02b907da14a9726bd1b0e35b5edea26f4ed08550 --- /dev/null +++ b/test/plugin/scenarios/hystrix-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: /hystrix-scenario +logging: + config: classpath:log4j2.xml diff --git a/test/plugin/scenarios/hystrix-scenario/src/main/resources/log4j2.xml b/test/plugin/scenarios/hystrix-scenario/src/main/resources/log4j2.xml new file mode 100644 index 0000000000000000000000000000000000000000..b5cda5ae8ad528f3272b269b1c9f0d733c52ef5f --- /dev/null +++ b/test/plugin/scenarios/hystrix-scenario/src/main/resources/log4j2.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + diff --git a/test/plugin/scenarios/hystrix-scenario/support-version.list b/test/plugin/scenarios/hystrix-scenario/support-version.list new file mode 100644 index 0000000000000000000000000000000000000000..9be28d10998e28fa2d8050ac56540f96a331e1f6 --- /dev/null +++ b/test/plugin/scenarios/hystrix-scenario/support-version.list @@ -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 +# "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. + +1.4.20 +1.4.21 +1.4.22 +1.4.23 +1.4.24 +1.4.25 +1.4.26 +1.5.0 +1.5.1 +1.5.2 +1.5.3 +1.5.4 +1.5.5 +1.5.6 +1.5.7 +1.5.8 +1.5.9 +1.5.10 +1.5.11 +1.5.12