From 48bcac23072669d8594903b55dfb74b833d32dfd Mon Sep 17 00:00:00 2001 From: zhang-wei Date: Sat, 9 Nov 2019 15:34:13 +0800 Subject: [PATCH] [test/plugin] immigrate jedis scenario (#3811) * jedis scenario * update doc --- Jenkinsfile-Agent-Test-4 | 8 +- docs/en/guides/Plugin-test.md | 3 +- .../scenarios/jedis-scenario/bin/startup.sh | 22 ++++ .../jedis-scenario/config/expectedData.yaml | 111 ++++++++++++++++++ .../jedis-scenario/configuration.yml | 29 +++++ test/plugin/scenarios/jedis-scenario/pom.xml | 108 +++++++++++++++++ .../src/main/assembly/assembly.xml | 41 +++++++ .../apm/testcase/jedis/Application.java | 35 ++++++ .../jedis/controller/CaseController.java | 57 +++++++++ .../controller/RedisCommandExecutor.java | 46 ++++++++ .../src/main/resources/application.yaml | 21 ++++ .../jedis-scenario/support-version.list | 34 ++++++ 12 files changed, 513 insertions(+), 2 deletions(-) create mode 100644 test/plugin/scenarios/jedis-scenario/bin/startup.sh create mode 100644 test/plugin/scenarios/jedis-scenario/config/expectedData.yaml create mode 100644 test/plugin/scenarios/jedis-scenario/configuration.yml create mode 100644 test/plugin/scenarios/jedis-scenario/pom.xml create mode 100644 test/plugin/scenarios/jedis-scenario/src/main/assembly/assembly.xml create mode 100644 test/plugin/scenarios/jedis-scenario/src/main/java/org/apache/skywalking/apm/testcase/jedis/Application.java create mode 100644 test/plugin/scenarios/jedis-scenario/src/main/java/org/apache/skywalking/apm/testcase/jedis/controller/CaseController.java create mode 100644 test/plugin/scenarios/jedis-scenario/src/main/java/org/apache/skywalking/apm/testcase/jedis/controller/RedisCommandExecutor.java create mode 100644 test/plugin/scenarios/jedis-scenario/src/main/resources/application.yaml create mode 100644 test/plugin/scenarios/jedis-scenario/support-version.list diff --git a/Jenkinsfile-Agent-Test-4 b/Jenkinsfile-Agent-Test-4 index 8b994e533..29c565ad7 100755 --- a/Jenkinsfile-Agent-Test-4 +++ b/Jenkinsfile-Agent-Test-4 @@ -68,7 +68,7 @@ pipeline { } } - stage('Test Cases Report (135)') { + stage('Test Cases Report (153)') { steps { echo "Test Cases Report" } @@ -101,6 +101,12 @@ pipeline { sh 'bash test/plugin/run.sh undertow-scenario' } } + + stage('jedis 2.4.0-2.9.0 (18)') { + steps { + sh 'bash test/plugin/run.sh jedis-scenario' + } + } } } diff --git a/docs/en/guides/Plugin-test.md b/docs/en/guides/Plugin-test.md index 438cee883..7b997bea6 100644 --- a/docs/en/guides/Plugin-test.md +++ b/docs/en/guides/Plugin-test.md @@ -659,12 +659,13 @@ spring async 4.3.x-5.1.x | 35 | 967.70 mongodb 3.4.0-3.11.1 | 17 | 1465.63 ### Workload 4 -#### Group 1 (1778.45s) +#### Group 1 (2397.45s) scenario name | versions | elapsed time (sec) ---|---|--- kafka 0.11.0.0-2.3.0 | 16 | 704.75 ehcache 2.8.x-2.10.x | 19 | 440.71 undertow 1.3.0-2.0.27 | 23 | 633.00 +jedis 2.4.0-2.9.0 | 18 | 619 #### Group 2 (2148.155s) scenario name | versions | elapsed time (sec) diff --git a/test/plugin/scenarios/jedis-scenario/bin/startup.sh b/test/plugin/scenarios/jedis-scenario/bin/startup.sh new file mode 100644 index 000000000..657a2f240 --- /dev/null +++ b/test/plugin/scenarios/jedis-scenario/bin/startup.sh @@ -0,0 +1,22 @@ +#!/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} -Dredis.host=${REDIS_HOST} -Dredis.port=${REDIS_PORT} \ +${home}/../libs/jedis-scenario.jar & \ No newline at end of file diff --git a/test/plugin/scenarios/jedis-scenario/config/expectedData.yaml b/test/plugin/scenarios/jedis-scenario/config/expectedData.yaml new file mode 100644 index 000000000..c87e2df6d --- /dev/null +++ b/test/plugin/scenarios/jedis-scenario/config/expectedData.yaml @@ -0,0 +1,111 @@ +# 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: + - {jedis-scenario: 2} + instances: + - {jedis-scenario: 1} + operationNames: + - jedis-scenario: [Jedis/set, Jedis/echo, Jedis/del, + Jedis/get, /jedis-scenario/case/jedis-scenario] + heartbeat: [] +segmentItems: + - applicationCode: jedis-scenario + segmentSize: gt 1 + segments: + - segmentId: not null + spans: + - operationName: Jedis/echo + operationId: 0 + parentSpanId: 0 + spanId: 1 + spanLayer: Cache + startTime: nq 0 + endTime: nq 0 + componentId: 30 + componentName: '' + isError: false + spanType: Exit + peer: redis-server:6379 + peerId: 0 + tags: + - {key: db.type, value: Redis} + - {key: db.statement, value: echo Test} + - operationName: Jedis/set + operationId: 0 + parentSpanId: 0 + spanId: 2 + spanLayer: Cache + startTime: nq 0 + endTime: nq 0 + componentId: 30 + componentName: '' + isError: false + spanType: Exit + peer: redis-server:6379 + peerId: 0 + tags: + - {key: db.type, value: Redis} + - {key: db.statement, value: set a} + - operationName: Jedis/get + operationId: 0 + parentSpanId: 0 + spanId: 3 + spanLayer: Cache + startTime: nq 0 + endTime: nq 0 + componentId: 30 + componentName: '' + isError: false + spanType: Exit + peer: redis-server:6379 + peerId: 0 + tags: + - {key: db.type, value: Redis} + - {key: db.statement, value: get a} + - operationName: Jedis/del + operationId: 0 + parentSpanId: 0 + spanId: 4 + spanLayer: Cache + startTime: nq 0 + endTime: nq 0 + componentId: 30 + componentName: '' + isError: false + spanType: Exit + peer: redis-server:6379 + peerId: 0 + tags: + - {key: db.type, value: Redis} + - {key: db.statement, value: del a} + - operationName: /jedis-scenario/case/jedis-scenario + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 1 + componentName: '' + isError: false + spanType: Entry + peer: '' + peerId: 0 + tags: + - {key: url, value: 'http://localhost:8080/jedis-scenario/case/jedis-scenario'} + - {key: http.method, value: GET} \ No newline at end of file diff --git a/test/plugin/scenarios/jedis-scenario/configuration.yml b/test/plugin/scenarios/jedis-scenario/configuration.yml new file mode 100644 index 000000000..84df659e7 --- /dev/null +++ b/test/plugin/scenarios/jedis-scenario/configuration.yml @@ -0,0 +1,29 @@ +# 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/jedis-scenario/case/jedis-scenario +healthCheck: http://localhost:8080/jedis-scenario/case/healthCheck +startScript: ./bin/startup.sh +framework: jedis-scenario +environment: + - REDIS_HOST=redis-server + - REDIS_PORT=6379 +dependencies: + redis-server: + image: redis:3.2.9-alpine + hostname: redis-server + diff --git a/test/plugin/scenarios/jedis-scenario/pom.xml b/test/plugin/scenarios/jedis-scenario/pom.xml new file mode 100644 index 000000000..a78f9a4a8 --- /dev/null +++ b/test/plugin/scenarios/jedis-scenario/pom.xml @@ -0,0 +1,108 @@ + + + + + org.apache.skywalking.apm.testcase + jedis-scenario + 1.0.0 + jar + + 4.0.0 + + + UTF-8 + 1.8 + 2.9.0 + 2.1.6.RELEASE + + + skywalking-jedis-scenario + + + + + org.springframework.boot + spring-boot-dependencies + ${spring-boot-version} + pom + import + + + + + + + redis.clients + jedis + ${test.framework.version} + + + org.springframework.boot + spring-boot-starter-web + + + + + jedis-scenario + + + org.springframework.boot + spring-boot-maven-plugin + 1.5.9.RELEASE + + + + repackage + + + + + + maven-compiler-plugin + + ${compiler.version} + ${compiler.version} + ${project.build.sourceEncoding} + + + + org.apache.maven.plugins + maven-assembly-plugin + + + assemble + package + + single + + + + src/main/assembly/assembly.xml + + ./target/ + + + + + + + + \ No newline at end of file diff --git a/test/plugin/scenarios/jedis-scenario/src/main/assembly/assembly.xml b/test/plugin/scenarios/jedis-scenario/src/main/assembly/assembly.xml new file mode 100644 index 000000000..8259d6da9 --- /dev/null +++ b/test/plugin/scenarios/jedis-scenario/src/main/assembly/assembly.xml @@ -0,0 +1,41 @@ + + + + + zip + + + + + ./bin + 0775 + + + + + + ${project.build.directory}/jedis-scenario.jar + ./libs + 0775 + + + diff --git a/test/plugin/scenarios/jedis-scenario/src/main/java/org/apache/skywalking/apm/testcase/jedis/Application.java b/test/plugin/scenarios/jedis-scenario/src/main/java/org/apache/skywalking/apm/testcase/jedis/Application.java new file mode 100644 index 000000000..a5284fd8f --- /dev/null +++ b/test/plugin/scenarios/jedis-scenario/src/main/java/org/apache/skywalking/apm/testcase/jedis/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 org.apache.skywalking.apm.testcase.jedis; + +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/jedis-scenario/src/main/java/org/apache/skywalking/apm/testcase/jedis/controller/CaseController.java b/test/plugin/scenarios/jedis-scenario/src/main/java/org/apache/skywalking/apm/testcase/jedis/controller/CaseController.java new file mode 100644 index 000000000..e38b2b2a3 --- /dev/null +++ b/test/plugin/scenarios/jedis-scenario/src/main/java/org/apache/skywalking/apm/testcase/jedis/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.jedis.controller; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/case") +public class CaseController { + + private static final String SUCCESS = "Success"; + + @Value("${redis.host:127.0.0.1}") + private String redisHost; + + @Value("${redis.port:6379}") + private Integer redisPort; + + @RequestMapping("/jedis-scenario") + @ResponseBody + public String testcase() throws Exception { + try (RedisCommandExecutor command = new RedisCommandExecutor(redisHost, redisPort)) { + command.set("a", "a"); + command.get("a"); + command.del("a"); + } + return SUCCESS; + } + + @RequestMapping("/healthCheck") + @ResponseBody + public String healthCheck() throws Exception { + try (RedisCommandExecutor command = new RedisCommandExecutor(redisHost, redisPort)) { + + } + return SUCCESS; + } +} diff --git a/test/plugin/scenarios/jedis-scenario/src/main/java/org/apache/skywalking/apm/testcase/jedis/controller/RedisCommandExecutor.java b/test/plugin/scenarios/jedis-scenario/src/main/java/org/apache/skywalking/apm/testcase/jedis/controller/RedisCommandExecutor.java new file mode 100644 index 000000000..dad68f1d0 --- /dev/null +++ b/test/plugin/scenarios/jedis-scenario/src/main/java/org/apache/skywalking/apm/testcase/jedis/controller/RedisCommandExecutor.java @@ -0,0 +1,46 @@ +/* + * 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.jedis.controller; + +import redis.clients.jedis.Jedis; + +public class RedisCommandExecutor implements AutoCloseable{ + private Jedis jedis; + + public RedisCommandExecutor(String host, Integer port) { + jedis = new Jedis(host, port); + jedis.echo("Test"); + } + + public void set(String key, String value) { + jedis.set(key, value); + } + + public void get(String key) { + jedis.get(key); + } + + public void del(String key) { + jedis.del(key); + } + + public void close() throws Exception { + jedis.close(); + } +} diff --git a/test/plugin/scenarios/jedis-scenario/src/main/resources/application.yaml b/test/plugin/scenarios/jedis-scenario/src/main/resources/application.yaml new file mode 100644 index 000000000..a97789a0a --- /dev/null +++ b/test/plugin/scenarios/jedis-scenario/src/main/resources/application.yaml @@ -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. +# +# +server: + port: 8080 + servlet: + context-path: /jedis-scenario \ No newline at end of file diff --git a/test/plugin/scenarios/jedis-scenario/support-version.list b/test/plugin/scenarios/jedis-scenario/support-version.list new file mode 100644 index 000000000..b2b411fcc --- /dev/null +++ b/test/plugin/scenarios/jedis-scenario/support-version.list @@ -0,0 +1,34 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +2.9.0 +2.8.2 +2.8.1 +2.8.0 +2.7.3 +2.7.2 +2.7.1 +2.7.0 +2.6.3 +2.6.2 +2.6.1 +2.6.0 +2.5.0 +2.5.1 +2.5.2 +2.4.2 +2.4.1 +2.4.0 \ No newline at end of file