Skip to content

Commit

Permalink
Merge pull request #83 from hanbingleixue/main
Browse files Browse the repository at this point in the history
Add configuration and code for xDS flow control validation demo
  • Loading branch information
lilai23 authored Jan 17, 2025
2 parents d12c1b6 + b26742d commit 622fa5d
Show file tree
Hide file tree
Showing 53 changed files with 61 additions and 1,101 deletions.
18 changes: 4 additions & 14 deletions .github/workflows/create_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,25 +186,15 @@ jobs:
asset_path: ${{ github.workspace }}/package/result/sermant-examples-first-plugin-demo-${{ env.version }}.tar.gz
asset_name: sermant-examples-first-plugin-demo-${{ env.version }}.tar.gz
asset_content_type: application/tar
- name: Upload Release xds-service-discovery-demo # xds-service-discovery-demo release包
id: upload-release-asset-xds-service-discovery
- name: Upload Release xds-demo # xds-demo release包
id: upload-release-asset-xds
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ github.workspace }}/package/result/sermant-examples-xds-service-discovery-demo-${{ env.version }}.tar.gz
asset_name: sermant-examples-xds-service-discovery-demo-${{ env.version }}.tar.gz
asset_content_type: application/tar
- name: Upload Release xds-router-demo # xds-router-demo release包
id: upload-release-asset-xds-router
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ github.workspace }}/package/result/sermant-examples-xds-router-demo-${{ env.version }}.tar.gz
asset_name: sermant-examples-xds-router-demo-${{ env.version }}.tar.gz
asset_path: ${{ github.workspace }}/package/result/sermant-examples-xds-demo-${{ env.version }}.tar.gz
asset_name: sermant-examples-xds-demo-${{ env.version }}.tar.gz
asset_content_type: application/tar
- name: Upload Release mq-gray-demo # rocketmq-gray-demo release包
id: upload-release-mq-gray
Expand Down
3 changes: 1 addition & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
<module>mq-consume-prohibition-demo</module>
<module>loadbalancer-demo</module>
<module>database-write-prohibition-demo</module>
<module>xds-service-discovery-demo</module>
<module>xds-router-demo</module>
<module>xds-demo</module>
<module>mq-gray-demo</module>
</modules>

Expand Down
10 changes: 3 additions & 7 deletions scripts/copy_jar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,14 @@ mkdir -p package/removal-demo
mkdir -p package/mq-consume-prohibition-demo
mkdir -p package/database-write-prohibition-demo
mkdir -p package/first-plugin-demo
mkdir -p package/xds-service-discovery-demo
mkdir -p package/xds-router-demo
mkdir -p package/xds-demo
mkdir -p package/mq-gray-demo

# 按照文件名模式将对应的jar文件复制到对应目录
# 创建首个插件
find . -type d -name "agent" -exec cp -rv {} package/first-plugin-demo/ \;
# xDS服务发现
cp -rv ./xds-service-discovery-demo/product package/xds-service-discovery-demo/
# xDS路由
cp -rv ./xds-router-demo/router-product package/xds-router-demo/
cp -rv ./xds-demo/product package/xds-demo/
# 动态配置
find . -type f -name "spring-provider.jar" -exec cp -v {} package/dynamic-demo/ \;
# 流控
Expand Down Expand Up @@ -82,8 +79,7 @@ find . -type f -name "rocketmq-gray-producer-demo.jar" -exec cp -v {} package/mq

# 打包
tar -czvf package/result/sermant-examples-first-plugin-demo-$*.tar.gz -C package/first-plugin-demo/ .
tar -czvf package/result/sermant-examples-xds-service-discovery-demo-$*.tar.gz -C package/xds-service-discovery-demo/ .
tar -czvf package/result/sermant-examples-xds-router-demo-$*.tar.gz -C package/xds-router-demo/ .
tar -czvf package/result/sermant-examples-xds-demo-$*.tar.gz -C package/xds-demo/ .
tar -czvf package/result/sermant-examples-dynamic-demo-$*.tar.gz -C package/dynamic-demo/ .
tar -czvf package/result/sermant-examples-flowcontrol-demo-$*.tar.gz -C package/flowcontrol-demo/ .
tar -czvf package/result/sermant-examples-grace-demo-$*.tar.gz -C package/grace-demo/ .
Expand Down
2 changes: 1 addition & 1 deletion xds-router-demo/pom.xml → xds-demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>xds-router-demo</artifactId>
<artifactId>xds-demo</artifactId>
<packaging>pom</packaging>

<modules>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,22 @@ spec:
containers:
- name: spring-client
image: spring-client:1.0.0
imagePullPolicy: IfNotPresent
imagePullPolicy: Never
ports:
- containerPort: 8080
env:
- name: agent_service_dynamic_config_enable
value: "false"
- name: agent_service_xds_service_enable
value: "true"
- name: xds_flow_control_config_enable
value: "true"
- name: ZOOKEEPER_ENABLED
value: "false"
- name: MYSQL_ENABLED
value: "false"
- name: JAVA_TOOL_OPTIONS
value: "-javaagent:/home/agent/sermant-agent.jar"
imagePullSecrets:
- name: default-secret
---
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: spring-server-virtualservice
spec:
hosts:
- spring-server
http:
- name: "v1-routes"
match:
- headers:
version:
exact: v1
uri:
exact: /router
ignoreUriCase: false
route:
- destination:
host: spring-server
subset: v1
port:
number: 8081
fault:
abort:
percentage:
value: 100
httpStatus: 400
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
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>xds-router-demo</artifactId>
<artifactId>xds-demo</artifactId>
<groupId>com.huaweicloud.sermant.examples</groupId>
<version>1.0.0</version>
</parent>
Expand Down Expand Up @@ -64,7 +64,7 @@
<configuration>
<mainClass>io.sermant.demo.xds.spring.client.SpringCloudClientApplication</mainClass>
<finalName>spring-client</finalName>
<outputDirectory>${pom.basedir}/../router-product/spring-client</outputDirectory>
<outputDirectory>${pom.basedir}/../product/spring-client</outputDirectory>
</configuration>
<executions>
<execution>
Expand All @@ -89,7 +89,7 @@
<configuration>
<filesets>
<fileset>
<directory>${pom.basedir}/../router-product/spring-client</directory>
<directory>${pom.basedir}/../product/spring-client</directory>
<includes>
<include>spring-client.jar</include>
</includes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@
import java.util.concurrent.TimeUnit;

/**
* SpringRouterController
* SpringController
*
* @author daizhenyu
* @since 2024-09-23
**/
@RequestMapping("router")
@RestController
public class SpringRouterController implements InitializingBean {
public class SpringClientController implements InitializingBean {
private static final String VERSION = "version";

private static final int SUCCEED_CODE = 200;
Expand Down Expand Up @@ -168,7 +168,7 @@ public String testHttpClientRouting(String host, String version) {
mockRealLogic();
return result;
} else {
return "";
return EntityUtils.toString(response.getEntity());
}
} catch (IOException e) {
return "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
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>xds-router-demo</artifactId>
<artifactId>xds-demo</artifactId>
<groupId>com.huaweicloud.sermant.examples</groupId>
<version>1.0.0</version>
</parent>
Expand Down Expand Up @@ -36,7 +36,7 @@
<configuration>
<mainClass>io.sermant.demo.xds.spring.server.SpringCloudServerApplication</mainClass>
<finalName>spring-server</finalName>
<outputDirectory>${pom.basedir}/../router-product/spring-server</outputDirectory>
<outputDirectory>${pom.basedir}/../product/spring-server</outputDirectory>
</configuration>
<executions>
<execution>
Expand All @@ -61,7 +61,7 @@
<configuration>
<filesets>
<fileset>
<directory>${pom.basedir}/../router-product/spring-server</directory>
<directory>${pom.basedir}/../product/spring-server</directory>
<includes>
<include>spring-server.jar</include>
</includes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
import java.net.UnknownHostException;

/**
* RouterServerController
* ServerController
*
* @author daizhenyu
* @since 2024-10-11
**/
@RestController
public class RouterServerController {
public class ServerController {
private static final int ITERATION_COUNT = 15000;

@Value("${SERVER_VERSION:v1}")
Expand Down
8 changes: 0 additions & 8 deletions xds-service-discovery-demo/config/bootstrap.properties

This file was deleted.

115 changes: 0 additions & 115 deletions xds-service-discovery-demo/config/config.properties

This file was deleted.

Loading

0 comments on commit 622fa5d

Please sign in to comment.