diff --git a/.github/workflows/plugins-test.2.yaml b/.github/workflows/plugins-test.2.yaml index 07138379d..cb076b5fe 100644 --- a/.github/workflows/plugins-test.2.yaml +++ b/.github/workflows/plugins-test.2.yaml @@ -79,6 +79,7 @@ jobs: - struts2.5-scenario - cxf-scenario - okhttp2-scenario + - rocketmq-scenario steps: - uses: actions/checkout@v2 with: diff --git a/CHANGES.md b/CHANGES.md index 0c0bdbdbf..607a19fb4 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -21,6 +21,7 @@ Release Notes. * Polish up rabbitmq-5.x plugin to fix missing broker tag on consumer side * Polish up activemq plugin to fix missing broker tag on consumer side * Enhance MQ plugin relative tests to check key tags not blank. +* Add RocketMQ test scenarios for version 4.3 - 4.9. No 4.0 - 4.2 release images for testing. #### Documentation diff --git a/test/plugin/containers/jvm-container/src/main/docker/run.sh b/test/plugin/containers/jvm-container/src/main/docker/run.sh index 4f968dfed..3307374cf 100644 --- a/test/plugin/containers/jvm-container/src/main/docker/run.sh +++ b/test/plugin/containers/jvm-container/src/main/docker/run.sh @@ -85,6 +85,7 @@ export agent_opts=" -Xms256m -Xmx256m ${agent_opts}" bash /var/run/${SCENARIO_NAME}/${SCENARIO_START_SCRIPT} 1>${LOGS_HOME}/scenario.out & +sleep 5 healthCheck ${SCENARIO_HEALTH_CHECK_URL} diff --git a/test/plugin/scenarios/rocketmq-scenario/bin/startup.sh b/test/plugin/scenarios/rocketmq-scenario/bin/startup.sh new file mode 100644 index 000000000..c38926c6f --- /dev/null +++ b/test/plugin/scenarios/rocketmq-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 -Dname.server=${NAME_SERVER} -jar ${agent_opts} ${home}/../libs/rocketmq-scenario.jar & diff --git a/test/plugin/scenarios/rocketmq-scenario/config/expectedData.yaml b/test/plugin/scenarios/rocketmq-scenario/config/expectedData.yaml new file mode 100644 index 000000000..7991de68f --- /dev/null +++ b/test/plugin/scenarios/rocketmq-scenario/config/expectedData.yaml @@ -0,0 +1,69 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +segmentItems: + - serviceName: rocketmq-scenario + segmentSize: ge 2 + segments: + - segmentId: not null + spans: + - operationName: RocketMQ/TopicTest/Producer + parentSpanId: 0 + spanId: 1 + spanLayer: MQ + startTime: nq 0 + endTime: nq 0 + componentId: 38 + isError: false + spanType: Exit + peer: not null + tags: + - {key: mq.broker, value: not null} + - {key: mq.topic, value: TopicTest} + skipAnalysis: 'false' + - operationName: GET:/case/rocketmq-scenario + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 14 + isError: false + spanType: Entry + peer: '' + tags: + - {key: url, value: 'http://localhost:8080/rocketmq-scenario/case/rocketmq-scenario'} + - {key: http.method, value: GET} + - {key: http.status_code, value: '200'} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: RocketMQ/TopicTest/Consumer + parentSpanId: -1 + spanId: 0 + spanLayer: MQ + startTime: nq 0 + endTime: nq 0 + componentId: 39 + isError: false + spanType: Entry + peer: '' + tags: + - {key: transmission.latency, value: not null} + refs: + - {parentEndpoint: GET:/case/rocketmq-scenario, networkAddress: not null, + refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, + parentServiceInstance: not null, parentService: not null, traceId: not null} + skipAnalysis: 'false' diff --git a/test/plugin/scenarios/rocketmq-scenario/configuration.yml b/test/plugin/scenarios/rocketmq-scenario/configuration.yml new file mode 100644 index 000000000..d7db51ec3 --- /dev/null +++ b/test/plugin/scenarios/rocketmq-scenario/configuration.yml @@ -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. + +type: jvm +entryService: http://localhost:8080/rocketmq-scenario/case/rocketmq-scenario +healthCheck: http://localhost:8080/rocketmq-scenario/case/healthCheck +startScript: ./bin/startup.sh +environment: + - NAME_SERVER=namesrv:9876 +depends_on: + - namesrv + - broker +dependencies: + namesrv: + image: apache/rocketmq:${CASE_SERVER_IMAGE_VERSION} + hostname: namesrv + command: sh mqnamesrv + broker: + image: apache/rocketmq:${CASE_SERVER_IMAGE_VERSION} + hostname: broker + command: sh mqbroker -n namesrv:9876 + depends_on: + - namesrv diff --git a/test/plugin/scenarios/rocketmq-scenario/pom.xml b/test/plugin/scenarios/rocketmq-scenario/pom.xml new file mode 100644 index 000000000..71cec225a --- /dev/null +++ b/test/plugin/scenarios/rocketmq-scenario/pom.xml @@ -0,0 +1,127 @@ + + + + + org.apache.skywalking.apm.testcase + rocketmq-scenario + 1.0.0 + jar + + 4.0.0 + + + UTF-8 + 1.8 + 4.9.4 + 2.1.6.RELEASE + 1.18.20 + + + skywalking-rocketmq-scenario + + + + + org.springframework.boot + spring-boot-dependencies + ${spring.boot.version} + pom + import + + + + + + + org.apache.rocketmq + rocketmq-client + ${test.framework.version} + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-logging + + + + + org.springframework.boot + spring-boot-starter-log4j2 + + + org.projectlombok + lombok + ${lombok.version} + provided + + + + + + + rocketmq-scenario + + + org.springframework.boot + spring-boot-maven-plugin + ${spring.boot.version} + + + + 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/rocketmq-scenario/src/main/assembly/assembly.xml b/test/plugin/scenarios/rocketmq-scenario/src/main/assembly/assembly.xml new file mode 100644 index 000000000..c0ba2664c --- /dev/null +++ b/test/plugin/scenarios/rocketmq-scenario/src/main/assembly/assembly.xml @@ -0,0 +1,41 @@ + + + + + zip + + + + + ./bin + 0775 + + + + + + ${project.build.directory}/rocketmq-scenario.jar + ./libs + 0775 + + + diff --git a/test/plugin/scenarios/rocketmq-scenario/src/main/java/test/apache/skywalking/apm/testcase/rocketmq/Application.java b/test/plugin/scenarios/rocketmq-scenario/src/main/java/test/apache/skywalking/apm/testcase/rocketmq/Application.java new file mode 100644 index 000000000..09df8a070 --- /dev/null +++ b/test/plugin/scenarios/rocketmq-scenario/src/main/java/test/apache/skywalking/apm/testcase/rocketmq/Application.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package test.apache.skywalking.apm.testcase.rocketmq; + +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/rocketmq-scenario/src/main/java/test/apache/skywalking/apm/testcase/rocketmq/controller/CaseController.java b/test/plugin/scenarios/rocketmq-scenario/src/main/java/test/apache/skywalking/apm/testcase/rocketmq/controller/CaseController.java new file mode 100644 index 000000000..3ce019c59 --- /dev/null +++ b/test/plugin/scenarios/rocketmq-scenario/src/main/java/test/apache/skywalking/apm/testcase/rocketmq/controller/CaseController.java @@ -0,0 +1,116 @@ +/* + * 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.rocketmq.controller; + +import lombok.extern.slf4j.Slf4j; +import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer; +import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext; +import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus; +import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently; +import org.apache.rocketmq.client.producer.DefaultMQProducer; +import org.apache.rocketmq.client.producer.SendResult; +import org.apache.rocketmq.common.message.Message; +import org.apache.rocketmq.common.message.MessageExt; +import org.apache.rocketmq.remoting.common.RemotingHelper; +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; + +import java.nio.charset.StandardCharsets; +import java.util.Date; +import java.util.List; + +@RestController +@RequestMapping("/case") +@Slf4j +public class CaseController { + + private static final String SUCCESS = "Success"; + + @Value("${name.server}") + private String namerServer; + + @RequestMapping("/rocketmq-scenario") + @ResponseBody + public String testcase() { + try { + // start producer + DefaultMQProducer producer = new DefaultMQProducer("please_rename_unique_group_name"); + producer.setNamesrvAddr(namerServer); + producer.start(); + System.out.printf("Provider Started.%n"); + + // send msg + Message msg = new Message("TopicTest", + "TagA", + ("Hello RocketMQ sendMsg " + new Date()).getBytes(RemotingHelper.DEFAULT_CHARSET) + ); + SendResult sendResult = producer.send(msg); + System.out.printf("%s send msg: %s%n", new Date(), sendResult); + + // start consumer + Thread thread = new Thread(new Runnable() { + @Override + public void run() { + try { + DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("please_rename_unique_group_name"); + consumer.setNamesrvAddr(namerServer); + consumer.subscribe("TopicTest", "*"); + consumer.registerMessageListener(new MessageListenerConcurrently() { + @Override + public ConsumeConcurrentlyStatus consumeMessage(List msgs, ConsumeConcurrentlyContext context) { + System.out.printf("%s Receive New Messages: %s %n", Thread.currentThread().getName(), new String(msgs.get(0).getBody(), StandardCharsets.UTF_8)); + return ConsumeConcurrentlyStatus.CONSUME_SUCCESS; + } + }); + consumer.start(); + System.out.printf("Consumer Started.%n"); + } catch (Exception e) { + log.error("consumer start error", e); + } + } + }); + thread.start(); + } catch (Exception e) { + log.error("testcase error", e); + } + return SUCCESS; + } + + @RequestMapping("/healthCheck") + @ResponseBody + public String healthCheck() throws Exception { + // start producer + DefaultMQProducer producer = new DefaultMQProducer("healthCheck_please_rename_unique_group_name"); + producer.setNamesrvAddr(namerServer); + producer.start(); + System.out.printf("HealthCheck Provider Started.%n"); + + // send msg + Message msg = new Message("HealthCheckTopicTest", + "TagA", + ("Hello RocketMQ sendMsg " + new Date()).getBytes(RemotingHelper.DEFAULT_CHARSET) + ); + SendResult sendResult = producer.send(msg); + System.out.printf("healthCheck %s send msg: %s%n", new Date(), sendResult); + return SUCCESS; + } + +} diff --git a/test/plugin/scenarios/rocketmq-scenario/src/main/resources/application.yaml b/test/plugin/scenarios/rocketmq-scenario/src/main/resources/application.yaml new file mode 100644 index 000000000..5c4366ba9 --- /dev/null +++ b/test/plugin/scenarios/rocketmq-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: /rocketmq-scenario +logging: + config: classpath:log4j2.xml \ No newline at end of file diff --git a/test/plugin/scenarios/rocketmq-scenario/src/main/resources/log4j2.xml b/test/plugin/scenarios/rocketmq-scenario/src/main/resources/log4j2.xml new file mode 100644 index 000000000..9849ed5a8 --- /dev/null +++ b/test/plugin/scenarios/rocketmq-scenario/src/main/resources/log4j2.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/plugin/scenarios/rocketmq-scenario/support-version.list b/test/plugin/scenarios/rocketmq-scenario/support-version.list new file mode 100644 index 000000000..44c67a363 --- /dev/null +++ b/test/plugin/scenarios/rocketmq-scenario/support-version.list @@ -0,0 +1,25 @@ +# 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. + +# lists your version here (Contains only the last version number of each minor version.) + +4.9.4 +4.8.0 +4.7.1 +4.6.0 +4.5.2 +4.4.0 +4.3.1