Skip to content

Commit

Permalink
Add integration tests for xDS flow control
Browse files Browse the repository at this point in the history
Signed-off-by: hanbingleixue <[email protected]>
  • Loading branch information
hanbingleixue committed Jan 17, 2025
1 parent 91e61f3 commit 3b26d06
Show file tree
Hide file tree
Showing 23 changed files with 1,385 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ runs:
cp -r sermant-integration-tests/xds-service-test/product/sermant-agent-*/agent sermant-integration-tests/xds-service-test/product/spring-client/
cp -r sermant-integration-tests/xds-service-test/product/sermant-agent-*/agent sermant-integration-tests/xds-service-test/product/spring-cloud-client/
cp -r sermant-integration-tests/xds-service-test/product/sermant-agent-*/agent sermant-integration-tests/xds-service-test/product/spring-server/
mvn package -Dspringboot.version=${{ matrix.springBootVersion }} -Dsnakeyaml.version=${{ matrix.snakeyamlVersion }} -Dspringcloud.version=${{ matrix.springCloudVersion }} -Dhttpclient.version=${{ matrix.httpClientVersion }} -Dokhttp2.version=${{ matrix.okHttp2Version }} -Dhttpclient.async.version=${{ matrix.httpAsyncClientVersion }} -Dokhttp3.version=${{ matrix.okHttp3Version }} -DskipTests -pl spring-client,spring-cloud-client,spring-server -Pxds-router-lb --file \
mvn package -Dspringboot.version=${{ matrix.springBootVersion }} -Dsnakeyaml.version=${{ matrix.snakeyamlVersion }} -Dspringcloud.version=${{ matrix.springCloudVersion }} -Dhttpclient.version=${{ matrix.httpClientVersion }} -Dokhttp2.version=${{ matrix.okHttp2Version }} -Dhttpclient.async.version=${{ matrix.httpAsyncClientVersion }} -Dokhttp3.version=${{ matrix.okHttp3Version }} -DskipTests -pl spring-common,spring-client,spring-cloud-client,spring-server -Pxds-router-lb --file \
sermant-integration-tests/xds-service-test/pom.xml
- name: build docker image
shell: bash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ runs:
run: |
cp -r sermant-integration-tests/xds-service-test/product/sermant-agent-*/agent sermant-integration-tests/xds-service-test/product/spring-client/
cp -r sermant-integration-tests/xds-service-test/product/sermant-agent-*/agent sermant-integration-tests/xds-service-test/product/spring-server/
mvn package -DskipTests -pl spring-client,spring-server -Pxds-discovery --file \
mvn package -DskipTests -pl spring-common,spring-client,spring-server -Pxds-discovery --file \
sermant-integration-tests/xds-service-test/pom.xml
- name: build docker image
shell: bash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ runs:
run: |
cp -r sermant-integration-tests/xds-service-test/product/sermant-agent-*/agent sermant-integration-tests/xds-service-test/product/spring-client/
cp -r sermant-integration-tests/xds-service-test/product/sermant-agent-*/agent sermant-integration-tests/xds-service-test/product/spring-server/
mvn package -DskipTests -pl spring-client,spring-server -Pxds-discovery --file \
mvn package -DskipTests -pl spring-common,spring-client,spring-server -Pxds-discovery --file \
sermant-integration-tests/xds-service-test/pom.xml
- name: build docker image
shell: bash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ runs:
run: |
cp -r sermant-integration-tests/xds-service-test/product/sermant-agent-*/agent sermant-integration-tests/xds-service-test/product/spring-client/
cp -r sermant-integration-tests/xds-service-test/product/sermant-agent-*/agent sermant-integration-tests/xds-service-test/product/spring-server/
mvn package -DskipTests -pl spring-client,spring-server -Pxds-discovery --file \
mvn package -DskipTests -pl spring-common,spring-client,spring-server -Pxds-discovery --file \
sermant-integration-tests/xds-service-test/pom.xml
- name: build docker image
shell: bash
Expand Down
11 changes: 11 additions & 0 deletions sermant-integration-tests/xds-service-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,24 @@
<profile>
<id>xds-discovery</id>
<modules>
<module>spring-common</module>
<module>spring-client</module>
<module>spring-server</module>
</modules>
</profile>
<profile>
<id>xds-router-lb</id>
<modules>
<module>spring-common</module>
<module>spring-client</module>
<module>spring-server</module>
<module>spring-cloud-client</module>
</modules>
</profile>
<profile>
<id>xds-flowcontrol</id>
<modules>
<module>spring-common</module>
<module>spring-client</module>
<module>spring-server</module>
<module>spring-cloud-client</module>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<spring.common.version>1.0.0</spring.common.version>
</properties>

<dependencies>
Expand All @@ -26,6 +27,11 @@
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
</dependency>
<dependency>
<groupId>io.sermant.integration</groupId>
<artifactId>spring-common</artifactId>
<version>${spring.common.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpasyncclient</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* Copyright (C) 2025-2025 Sermant Authors. 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 io.sermant.demo.spring.client.flowcontrol;

import io.sermant.demo.spring.common.HttpClientType;
import io.sermant.demo.spring.client.util.HttpUtil;
import io.sermant.demo.spring.common.Constants;
import io.sermant.demo.spring.common.entity.Result;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
* flow control
*
* @author zhp
* @since 2025-01-13
**/
@RequestMapping("flowControl")
@RestController
public class FlowControlController {
/**
* Test the flow control functionality of the HttpClient client
*
* @param host the service address of upstream service
* @param path request path
* @return result
*/
@GetMapping("testHttpClient")
public Result testHttpClient(String host, String path, String version) {
Map<String, String> headers = new HashMap<>();
headers.put("version", version);
return HttpUtil.sendGetRequest(Constants.HTTP_PROTOCOL + host + Constants.SLASH + path,
HttpClientType.HTTP_CLIENT, headers);
}

/**
* Test the flow control functionality of the OkHttp2
*
* @param host the service address of upstream service
* @param path request path
* @return result
*/
@GetMapping("testOkHttp2")
public Result testOkHttp2(String host, String path, String version) {
Map<String, String> headers = new HashMap<>();
headers.put("version", version);
return HttpUtil.sendGetRequest(Constants.HTTP_PROTOCOL + host + Constants.SLASH + path,
HttpClientType.OK_HTTP2, headers);
}

/**
* Test the flow control functionality of the HttpUrlConnection
*
* @param host the service address of upstream service
* @param path request path
* @return result
*/
@GetMapping("testHttpUrlConnection")
public Result testHttpUrlConnection(String host, String path, String version) {
Map<String, String> headers = new HashMap<>();
headers.put("version", version);
return HttpUtil.sendGetRequest(Constants.HTTP_PROTOCOL + host + Constants.SLASH + path,
HttpClientType.HTTP_URL_CONNECTION, headers);
}
}
Loading

0 comments on commit 3b26d06

Please sign in to comment.