diff --git a/Jenkinsfile-Agent-Test b/Jenkinsfile-Agent-Test index aa82fb6ad..506b7ce69 100755 --- a/Jenkinsfile-Agent-Test +++ b/Jenkinsfile-Agent-Test @@ -54,6 +54,11 @@ pipeline { sh './mvnw -f test/plugin/pom.xml clean package -DskipTests -Dbuild_id=${BUILD_ID} docker:build' } } + stage('Test Cases Report') { + steps { + echo "total test cases: 135" + } + } stage('Run Agent Plugin Tests') { parallel { stage('Group1') { @@ -76,8 +81,8 @@ pipeline { } } - stage('spring async 4.3.x-5.1.x (35)'){ - steps{ + stage('spring async 4.3.x-5.1.x (35)') { + steps { sh 'bash test/plugin/run.sh --build_id=${BUILD_ID} spring-async-scenario' } } diff --git a/Jenkinsfile-Agent-Test-2 b/Jenkinsfile-Agent-Test-2 index 7f7a21d79..164b131c7 100755 --- a/Jenkinsfile-Agent-Test-2 +++ b/Jenkinsfile-Agent-Test-2 @@ -54,6 +54,11 @@ pipeline { sh './mvnw -f test/plugin/pom.xml clean package -DskipTests -Dbuild_id=${BUILD_ID} docker:build' } } + stage('Test Cases Report') { + steps { + echo "total test cases: 132" + } + } stage('Run Agent Plugin Tests') { parallel { stage('Group1') { diff --git a/Jenkinsfile-Agent-Test-3 b/Jenkinsfile-Agent-Test-3 index 64d5846c9..69196a001 100755 --- a/Jenkinsfile-Agent-Test-3 +++ b/Jenkinsfile-Agent-Test-3 @@ -54,6 +54,11 @@ pipeline { sh './mvnw -f test/plugin/pom.xml clean package -DskipTests -Dbuild_id=${BUILD_ID} docker:build' } } + stage('Test Cases Report') { + steps { + echo "total test cases: 21" + } + } stage('Run Agent Plugin Tests') { parallel { stage('Group1') { @@ -63,6 +68,11 @@ pipeline { sh 'bash test/plugin/run.sh --build_id=${BUILD_ID} kafka-scenario' } } + stage('canal 1.0.24-1.1.2 (5)') { + steps { + sh 'bash test/plugin/run.sh --build_id=${BUILD_ID} canal-scenario' + } + } } } stage('Group2') { diff --git a/test/plugin/scenarios/canal-scenario/bin/startup.sh b/test/plugin/scenarios/canal-scenario/bin/startup.sh new file mode 100644 index 000000000..727110681 --- /dev/null +++ b/test/plugin/scenarios/canal-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 -Dcanal.host=${CANAL_HOST} -Dcanal.port=${CANAL_PORT} -jar ${agent_opts} ${home}/../libs/canal-scenario.jar & \ No newline at end of file diff --git a/test/plugin/scenarios/canal-scenario/config/expectedData.yaml b/test/plugin/scenarios/canal-scenario/config/expectedData.yaml new file mode 100644 index 000000000..154e28bc9 --- /dev/null +++ b/test/plugin/scenarios/canal-scenario/config/expectedData.yaml @@ -0,0 +1,66 @@ +# 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: + - {canal-scenario: 2} + instances: + - {canal-scenario: 1} + operationNames: + - canal-scenario: [Canal/example, /canal-scenario/case/canal-case] + heartbeat: [] +segmentItems: + - applicationCode: canal-scenario + segmentSize: gt 1 + segments: + - segmentId: not null + spans: + - operationName: Canal/example + operationId: 0 + parentSpanId: 0 + spanId: 1 + spanLayer: Unknown + startTime: nq 0 + endTime: nq 0 + componentId: 54 + componentName: '' + isError: false + spanType: Exit + peer: not null + peerId: 0 + tags: + - {key: batchSize, value: '1000'} + - {key: destination, value: example} + - operationName: /canal-scenario/case/canal-case + 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/canal-scenario/case/canal-case'} + - {key: http.method, value: GET} + + + + + diff --git a/test/plugin/scenarios/canal-scenario/configuration.yml b/test/plugin/scenarios/canal-scenario/configuration.yml new file mode 100644 index 000000000..d976aa951 --- /dev/null +++ b/test/plugin/scenarios/canal-scenario/configuration.yml @@ -0,0 +1,43 @@ +# 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/canal-scenario/case/canal-case +healthCheck: http://localhost:8080/canal-scenario/case/healthCheck +startScript: ./bin/startup.sh +framework: canal +environment: + - CANAL_HOST=canal-server + - CANAL_PORT=11111 +depends_on: + - mysql + - canal-server +dependencies: + mysql: + image: mysql:5.7 + hostname: mysql + environment: + - MYSQL_ROOT_PASSWORD=000000 + canal-server: + image: canal/canal-server:v1.1.0 + hostname: canal-server + environment: + - canal.instance.master.address=mysql:3306 + - canal.instance.master.journal.name=mysql-bin.000001 + - canal.instance.dbUsername=root + - canal.instance.dbPassword=000000 + depends_on: + - mysql \ No newline at end of file diff --git a/test/plugin/scenarios/canal-scenario/pom.xml b/test/plugin/scenarios/canal-scenario/pom.xml new file mode 100644 index 000000000..3c2118ce5 --- /dev/null +++ b/test/plugin/scenarios/canal-scenario/pom.xml @@ -0,0 +1,168 @@ + + + + 4.0.0 + + org.apache.skywalking + canal-scenario + 5.0.0 + + skywalking-canal-scenario + + + UTF-8 + 1.1.2 + 1.8 + + 2.6.2 + 4.3.8.RELEASE + 1.5.2.RELEASE + + + + + com.alibaba.otter + canal.client + + + ch.qos.logback + logback-core + + + ch.qos.logback + logback-classic + + + org.slf4j + jcl-over-slf4j + + + + org.slf4j + slf4j-api + + + org.springframework + spring-core + + + + org.springframework + spring-jdbc + + + + org.springframework + spring-test + + + org.springframework + spring-aop + + + org.springframework + spring-context + + + org.springframework + spring-orm + + + + org.springframework + spring + + + ${test.framework.version} + + + + org.springframework.boot + spring-boot-starter + ${spring-boot-version} + + + org.springframework.boot + spring-boot-starter-tomcat + ${spring-boot-version} + + + org.springframework.boot + spring-boot-starter-web + ${spring-boot-version} + + + + + canal-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/ + + + + + + + + + + spring-snapshots + http://repo.spring.io/snapshot + + + spring-milestones + http://repo.spring.io/milestone + + + \ No newline at end of file diff --git a/test/plugin/scenarios/canal-scenario/src/main/assembly/assembly.xml b/test/plugin/scenarios/canal-scenario/src/main/assembly/assembly.xml new file mode 100644 index 000000000..7227ba192 --- /dev/null +++ b/test/plugin/scenarios/canal-scenario/src/main/assembly/assembly.xml @@ -0,0 +1,41 @@ + + + + + zip + + + + + ./bin + 0775 + + + + + + ${project.build.directory}/canal-scenario.jar + ./libs + 0775 + + + diff --git a/test/plugin/scenarios/canal-scenario/src/main/java/org/apache/skywalking/apm/testcase/canal/Application.java b/test/plugin/scenarios/canal-scenario/src/main/java/org/apache/skywalking/apm/testcase/canal/Application.java new file mode 100644 index 000000000..a13d976e0 --- /dev/null +++ b/test/plugin/scenarios/canal-scenario/src/main/java/org/apache/skywalking/apm/testcase/canal/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.canal; + +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/canal-scenario/src/main/java/org/apache/skywalking/apm/testcase/canal/controller/CaseController.java b/test/plugin/scenarios/canal-scenario/src/main/java/org/apache/skywalking/apm/testcase/canal/controller/CaseController.java new file mode 100644 index 000000000..3fb82dd13 --- /dev/null +++ b/test/plugin/scenarios/canal-scenario/src/main/java/org/apache/skywalking/apm/testcase/canal/controller/CaseController.java @@ -0,0 +1,89 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.testcase.canal.controller; + + +import com.alibaba.otter.canal.client.CanalConnector; +import com.alibaba.otter.canal.client.CanalConnectors; +import com.alibaba.otter.canal.protocol.Message; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +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; + +import java.net.InetSocketAddress; +import java.util.function.Consumer; + + +@Controller +@RequestMapping("/case") +@PropertySource("classpath:application.properties") +public class CaseController { + + private static final String SUCCESS = "Success"; + + private Logger logger = LoggerFactory.getLogger(CaseController.class); + + @Value(value = "${canal.host}") + private String address; + + @Value(value = "${canal.port}") + private int port; + + + @RequestMapping("/canal-case") + @ResponseBody + public String canalCase() { + wrapCreateConnector("example", connector -> { + try { + int batchSize = 1000; + connector.subscribe(".*\\..*"); + connector.rollback(); + Message message = connector.getWithoutAck(batchSize); + long batchId = message.getId(); + logger.info(message.getEntries().toString()); + connector.ack(batchId); + } catch (Exception ex) { + logger.error(ex.toString()); + } + }); + return SUCCESS; + } + + @RequestMapping("/healthCheck") + @ResponseBody + public String healthCheck() { + wrapCreateConnector("healthCheck", connect -> { + }); + return SUCCESS; + } + + private void wrapCreateConnector(String destination, Consumer consumer) { + CanalConnector connector = CanalConnectors.newSingleConnector(new InetSocketAddress(address, port), destination, "", ""); + connector.connect(); + try { + consumer.accept(connector); + } finally { + connector.disconnect(); + } + } +} diff --git a/test/plugin/scenarios/canal-scenario/src/main/resources/application.properties b/test/plugin/scenarios/canal-scenario/src/main/resources/application.properties new file mode 100644 index 000000000..f55449911 --- /dev/null +++ b/test/plugin/scenarios/canal-scenario/src/main/resources/application.properties @@ -0,0 +1,20 @@ +# +# 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=/canal-scenario \ No newline at end of file diff --git a/test/plugin/scenarios/canal-scenario/src/main/resources/log4j2.xml b/test/plugin/scenarios/canal-scenario/src/main/resources/log4j2.xml new file mode 100644 index 000000000..b5cda5ae8 --- /dev/null +++ b/test/plugin/scenarios/canal-scenario/src/main/resources/log4j2.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + diff --git a/test/plugin/scenarios/canal-scenario/support-version.list b/test/plugin/scenarios/canal-scenario/support-version.list new file mode 100644 index 000000000..3be9c391a --- /dev/null +++ b/test/plugin/scenarios/canal-scenario/support-version.list @@ -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 +# "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.1.2 +1.1.1 +1.1.0 +1.0.25 +1.0.24 \ No newline at end of file