Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Traffic label transparent transmission plugin integration test demo: sofa rpc demo, servicecomb demo #1339

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sermant-integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@
<module>agentcore-test</module>
<module>dubbo-test</module>
<module>spring-test</module>
<module>tag-transmission-test</module>
</modules>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<parent>
<artifactId>tag-transmission-test</artifactId>
<groupId>com.huaweicloud.sermant.tagtransmission</groupId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>okhttp-demo</artifactId>

<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.squareup.okhttp</groupId>
<artifactId>okhttp</artifactId>
<version>${okhttpv2.version}</version>
</dependency>
</dependencies>

<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (C) 2023-2023 Huawei Technologies Co., Ltd. All rights reserved.
*
* Licensed 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 com.huaweicloud.demo.tagtransmission.okhttp;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
* springboot 启动类
*
* @author daizhenyu
* @since 2023-09-07
**/
@SpringBootApplication
public class OkHttpApplication {
/**
* 启动类
*
* @param args 进程启动入参
*/
public static void main(String[] args) {
SpringApplication.run(OkHttpApplication.class, args);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Copyright (C) 2023-2023 Huawei Technologies Co., Ltd. All rights reserved.
*
* Licensed 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 com.huaweicloud.demo.tagtransmission.okhttp.controller;

import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

/**
* controller,使用okhttp调用http 服务端
*
* @author daizhenyu
* @since 2023-10-14
**/
@RestController
@RequestMapping(value = "okHttp")
public class OkHttpController {
@Value("${common.server.url}")
private String commonServerUrl;

/**
* 验证okhttp透传流量标签
*
* @return 流量标签值
* @throws IOException
*/
@RequestMapping(value = "testOkHttp", method = RequestMethod.GET, produces = MediaType.TEXT_PLAIN_VALUE)
public String testOkHttp() throws IOException {
return doOkHttpGet(commonServerUrl);
}

private String doOkHttpGet(String url) throws IOException {
OkHttpClient client = new OkHttpClient();

// 创建 HTTP 请求
Request request = new Request.Builder()
.url(url)
.build();

// 执行请求
Response response = client.newCall(request).execute();
String responseContext = response.body().string();
response.body().close();

return responseContext;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
common.server.url=http://127.0.0.1:9040/common/httpServer
server.port=9055
179 changes: 179 additions & 0 deletions sermant-integration-tests/tag-transmission-test/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.15</version>
<relativePath/>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>tag-transmission-test</artifactId>
<groupId>com.huaweicloud.sermant.tagtransmission</groupId>
<version>1.0.0</version>
<packaging>pom</packaging>

<properties>
<spring.boot.version>2.2.0.RELEASE</spring.boot.version>
<tag-transmission.version>1.0.0</tag-transmission.version>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<curator.version>5.0.0</curator.version>
<servicecomb.version>2.8.3</servicecomb.version>
<httpclient3x.version>3.1</httpclient3x.version>
<httpclient4x.version>4.5.13</httpclient4x.version>
<okhttpv2.version>2.7.5</okhttpv2.version>
<apache.dubbo.version>2.7.15</apache.dubbo.version>
<sofarpc.version>5.10.0</sofarpc.version>
<rocketmq-client.version>5.1.0</rocketmq-client.version>
<kafka-client.version>2.7.0</kafka-client.version>
<alibaba.dubbo.version>2.6.12</alibaba.dubbo.version>
<grpc.version>1.52.1</grpc.version>
<protobuf.version>3.21.7</protobuf.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.huaweicloud.sermant.tagtransmission</groupId>
<artifactId>rpc-api-demo</artifactId>
<version>${tag-transmission.version}</version>
</dependency>
<dependency>
<groupId>com.huaweicloud.sermant.tagtransmission</groupId>
<artifactId>tag-transmission-util-demo</artifactId>
<version>${tag-transmission.version}</version>
</dependency>
<dependency>
<groupId>com.huaweicloud.sermant.tagtransmission</groupId>
<artifactId>grpc-api-demo</artifactId>
<version>${tag-transmission.version}</version>
</dependency>
<dependency>
<groupId>com.huaweicloud.sermant.tagtransmission</groupId>
<artifactId>midware-common-demo</artifactId>
<version>${tag-transmission.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

<modules>
<module>httpserver-common-demo</module>
</modules>

<profiles>
<profile>
<id>alibaba-dubbo-test</id>
<modules>
<module>alibaba-dubbo-provider-demo</module>
<module>alibaba-dubbo-consumer-demo</module>
<module>rpc-api-demo</module>
<module>tag-transmission-util-demo</module>
</modules>
</profile>
<profile>
<id>apache-dubbo-test</id>
<modules>
<module>apache-dubbo-provider-demo</module>
<module>apache-dubbo-consumer-demo</module>
<module>rpc-api-demo</module>
<module>tag-transmission-util-demo</module>
</modules>
</profile>
<profile>
<id>sofarpc-test</id>
<modules>
<module>sofarpc-consumer-demo</module>
<module>sofarpc-provider-demo</module>
<module>rpc-api-demo</module>
<module>tag-transmission-util-demo</module>
</modules>
</profile>
<profile>
<id>servicecomb-test</id>
<modules>
<module>servicecomb-consumer-demo</module>
<module>servicecomb-provider-demo</module>
<module>rpc-api-demo</module>
<module>tag-transmission-util-demo</module>
</modules>
</profile>
<profile>
<id>grpc-test</id>
<modules>
<module>grpc-client-demo</module>
<module>grpc-server-demo</module>
<module>grpc-api-demo</module>
<module>tag-transmission-util-demo</module>
</modules>
</profile>
<profile>
<id>rocketmq-test</id>
<modules>
<module>rocketmq-consumer-demo</module>
<module>rocketmq-producer-demo</module>
<module>midware-common-demo</module>
<module>tag-transmission-util-demo</module>
</modules>
</profile>
<profile>
<id>kafka-test</id>
<modules>
<module>kafka-consumer-demo</module>
<module>kafka-producer-demo</module>
<module>midware-common-demo</module>
<module>tag-transmission-util-demo</module>
</modules>
</profile>
<profile>
<id>crossthread-test</id>
<modules>
<module>crossthread-demo</module>
<module>tag-transmission-util-demo</module>
</modules>
</profile>
<profile>
<id>httpclientv3-test</id>
<modules>
<module>httpclientv3-demo</module>
</modules>
</profile>
<profile>
<id>httpclientv4-test</id>
<modules>
<module>httpclientv4-demo</module>
</modules>
</profile>
<profile>
<id>okhttp-test</id>
<modules>
<module>okhttp-demo</module>
</modules>
</profile>
<profile>
<id>jdkhttp-jetty-test</id>
<modules>
<module>jdkhttp-demo</module>
<module>jetty-demo</module>
<module>tag-transmission-util-demo</module>
</modules>
</profile>
<profile>
<id>jdkhttp-tomcat-test</id>
<modules>
<module>jdkhttp-demo</module>
<module>tomcat-demo</module>
<module>tag-transmission-util-demo</module>
</modules>
</profile>
<profile>
<id>config-test</id>
<modules>
<module>tomcat-demo</module>
<module>tag-transmission-util-demo</module>
</modules>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<parent>
<groupId>com.huaweicloud.sermant.tagtransmission</groupId>
<artifactId>tag-transmission-test</artifactId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>servicecomb-consumer-demo</artifactId>

<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.servicecomb</groupId>
<artifactId>java-chassis-spring-boot-starter-servlet</artifactId>
<version>${servicecomb.version}</version>
</dependency>
<dependency>
<groupId>org.apache.servicecomb</groupId>
<artifactId>solution-basic</artifactId>
<version>${servicecomb.version}</version>
</dependency>
<dependency>
<groupId>org.apache.servicecomb</groupId>
<artifactId>registry-service-center</artifactId>
<version>${servicecomb.version}</version>
</dependency>
<dependency>
<groupId>org.apache.servicecomb</groupId>
<artifactId>servicestage-environment</artifactId>
<version>${servicecomb.version}</version>
</dependency>
<dependency>
<groupId>com.huaweicloud.sermant.tagtransmission</groupId>
<artifactId>rpc-api-demo</artifactId>
</dependency>
</dependencies>

<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Loading