diff --git a/Jenkinsfile-Agent-Test-2 b/Jenkinsfile-Agent-Test-2 index ad1d5f376..07ddf6533 100755 --- a/Jenkinsfile-Agent-Test-2 +++ b/Jenkinsfile-Agent-Test-2 @@ -66,7 +66,7 @@ pipeline { sh './mvnw -f test/plugin/pom.xml clean package -DskipTests -Dbuild_id=wl2_${BUILD_ID} docker:build' } } - stage('Test Cases Report (174)') { + stage('Test Cases Report (175)') { steps { echo "reserve." } @@ -142,6 +142,12 @@ pipeline { sh 'bash test/plugin/run.sh --build_id=wl2_${BUILD_ID} undertow-scenario' } } + + stage('customize-scenario (1)') { + steps { + sh 'bash test/plugin/run.sh --build_id=wl2_${BUILD_ID} customize-scenario' + } + } } } } diff --git a/test/plugin/scenarios/customize-scenario/bin/startup.sh b/test/plugin/scenarios/customize-scenario/bin/startup.sh new file mode 100644 index 000000000..3cc699d99 --- /dev/null +++ b/test/plugin/scenarios/customize-scenario/bin/startup.sh @@ -0,0 +1,23 @@ +#!/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} \ + -Dskywalking.plugin.customize.enhance_file=${home}/../config/customize_enhance.xml \ + ${home}/../libs/customize-scenario.jar & \ No newline at end of file diff --git a/test/plugin/scenarios/customize-scenario/config/customize_enhance.xml b/test/plugin/scenarios/customize-scenario/config/customize_enhance.xml new file mode 100644 index 000000000..21c14f966 --- /dev/null +++ b/test/plugin/scenarios/customize-scenario/config/customize_enhance.xml @@ -0,0 +1,57 @@ + + + + + + + arg[0] + arg[1] + arg[3].[0] + arg[2].['k1'] + arg[4].[1] + arg[4].[2] + + + + arg[0] + arg[0] + arg[1] + + + arg[0].id + arg[0].model1.name + arg[0].model1.getId() + arg[0].os.[1] + arg[0].getM().['k1'] + + + + + arg[0] + arg[1] + + + arg[0].[0]CustomizeController + + + arg[0].[0] + arg[1] + + + \ No newline at end of file diff --git a/test/plugin/scenarios/customize-scenario/config/expectedData.yaml b/test/plugin/scenarios/customize-scenario/config/expectedData.yaml new file mode 100644 index 000000000..77c95dc30 --- /dev/null +++ b/test/plugin/scenarios/customize-scenario/config/expectedData.yaml @@ -0,0 +1,153 @@ +# 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: + - {customize-scenario: nq 0} + instances: + - {customize-scenario: 1} + operationNames: + - customize-scenario: [/case/customize] +segmentItems: + - applicationCode: customize-scenario + segmentSize: gt 1 + segments: + - segmentId: not null + spans: + - operationName: /is_static_method + operationId: 0 + parentSpanId: 0 + spanId: 1 + startTime: nq 0 + endTime: nq 0 + componentName: '' + isError: false + peerId: 0 + spanType: Local + - operationName: /is_static_method_args/id/123/a + operationId: 0 + parentSpanId: 0 + spanId: 2 + startTime: nq 0 + endTime: nq 0 + componentName: '' + isError: false + peerId: 0 + spanType: Local + tags: + - {key: tag_1, value: v1} + - {key: tag_2, value: '2'} + logs: + - logEvent: + - {key: log_1, value: '3'} + - operationName: test.org.apache.skywalking.apm.testcase.customize.service.TestService1.method() + operationId: 0 + parentSpanId: 0 + spanId: 3 + startTime: nq 0 + endTime: nq 0 + componentName: '' + isError: false + peerId: 0 + spanType: Local + - operationName: /method_2/str0 + operationId: 0 + parentSpanId: 0 + spanId: 4 + startTime: nq 0 + endTime: nq 0 + componentName: '' + isError: false + peerId: 0 + spanType: Local + tags: + - {key: tag_1, value: str0} + logs: + - logEvent: + - {key: log_1, value: '123'} + - operationName: /method_3/id/name/100 + operationId: 0 + parentSpanId: 0 + spanId: 5 + startTime: nq 0 + endTime: nq 0 + componentName: '' + isError: false + peerId: 0 + spanType: Local + tags: + - {key: tag_os, value: '2'} + logs: + - logEvent: + - {key: log_map, value: v1} + - operationName: /is_2_static_method + operationId: 0 + parentSpanId: 0 + spanId: 6 + startTime: nq 0 + endTime: nq 0 + componentName: '' + isError: false + peerId: 0 + spanType: Local + tags: + - {key: tag_2_1, value: s} + logs: + - logEvent: + - {key: log_1_1, value: '123'} + - operationName: /method_4 + operationId: 0 + parentSpanId: 0 + spanId: 7 + startTime: nq 0 + endTime: nq 0 + componentName: '' + isError: false + peerId: 0 + spanType: Local + tags: + - {key: tag_4_1, value: '1'} + - operationName: /method_5 + operationId: 0 + parentSpanId: 0 + spanId: 8 + startTime: nq 0 + endTime: nq 0 + componentName: '' + isError: false + peerId: 0 + spanType: Local + tags: + - {key: tag_5_1, value: a2} + logs: + - logEvent: + - {key: log_5_1, value: '123'} + - operationName: /case/customize + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: 'not null' + endTime: 'not null' + componentId: 14 + componentName: '' + isError: false + spanType: Entry + peer: '' + peerId: 0 + tags: + - {key: url, value: 'http://localhost:8080/customize-scenario/case/customize'} + - {key: http.method, value: GET} \ No newline at end of file diff --git a/test/plugin/scenarios/customize-scenario/configuration.yml b/test/plugin/scenarios/customize-scenario/configuration.yml new file mode 100644 index 000000000..928f2dc07 --- /dev/null +++ b/test/plugin/scenarios/customize-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/customize-scenario/case/customize +healthCheck: http://localhost:8080/customize-scenario/case/healthCheck +startScript: ./bin/startup.sh +framework: customize-scenario +runningMode: with_optional +withPlugins: apm-customize-enhance-plugin-*.jar diff --git a/test/plugin/scenarios/customize-scenario/pom.xml b/test/plugin/scenarios/customize-scenario/pom.xml new file mode 100644 index 000000000..c1c65f54d --- /dev/null +++ b/test/plugin/scenarios/customize-scenario/pom.xml @@ -0,0 +1,112 @@ + + + + 4.0.0 + + org.apache.skywalking + customize-scenario + 5.0.0 + + + UTF-8 + 1.8 + 2.1.6.RELEASE + + customize-scenario + 1.0.0 + + + skywalking-customize-scenario + + + + + org.springframework.boot + spring-boot-dependencies + ${spring.boot.version} + pom + import + + + + + + + org.springframework.boot + spring-boot-starter-web + + + + + customize-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/customize-scenario/src/main/assembly/assembly.xml b/test/plugin/scenarios/customize-scenario/src/main/assembly/assembly.xml new file mode 100644 index 000000000..3981fc2f5 --- /dev/null +++ b/test/plugin/scenarios/customize-scenario/src/main/assembly/assembly.xml @@ -0,0 +1,46 @@ + + + + + zip + + + + + ./bin + 0775 + + + + + + ./target/customize-scenario.jar + ./libs + 0775 + + + ./config/customize_enhance.xml + ./config + 0555 + + + \ No newline at end of file diff --git a/test/plugin/scenarios/customize-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/customize/Application.java b/test/plugin/scenarios/customize-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/customize/Application.java new file mode 100644 index 000000000..71ce9cdbc --- /dev/null +++ b/test/plugin/scenarios/customize-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/customize/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.org.apache.skywalking.apm.testcase.customize; + +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/customize-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/customize/controller/CustomizeController.java b/test/plugin/scenarios/customize-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/customize/controller/CustomizeController.java new file mode 100644 index 000000000..9709ca863 --- /dev/null +++ b/test/plugin/scenarios/customize-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/customize/controller/CustomizeController.java @@ -0,0 +1,81 @@ +/* + * 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.org.apache.skywalking.apm.testcase.customize.controller; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; +import test.org.apache.skywalking.apm.testcase.customize.model.Model0; +import test.org.apache.skywalking.apm.testcase.customize.model.Model1; +import test.org.apache.skywalking.apm.testcase.customize.service.TestService1; +import test.org.apache.skywalking.apm.testcase.customize.service.TestService2; + +import java.util.ArrayList; +import java.util.HashMap; + + +@RestController +@RequestMapping("/case") +public class CustomizeController { + + private Logger logger = LoggerFactory.getLogger(CustomizeController.class); + + private static final String SUCCESS = "Success"; + + private TestService1 testService1 = new TestService1(); + private TestService2 testService2 = new TestService2(); + + @RequestMapping("/customize") + @ResponseBody + public String customizeCase() { + Model0 m0 = new Model0("id", 123, new Model1(100, "name"), new HashMap() {{ + put("k1", "v1"); + }}, new ArrayList() {{ + add("a"); + }}, new Object[] {'1', 2, "3"}); + + TestService1.staticMethod(); + TestService1.staticMethod("id", 123, new HashMap() {{ + put("k1", "v1"); + }}, new ArrayList() {{ + add("a"); + }}, new Object[] {'1', 2, "3"}); + testService1.method(); + testService1.method("str0", 123); + testService1.method(m0, "def_str_0", 123); + + TestService2.staticMethod("s", 123); + testService2.method(new Object[] {'1', 2, "3"}); + testService2.method(new ArrayList() {{ + add("a2"); + }}, 123); + + + logger.info(SUCCESS); + return SUCCESS; + } + + @RequestMapping("/healthCheck") + @ResponseBody + public String healthCheck() { + return SUCCESS; + } +} diff --git a/test/plugin/scenarios/customize-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/customize/model/Model0.java b/test/plugin/scenarios/customize-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/customize/model/Model0.java new file mode 100644 index 000000000..3374b6203 --- /dev/null +++ b/test/plugin/scenarios/customize-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/customize/model/Model0.java @@ -0,0 +1,93 @@ +/* + * 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.org.apache.skywalking.apm.testcase.customize.model; + +import java.util.List; +import java.util.Map; + +/** + * @author zhaoyuguang + */ + +public class Model0 { + + public Model0(String id, int num, Model1 model1, Map m, List l, Object[] os) { + this.id = id; + this.num = num; + this.model1 = model1; + this.m = m; + this.l = l; + this.os = os; + } + + private String id; + private int num; + private Model1 model1; + private Map m; + private List l; + private Object[] os; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public int getNum() { + return num; + } + + public void setNum(int num) { + this.num = num; + } + + public Model1 getModel1() { + return model1; + } + + public void setModel1(Model1 model1) { + this.model1 = model1; + } + + public Map getM() { + return m; + } + + public void setM(Map m) { + this.m = m; + } + + public List getL() { + return l; + } + + public void setL(List l) { + this.l = l; + } + + public Object[] getOs() { + return os; + } + + public void setOs(Object[] os) { + this.os = os; + } +} diff --git a/test/plugin/scenarios/customize-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/customize/model/Model1.java b/test/plugin/scenarios/customize-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/customize/model/Model1.java new file mode 100644 index 000000000..712dbbd33 --- /dev/null +++ b/test/plugin/scenarios/customize-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/customize/model/Model1.java @@ -0,0 +1,50 @@ +/* + * 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.org.apache.skywalking.apm.testcase.customize.model; + +/** + * @author zhaoyuguang + */ + +public class Model1 { + + public Model1(int id, String name) { + this.id = id; + this.name = name; + } + + private int id; + private String name; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/test/plugin/scenarios/customize-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/customize/service/TestService1.java b/test/plugin/scenarios/customize-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/customize/service/TestService1.java new file mode 100644 index 000000000..63d1c032f --- /dev/null +++ b/test/plugin/scenarios/customize-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/customize/service/TestService1.java @@ -0,0 +1,51 @@ +/* + * 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.org.apache.skywalking.apm.testcase.customize.service; + +import test.org.apache.skywalking.apm.testcase.customize.model.Model0; + +import java.util.List; +import java.util.Map; + +/** + * @author zhaoyuguang + */ + +public class TestService1 { + + public static void staticMethod() { + + } + + public static void staticMethod(String str0, int count, Map m, List l, Object[] os) { + + } + + public void method() { + + } + + public void method(String str0, int count) { + + } + + public void method(Model0 m0, String str0, int count) { + + } +} diff --git a/test/plugin/scenarios/customize-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/customize/service/TestService2.java b/test/plugin/scenarios/customize-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/customize/service/TestService2.java new file mode 100644 index 000000000..8ddc8d0ad --- /dev/null +++ b/test/plugin/scenarios/customize-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/customize/service/TestService2.java @@ -0,0 +1,40 @@ +/* + * 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.org.apache.skywalking.apm.testcase.customize.service; + +import java.util.List; + +/** + * @author zhaoyuguang + */ +public class TestService2 { + + + public static void staticMethod(String str0, int count) { + + } + + public void method(Object[] objects) { + + } + + public void method(List str0, int count) { + + } +} diff --git a/test/plugin/scenarios/customize-scenario/src/main/resources/application.yaml b/test/plugin/scenarios/customize-scenario/src/main/resources/application.yaml new file mode 100644 index 000000000..fdc1fd9a8 --- /dev/null +++ b/test/plugin/scenarios/customize-scenario/src/main/resources/application.yaml @@ -0,0 +1,22 @@ +# +# 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: /customize-scenario \ No newline at end of file diff --git a/test/plugin/scenarios/customize-scenario/support-version.list b/test/plugin/scenarios/customize-scenario/support-version.list new file mode 100644 index 000000000..5061adb46 --- /dev/null +++ b/test/plugin/scenarios/customize-scenario/support-version.list @@ -0,0 +1,17 @@ +# 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. + +1.0.0 \ No newline at end of file