From e1619495c3395d996b52801676036d01069d0206 Mon Sep 17 00:00:00 2001 From: zifeihan Date: Thu, 22 Oct 2020 14:03:28 +0800 Subject: [PATCH] Add feign loadbalancer case for spring-cloud-feign-1.x-scenario plugin. (#5711) --- .../config/expectedData.yaml | 163 ++++++++++-------- .../apm/testcase/feign/Application.java | 11 ++ .../feign/controller/RestRequest.java | 2 +- .../config/expectedData.yaml | 163 ++++++++++-------- .../apm/testcase/feign/Application.java | 11 ++ .../feign/controller/RestRequest.java | 2 +- 6 files changed, 202 insertions(+), 150 deletions(-) diff --git a/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/config/expectedData.yaml index b05778072..e525349b0 100644 --- a/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/config/expectedData.yaml @@ -14,77 +14,92 @@ # See the License for the specific language governing permissions and # limitations under the License. segmentItems: -- serviceName: spring-cloud-feign-1.1.x-scenario - segmentSize: ge 2 - segments: - - segmentId: not null - spans: - - operationName: /spring-cloud-feign-1.1.x-scenario/case/healthCheck - operationId: 0 - parentSpanId: -1 - spanId: 0 - spanLayer: Http - startTime: nq 0 - endTime: nq 0 - componentId: not null - isError: false - spanType: Entry - peer: '' - tags: - - {key: url, value: 'http://localhost:8080/spring-cloud-feign-1.1.x-scenario/case/healthCheck'} - - {key: http.method, value: HEAD} - skipAnalysis: 'false' - - segmentId: not null - spans: - - operationName: /spring-cloud-feign-1.1.x-scenario/get - operationId: 0 - parentSpanId: -1 - spanId: 0 - spanLayer: Http - startTime: nq 0 - endTime: nq 0 - componentId: not null - isError: false - spanType: Entry - peer: '' - tags: - - {key: url, value: 'http://localhost:8080/spring-cloud-feign-1.1.x-scenario/get'} - - {key: http.method, value: GET} - refs: - - {parentEndpoint: /spring-cloud-feign-1.1.x-scenario/case/spring-cloud-feign-1.1.x-scenario, - networkAddress: 'localhost:8080', refType: CrossProcess, parentSpanId: 1, - parentTraceSegmentId: not null, parentServiceInstance: not null, parentService: spring-cloud-feign-1.1.x-scenario, - traceId: not null} - skipAnalysis: 'false' - - segmentId: not null - spans: - - operationName: /spring-cloud-feign-1.1.x-scenario/get - operationId: 0 - parentSpanId: 0 - spanId: 1 - spanLayer: Http - startTime: nq 0 - endTime: nq 0 - componentId: not null - isError: false - spanType: Exit - peer: localhost:8080 - tags: - - {key: http.method, value: GET} - - {key: url, value: 'http://localhost:8080/spring-cloud-feign-1.1.x-scenario/get'} - skipAnalysis: 'false' - - operationName: /spring-cloud-feign-1.1.x-scenario/case/spring-cloud-feign-1.1.x-scenario - operationId: 0 - parentSpanId: -1 - spanId: 0 - spanLayer: Http - startTime: nq 0 - endTime: nq 0 - componentId: not null - isError: false - spanType: Entry - peer: '' - tags: - - {key: url, value: 'http://localhost:8080/spring-cloud-feign-1.1.x-scenario/case/spring-cloud-feign-1.1.x-scenario'} - - {key: http.method, value: GET} - skipAnalysis: 'false' + - serviceName: spring-cloud-feign-1.1.x-scenario + segmentSize: ge 2 + segments: + - segmentId: not null + spans: + - operationName: /spring-cloud-feign-1.1.x-scenario/case/healthCheck + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: not null + isError: false + spanType: Entry + peer: '' + tags: + - {key: url, value: 'http://localhost:8080/spring-cloud-feign-1.1.x-scenario/case/healthCheck'} + - {key: http.method, value: HEAD} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: /spring-cloud-feign-1.1.x-scenario/get + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: not null + isError: false + spanType: Entry + peer: '' + tags: + - {key: url, value: 'http://localhost:8080/spring-cloud-feign-1.1.x-scenario/get'} + - {key: http.method, value: GET} + refs: + - {parentEndpoint: /spring-cloud-feign-1.1.x-scenario/case/spring-cloud-feign-1.1.x-scenario, + networkAddress: 'localhost:8080', refType: CrossProcess, parentSpanId: not null, + parentTraceSegmentId: not null, parentServiceInstance: not null, parentService: spring-cloud-feign-1.1.x-scenario, + traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: /spring-cloud-feign-1.1.x-scenario/get + operationId: 0 + parentSpanId: 1 + spanId: 2 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: not null + isError: false + spanType: Exit + peer: localhost:8080 + tags: + - {key: http.method, value: GET} + - {key: url, value: 'http://localhost:8080/spring-cloud-feign-1.1.x-scenario/get'} + skipAnalysis: 'false' + - operationName: Balancer/spring-cloud-feign-1.1.x-scenario/get + operationId: 0 + parentSpanId: 0 + spanId: 1 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: not null + isError: false + spanType: Local + peer: '' + tags: + - {key: http.method, value: GET} + - {key: url, value: 'http://spring-cloud-feign-1.1.x-scenario/spring-cloud-feign-1.1.x-scenario/get'} + skipAnalysis: 'false' + - operationName: /spring-cloud-feign-1.1.x-scenario/case/spring-cloud-feign-1.1.x-scenario + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: not null + isError: false + spanType: Entry + peer: '' + tags: + - {key: url, value: 'http://localhost:8080/spring-cloud-feign-1.1.x-scenario/case/spring-cloud-feign-1.1.x-scenario'} + - {key: http.method, value: GET} + skipAnalysis: 'false' diff --git a/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/Application.java b/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/Application.java index 57c9ada2f..00ba039a8 100644 --- a/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/Application.java +++ b/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/Application.java @@ -18,9 +18,13 @@ package org.apache.skywalking.apm.testcase.feign; +import com.netflix.loadbalancer.DynamicServerListLoadBalancer; +import com.netflix.loadbalancer.ILoadBalancer; +import com.netflix.loadbalancer.Server; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.netflix.feign.EnableFeignClients; +import org.springframework.context.annotation.Bean; @SpringBootApplication @EnableFeignClients @@ -33,4 +37,11 @@ public class Application { // Never do this } } + + @Bean + public ILoadBalancer loadBalancer() { + DynamicServerListLoadBalancer serverDynamicServerListLoadBalancer = new DynamicServerListLoadBalancer<>(); + serverDynamicServerListLoadBalancer.addServer(new Server("localhost", 8080)); + return serverDynamicServerListLoadBalancer; + } } diff --git a/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/RestRequest.java b/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/RestRequest.java index 92b3fcb75..c196a16ae 100644 --- a/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/RestRequest.java +++ b/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/RestRequest.java @@ -22,7 +22,7 @@ import org.springframework.cloud.netflix.feign.FeignClient; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; -@FeignClient(value = "spring-cloud-feign-1.1.x-scenario", url = "localhost:8080/spring-cloud-feign-1.1.x-scenario") +@FeignClient(value = "spring-cloud-feign-1.1.x-scenario", path = "/spring-cloud-feign-1.1.x-scenario") public interface RestRequest { @RequestMapping(value = "/get", method = RequestMethod.GET) diff --git a/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/config/expectedData.yaml index f2a113a94..d18a6b2d0 100644 --- a/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/config/expectedData.yaml @@ -14,77 +14,92 @@ # See the License for the specific language governing permissions and # limitations under the License. segmentItems: -- serviceName: spring-cloud-feign-1.2.x-scenario - segmentSize: ge 2 - segments: - - segmentId: not null - spans: - - operationName: /spring-cloud-feign-1.2.x-scenario/case/healthCheck - operationId: 0 - parentSpanId: -1 - spanId: 0 - spanLayer: Http - startTime: nq 0 - endTime: nq 0 - componentId: not null - isError: false - spanType: Entry - peer: '' - tags: - - {key: url, value: 'http://localhost:8080/spring-cloud-feign-1.2.x-scenario/case/healthCheck'} - - {key: http.method, value: HEAD} - skipAnalysis: 'false' - - segmentId: not null - spans: - - operationName: /spring-cloud-feign-1.2.x-scenario/get - operationId: 0 - parentSpanId: -1 - spanId: 0 - spanLayer: Http - startTime: nq 0 - endTime: nq 0 - componentId: not null - isError: false - spanType: Entry - peer: '' - tags: - - {key: url, value: 'http://localhost:8080/spring-cloud-feign-1.2.x-scenario/get'} - - {key: http.method, value: GET} - refs: - - {parentEndpoint: /spring-cloud-feign-1.2.x-scenario/case/spring-cloud-feign-1.2.x-scenario, - networkAddress: 'localhost:8080', refType: CrossProcess, parentSpanId: 1, - parentTraceSegmentId: not null, parentServiceInstance: not null, parentService: spring-cloud-feign-1.2.x-scenario, - traceId: not null} - skipAnalysis: 'false' - - segmentId: not null - spans: - - operationName: /spring-cloud-feign-1.2.x-scenario/get - operationId: 0 - parentSpanId: 0 - spanId: 1 - spanLayer: Http - startTime: nq 0 - endTime: nq 0 - componentId: not null - isError: false - spanType: Exit - peer: localhost:8080 - tags: - - {key: http.method, value: GET} - - {key: url, value: 'http://localhost:8080/spring-cloud-feign-1.2.x-scenario/get'} - skipAnalysis: 'false' - - operationName: /spring-cloud-feign-1.2.x-scenario/case/spring-cloud-feign-1.2.x-scenario - operationId: 0 - parentSpanId: -1 - spanId: 0 - spanLayer: Http - startTime: nq 0 - endTime: nq 0 - componentId: not null - isError: false - spanType: Entry - peer: '' - tags: - - {key: url, value: 'http://localhost:8080/spring-cloud-feign-1.2.x-scenario/case/spring-cloud-feign-1.2.x-scenario'} - - {key: http.method, value: GET} - skipAnalysis: 'false' + - serviceName: spring-cloud-feign-1.2.x-scenario + segmentSize: ge 2 + segments: + - segmentId: not null + spans: + - operationName: /spring-cloud-feign-1.2.x-scenario/case/healthCheck + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: not null + isError: false + spanType: Entry + peer: '' + tags: + - {key: url, value: 'http://localhost:8080/spring-cloud-feign-1.2.x-scenario/case/healthCheck'} + - {key: http.method, value: HEAD} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: /spring-cloud-feign-1.2.x-scenario/get + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: not null + isError: false + spanType: Entry + peer: '' + tags: + - {key: url, value: 'http://localhost:8080/spring-cloud-feign-1.2.x-scenario/get'} + - {key: http.method, value: GET} + refs: + - {parentEndpoint: /spring-cloud-feign-1.2.x-scenario/case/spring-cloud-feign-1.2.x-scenario, + networkAddress: 'localhost:8080', refType: CrossProcess, parentSpanId: not null, + parentTraceSegmentId: not null, parentServiceInstance: not null, parentService: spring-cloud-feign-1.2.x-scenario, + traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: /spring-cloud-feign-1.2.x-scenario/get + operationId: 0 + parentSpanId: 1 + spanId: 2 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: not null + isError: false + spanType: Exit + peer: localhost:8080 + tags: + - {key: http.method, value: GET} + - {key: url, value: 'http://localhost:8080/spring-cloud-feign-1.2.x-scenario/get'} + skipAnalysis: 'false' + - operationName: Balancer/spring-cloud-feign-1.2.x-scenario/get + operationId: 0 + parentSpanId: 0 + spanId: 1 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: not null + isError: false + spanType: Local + peer: '' + tags: + - {key: http.method, value: GET} + - {key: url, value: 'http://spring-cloud-feign-1.2.x-scenario/spring-cloud-feign-1.2.x-scenario/get'} + skipAnalysis: 'false' + - operationName: /spring-cloud-feign-1.2.x-scenario/case/spring-cloud-feign-1.2.x-scenario + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: not null + isError: false + spanType: Entry + peer: '' + tags: + - {key: url, value: 'http://localhost:8080/spring-cloud-feign-1.2.x-scenario/case/spring-cloud-feign-1.2.x-scenario'} + - {key: http.method, value: GET} + skipAnalysis: 'false' diff --git a/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/Application.java b/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/Application.java index 57c9ada2f..00ba039a8 100644 --- a/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/Application.java +++ b/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/Application.java @@ -18,9 +18,13 @@ package org.apache.skywalking.apm.testcase.feign; +import com.netflix.loadbalancer.DynamicServerListLoadBalancer; +import com.netflix.loadbalancer.ILoadBalancer; +import com.netflix.loadbalancer.Server; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.netflix.feign.EnableFeignClients; +import org.springframework.context.annotation.Bean; @SpringBootApplication @EnableFeignClients @@ -33,4 +37,11 @@ public class Application { // Never do this } } + + @Bean + public ILoadBalancer loadBalancer() { + DynamicServerListLoadBalancer serverDynamicServerListLoadBalancer = new DynamicServerListLoadBalancer<>(); + serverDynamicServerListLoadBalancer.addServer(new Server("localhost", 8080)); + return serverDynamicServerListLoadBalancer; + } } diff --git a/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/RestRequest.java b/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/RestRequest.java index abe9f0ca0..1c24d28b0 100644 --- a/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/RestRequest.java +++ b/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/RestRequest.java @@ -22,7 +22,7 @@ import org.springframework.cloud.netflix.feign.FeignClient; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; -@FeignClient(value = "spring-cloud-feign-1.2.x-scenario", url = "localhost:8080/spring-cloud-feign-1.2.x-scenario") +@FeignClient(value = "spring-cloud-feign-1.2.x-scenario", path = "/spring-cloud-feign-1.2.x-scenario") public interface RestRequest { @RequestMapping(value = "/get", method = RequestMethod.GET)