[test/plugin] immigrate test feign scenario. (#3838)
* immigrate test feign scenario. * add license. * update use test skeleton. * delete repeat spring-boot starter dependence. * add support-list version.
This commit is contained in:
parent
41bb3b5c0a
commit
5f8ee254a4
|
|
@ -68,7 +68,7 @@ pipeline {
|
|||
}
|
||||
}
|
||||
|
||||
stage('Test Cases Report (136)') {
|
||||
stage('Test Cases Report (144)') {
|
||||
steps {
|
||||
echo "Test Cases Report"
|
||||
}
|
||||
|
|
@ -105,6 +105,12 @@ pipeline {
|
|||
|
||||
stage('Group2') {
|
||||
stages {
|
||||
stage('feign 9.0.0-9.5.1 (8)') {
|
||||
steps {
|
||||
sh 'bash test/plugin/run.sh feign-scenario'
|
||||
}
|
||||
}
|
||||
|
||||
stage('customize (1)') {
|
||||
steps {
|
||||
sh 'bash test/plugin/run.sh customize-scenario'
|
||||
|
|
|
|||
|
|
@ -619,9 +619,10 @@ apm-toolkit-trace | 1 | 87.00
|
|||
jetty 9.x | 63 | 2043.00
|
||||
netty-socketio 1.x | 4 | 117.00
|
||||
|
||||
#### Group 2 (2119.991s)
|
||||
#### Group 2 (2291.98s)
|
||||
scenario name | versions | elapsed time (sec)
|
||||
---|---|---
|
||||
feign 9.0.0-9.5.1 | 8 | 172.00
|
||||
customize | 1 | 85.64
|
||||
postgresql 9.4.1207+ | 62 | 1820.29
|
||||
canal 1.0.24-1.1.2 | 5 | 214.05
|
||||
|
|
|
|||
|
|
@ -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 -jar ${agent_opts} ${home}/../libs/feign-scenario.jar &
|
||||
|
|
@ -0,0 +1,202 @@
|
|||
# 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:
|
||||
- {feign-scenario: nq 0}
|
||||
instances:
|
||||
- {feign-scenario: 1}
|
||||
operationNames:
|
||||
- feign-scenario: [/feign-scenario/update/1, /feign-scenario/get/1, /feign-scenario/create/,
|
||||
/feign-scenario/case/feign-scenario, /feign-scenario/delete/1]
|
||||
heartbeat: []
|
||||
segmentItems:
|
||||
- applicationCode: feign-scenario
|
||||
segmentSize: ge 1
|
||||
segments:
|
||||
- segmentId: not null
|
||||
spans:
|
||||
- operationName: /feign-scenario/create/
|
||||
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/feign-scenario/create/'}
|
||||
- {key: http.method, value: POST}
|
||||
refs:
|
||||
- {parentEndpointId: 0, parentEndpoint: /feign-scenario/case/feign-scenario, networkAddressId: 0,
|
||||
entryEndpointId: 0, refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: "${feign-scenario[4]}",
|
||||
parentServiceInstanceId: nq 0, networkAddress: 'localhost:8080', entryEndpoint: /feign-scenario/case/feign-scenario,
|
||||
entryServiceInstanceId: nq 0}
|
||||
- segmentId: not null
|
||||
spans:
|
||||
- operationName: /feign-scenario/get/1
|
||||
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/feign-scenario/get/1'}
|
||||
- {key: http.method, value: GET}
|
||||
refs:
|
||||
- {parentEndpointId: 0, parentEndpoint: /feign-scenario/case/feign-scenario, networkAddressId: 0,
|
||||
entryEndpointId: 0, refType: CrossProcess, parentSpanId: 2, parentTraceSegmentId: "${feign-scenario[4]}",
|
||||
parentServiceInstanceId: 1, networkAddress: 'localhost:8080', entryEndpoint: /feign-scenario/case/feign-scenario,
|
||||
entryServiceInstanceId: 1}
|
||||
- segmentId: not null
|
||||
spans:
|
||||
- operationName: /feign-scenario/update/1
|
||||
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/feign-scenario/update/1'}
|
||||
- {key: http.method, value: PUT}
|
||||
refs:
|
||||
- {parentEndpointId: 0, parentEndpoint: /feign-scenario/case/feign-scenario, networkAddressId: 0,
|
||||
entryEndpointId: 0, refType: CrossProcess, parentSpanId: 3, parentTraceSegmentId: "${feign-scenario[4]}",
|
||||
parentServiceInstanceId: 1, networkAddress: 'localhost:8080', entryEndpoint: /feign-scenario/case/feign-scenario,
|
||||
entryServiceInstanceId: 1}
|
||||
- segmentId: not null
|
||||
spans:
|
||||
- operationName: /feign-scenario/delete/1
|
||||
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/feign-scenario/delete/1'}
|
||||
- {key: http.method, value: DELETE}
|
||||
refs:
|
||||
- {parentEndpointId: 0, parentEndpoint: /feign-scenario/case/feign-scenario, networkAddressId: 0,
|
||||
entryEndpointId: 0, refType: CrossProcess, parentSpanId: 4, parentTraceSegmentId: "${feign-scenario[4]}",
|
||||
parentServiceInstanceId: 1, networkAddress: 'localhost:8080', entryEndpoint: /feign-scenario/case/feign-scenario,
|
||||
entryServiceInstanceId: 1}
|
||||
- segmentId: not null
|
||||
spans:
|
||||
- operationName: /feign-scenario/create/
|
||||
operationId: 0
|
||||
parentSpanId: 0
|
||||
spanId: 1
|
||||
spanLayer: Http
|
||||
startTime: nq 0
|
||||
endTime: nq 0
|
||||
componentId: 11
|
||||
componentName: ''
|
||||
isError: false
|
||||
spanType: Exit
|
||||
peer: localhost:8080
|
||||
peerId: 0
|
||||
tags:
|
||||
- {key: http.method, value: POST}
|
||||
- {key: url, value: 'http://localhost:8080/feign-scenario/create/'}
|
||||
- operationName: /feign-scenario/get/1
|
||||
operationId: 0
|
||||
parentSpanId: 0
|
||||
spanId: 2
|
||||
spanLayer: Http
|
||||
startTime: nq 0
|
||||
endTime: nq 0
|
||||
componentId: 11
|
||||
componentName: ''
|
||||
isError: false
|
||||
spanType: Exit
|
||||
peer: localhost:8080
|
||||
peerId: 0
|
||||
tags:
|
||||
- {key: http.method, value: GET}
|
||||
- {key: url, value: 'http://localhost:8080/feign-scenario/get/1'}
|
||||
- operationName: /feign-scenario/update/1
|
||||
operationId: 0
|
||||
parentSpanId: 0
|
||||
spanId: 3
|
||||
spanLayer: Http
|
||||
startTime: nq 0
|
||||
endTime: nq 0
|
||||
componentId: 11
|
||||
componentName: ''
|
||||
isError: false
|
||||
spanType: Exit
|
||||
peer: localhost:8080
|
||||
peerId: 0
|
||||
tags:
|
||||
- {key: http.method, value: PUT}
|
||||
- {key: url, value: 'http://localhost:8080/feign-scenario/update/1'}
|
||||
- operationName: /feign-scenario/delete/1
|
||||
operationId: 0
|
||||
parentSpanId: 0
|
||||
spanId: 4
|
||||
spanLayer: Http
|
||||
startTime: nq 0
|
||||
endTime: nq 0
|
||||
componentId: 11
|
||||
componentName: ''
|
||||
isError: false
|
||||
spanType: Exit
|
||||
peer: localhost:8080
|
||||
peerId: 0
|
||||
tags:
|
||||
- {key: http.method, value: DELETE}
|
||||
- {key: url, value: 'http://localhost:8080/feign-scenario/delete/1'}
|
||||
- operationName: /feign-scenario/case/feign-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/feign-scenario/case/feign-scenario'}
|
||||
- {key: http.method, value: GET}
|
||||
|
|
@ -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/feign-scenario/case/feign-scenario
|
||||
healthCheck: http://localhost:8080/feign-scenario/case/healthCheck
|
||||
startScript: ./bin/startup.sh
|
||||
framework: feign-scenario
|
||||
environment:
|
||||
dependencies:
|
||||
|
|
@ -0,0 +1,141 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
~
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<groupId>org.apache.skywalking.apm.testcase</groupId>
|
||||
<artifactId>feign-scenario</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<compiler.version>1.8</compiler.version>
|
||||
|
||||
<test.framework.version>9.0.0</test.framework.version>
|
||||
<spring-boot-version>2.1.6.RELEASE</spring-boot-version>
|
||||
<gson.version>2.6.2</gson.version>
|
||||
</properties>
|
||||
|
||||
<name>skywalking-feign-scenario</name>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>${spring-boot-version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-log4j2</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>jul-to-slf4j</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.openfeign</groupId>
|
||||
<artifactId>feign-core</artifactId>
|
||||
<version>${test.framework.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.openfeign</groupId>
|
||||
<artifactId>feign-gson</artifactId>
|
||||
<version>${test.framework.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>${gson.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>feign-scenario</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>1.5.9.RELEASE</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>${compiler.version}</source>
|
||||
<target>${compiler.version}</target>
|
||||
<encoding>${project.build.sourceEncoding}</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>assemble</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<descriptor>src/main/assembly/assembly.xml</descriptor>
|
||||
</descriptors>
|
||||
<outputDirectory>./target/</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
~
|
||||
-->
|
||||
<assembly
|
||||
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
|
||||
<formats>
|
||||
<format>zip</format>
|
||||
</formats>
|
||||
|
||||
<fileSets>
|
||||
<fileSet>
|
||||
<directory>./bin</directory>
|
||||
<fileMode>0775</fileMode>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
|
||||
<files>
|
||||
<file>
|
||||
<source>${project.build.directory}/feign-scenario.jar</source>
|
||||
<outputDirectory>./libs</outputDirectory>
|
||||
<fileMode>0775</fileMode>
|
||||
</file>
|
||||
</files>
|
||||
</assembly>
|
||||
|
|
@ -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 org.apache.skywalking.apm.testcase.feign;
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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 org.apache.skywalking.apm.testcase.feign.controller;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.skywalking.apm.testcase.feign.entity.User;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/case")
|
||||
public class CaseController {
|
||||
|
||||
private Logger logger = LogManager.getLogger(CaseController.class);
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping("/healthCheck")
|
||||
public String healthcheck() {
|
||||
return "Success";
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping("/feign-scenario")
|
||||
public String feignCase() {
|
||||
RestRequest request = RestRequest.connect();
|
||||
request.createUser(1, "test");
|
||||
User user = request.getById(1);
|
||||
logger.info("find Id{} user. User name is {} ", user.getId(), user.getUserName());
|
||||
request.updateUser(1, "testA");
|
||||
request.deleteUser(1);
|
||||
return "success";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* 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.feign.controller;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import org.apache.skywalking.apm.testcase.feign.entity.User;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
@Controller
|
||||
public class RestController {
|
||||
|
||||
private static final Map<Integer, User> users = new ConcurrentHashMap<>();
|
||||
|
||||
@GetMapping(value = "/get/{id}")
|
||||
@ResponseBody
|
||||
private ResponseEntity<User> getUser(@PathVariable("id") int id) throws InterruptedException {
|
||||
User currentUser = users.get(id);
|
||||
return ResponseEntity.ok(currentUser);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/create/")
|
||||
@ResponseBody
|
||||
public ResponseEntity<Void> createUser(@RequestBody User user,
|
||||
UriComponentsBuilder ucBuilder) throws InterruptedException {
|
||||
users.put(user.getId(), user);
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setLocation(ucBuilder.path("/user/{id}").buildAndExpand(user.getId()).toUri());
|
||||
return new ResponseEntity<Void>(headers, HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping(value = "/update/{id}")
|
||||
@ResponseBody
|
||||
public ResponseEntity<User> updateUser(@PathVariable("id") int id,
|
||||
@RequestBody User user) throws InterruptedException {
|
||||
User currentUser = new User(id, user.getUserName());
|
||||
return ResponseEntity.ok(currentUser);
|
||||
}
|
||||
|
||||
@DeleteMapping(value = "/delete/{id}")
|
||||
@ResponseBody
|
||||
public ResponseEntity<User> deleteUser(@PathVariable("id") int id) throws InterruptedException {
|
||||
User currentUser = users.get(id);
|
||||
if (currentUser == null) {
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
users.remove(id);
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
}
|
||||
|
|
@ -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.feign.controller;
|
||||
|
||||
import feign.Body;
|
||||
import feign.Feign;
|
||||
import feign.Headers;
|
||||
import feign.Logger;
|
||||
import feign.Param;
|
||||
import feign.RequestLine;
|
||||
import feign.codec.Decoder;
|
||||
import feign.gson.GsonDecoder;
|
||||
import org.apache.skywalking.apm.testcase.feign.entity.User;
|
||||
|
||||
public interface RestRequest {
|
||||
|
||||
@RequestLine("GET /get/{id}")
|
||||
User getById(@Param("id") int id);
|
||||
|
||||
@RequestLine("POST /create/")
|
||||
@Headers("Content-Type: application/json")
|
||||
@Body("%7B\"id\": \"{id}\", \"userName\": \"{userName}\"%7D")
|
||||
void createUser(@Param("id") int id, @Param("userName") String userName);
|
||||
|
||||
@RequestLine("PUT /update/{id}")
|
||||
@Headers("Content-Type: application/json")
|
||||
@Body("%7B\"id\": \"{id}\", \"userName\": \"{userName}\"%7D")
|
||||
User updateUser(@Param("id") int id, @Param("userName") String userName);
|
||||
|
||||
@RequestLine("DELETE /delete/{id}")
|
||||
void deleteUser(@Param("id") int id);
|
||||
|
||||
static RestRequest connect() {
|
||||
Decoder decoder = new GsonDecoder();
|
||||
return Feign.builder()
|
||||
.decoder(decoder)
|
||||
.logger(new Logger.ErrorLogger())
|
||||
.logLevel(Logger.Level.BASIC)
|
||||
.target(RestRequest.class, "http://localhost:8080/feign-scenario");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* 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.feign.entity;
|
||||
|
||||
public class User {
|
||||
|
||||
private int id;
|
||||
private String userName;
|
||||
|
||||
public User(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public User(int id, String userName) {
|
||||
this.id = id;
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public User() {
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
|
|
@ -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: /feign-scenario
|
||||
logging:
|
||||
config: classpath:log4j2.xml
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
~
|
||||
-->
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="Console" target="SYSTEM_ERR">
|
||||
<PatternLayout charset="UTF-8" pattern="[%d{yyyy-MM-dd HH:mm:ss:SSS}] [%p] - %l - %m%n"/>
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Root level="WARN">
|
||||
<AppenderRef ref="Console"/>
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
|
|
@ -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
|
||||
# "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.
|
||||
9.0.0
|
||||
9.1.0
|
||||
9.2.0
|
||||
9.3.0
|
||||
9.3.1
|
||||
9.4.0
|
||||
9.5.0
|
||||
9.5.1
|
||||
Loading…
Reference in New Issue