From e2679d13e94161da8a6452fe47d6f6dd36032d7a Mon Sep 17 00:00:00 2001 From: Haotian Zhang <928016560@qq.com> Date: Wed, 27 Jul 2022 17:28:36 +0800 Subject: [PATCH] release:release 1.7.0-Hoxton.SR12. (#472) --- pom.xml | 2 +- spring-cloud-tencent-dependencies/pom.xml | 4 +- .../README-zh.md | 82 ++++++++++------ .../README.md | 97 ++++++++++++------- .../rule/StainingRuleManagerTest.java | 9 +- 5 files changed, 119 insertions(+), 75 deletions(-) diff --git a/pom.xml b/pom.xml index 30d94f425..1a13527fd 100644 --- a/pom.xml +++ b/pom.xml @@ -88,7 +88,7 @@ - 1.7.0-Hoxton.SR12-SNAPSHOT + 1.7.0-Hoxton.SR12 Hoxton.SR12 diff --git a/spring-cloud-tencent-dependencies/pom.xml b/spring-cloud-tencent-dependencies/pom.xml index a5950ba7c..11562f09f 100644 --- a/spring-cloud-tencent-dependencies/pom.xml +++ b/spring-cloud-tencent-dependencies/pom.xml @@ -70,8 +70,8 @@ - 1.7.0-Hoxton.SR12-SNAPSHOT - 1.7.2-SNAPSHOT + 1.7.0-Hoxton.SR12 + 1.7.2 1.2.11 4.5.1 1.12.10 diff --git a/spring-cloud-tencent-examples/polaris-router-featureenv-example/README-zh.md b/spring-cloud-tencent-examples/polaris-router-featureenv-example/README-zh.md index be085e321..85a17f4f0 100644 --- a/spring-cloud-tencent-examples/polaris-router-featureenv-example/README-zh.md +++ b/spring-cloud-tencent-examples/polaris-router-featureenv-example/README-zh.md @@ -7,6 +7,7 @@ 如上图所示,一共有三个环境: + 1. 基线环境,包含 FrontService、MiddleService、BackendService 2. feature1 环境,包含 MiddleService、BackendService 3. feature2 环境,包含 FrontService、BackendService @@ -14,11 +15,11 @@ 并且在入口处,部署网关服务。 三条请求链路: + 1. 基线环境链路,Gateway -> FrontService(基线) -> MiddleService(基线) -> BackendService(基线) 2. feature1 环境链路,Gateway -> FrontService(基线) -> MiddleService(feature1) -> BackendService(feature1) 3. feature2 环境链路,Gateway -> FrontService(feature2) -> MiddleService(基线) -> BackendService(feature2) - ## 二、运行样例 无需任何代码变更,直接启动 base、feature1、feature2、featureenv-gateway 下所有应用即可。 @@ -34,10 +35,13 @@ ### 方式一:客户端打标 #### 基线环境链路 + ```` curl http://127.0.0.1:9999/featureenv-front-example/router/rest ```` + 响应结果(base 表示基线环境) + ```` featureenv-front-example[base] -> featureenv-middle-example[base] -> featureenv-backend-example[base] ```` @@ -49,7 +53,9 @@ featureenv-front-example[base] -> featureenv-middle-example[base] -> featureenv- ```` curl -H'X-Polaris-Metadata-Transitive-featureenv:feature1' http://127.0.0.1:9999/featureenv-front-example/router/rest ```` + 响应结果 + ```` featureenv-front-example[base] -> featureenv-middle-example[feature1] -> featureenv-backend-example[feature1] ```` @@ -61,7 +67,9 @@ featureenv-front-example[base] -> featureenv-middle-example[feature1] -> feature ```` curl -H'X-Polaris-Metadata-Transitive-featureenv:feature2' http://127.0.0.1:9999/featureenv-front-example/router/rest ```` + 响应结果 + ```` featureenv-front-example[feature2] -> featureenv-middle-example[base] -> featureenv-backend-example[feature2] ```` @@ -69,10 +77,11 @@ featureenv-front-example[feature2] -> featureenv-middle-example[base] -> feature ### 方式二:网关流量染色 模拟一种实际的场景,假设客户端请求有一个 uid 请求参数,期望: + 1. uid=1000 的请求打到 feature1 环境 2. uid=2000 的请求打到 feature2 环境 3. 其它 uid 的请求打到基线环境 - + **配置染色规则** 配置地址:http://14.116.241.63:8080/#/filegroup-detail?group=featureenv-gateway&namespace=default @@ -81,48 +90,55 @@ featureenv-front-example[feature2] -> featureenv-middle-example[base] -> feature ````json { - "rules":[ + "rules": [ + { + "conditions": [ { - "conditions":[ - { - "key":"${http.query.uid}", - "values":["1000"], - "operation":"EQUAL" - } - ], - "labels":[ - { - "key":"featureenv", - "value":"feature1" - } - ] - }, + "key": "${http.query.uid}", + "values": [ + "1000" + ], + "operation": "EQUALS" + } + ], + "labels": [ + { + "key": "featureenv", + "value": "feature1" + } + ] + }, + { + "conditions": [ { - "conditions":[ - { - "key":"${http.query.uid}", - "values":["2000"], - "operation":"EQUAL" - } - ], - "labels":[ - { - "key":"featureenv", - "value":"feature2" - } - ] + "key": "${http.query.uid}", + "values": [ + "2000" + ], + "operation": "EQUALS" } - ] + ], + "labels": [ + { + "key": "featureenv", + "value": "feature2" + } + ] + } + ] } ```` 填写完后发布配置即可。 #### 基线环境链路 + ```` curl http://127.0.0.1:9999/featureenv-front-example/router/rest?uid=3000 ```` + 响应结果(base 表示基线环境) + ```` featureenv-front-example[base] -> featureenv-middle-example[base] -> featureenv-backend-example[base] ```` @@ -134,7 +150,9 @@ featureenv-front-example[base] -> featureenv-middle-example[base] -> featureenv- ```` curl http://127.0.0.1:9999/featureenv-front-example/router/rest?uid=1000 ```` + 响应结果 + ```` featureenv-front-example[base] -> featureenv-middle-example[feature1] -> featureenv-backend-example[feature1] ```` @@ -146,7 +164,9 @@ featureenv-front-example[base] -> featureenv-middle-example[feature1] -> feature ```` curl http://127.0.0.1:9999/featureenv-front-example/router/rest?uid=2000 ```` + 响应结果 + ```` featureenv-front-example[feature2] -> featureenv-middle-example[base] -> featureenv-backend-example[feature2] ```` diff --git a/spring-cloud-tencent-examples/polaris-router-featureenv-example/README.md b/spring-cloud-tencent-examples/polaris-router-featureenv-example/README.md index acc3ad194..e0853aef2 100644 --- a/spring-cloud-tencent-examples/polaris-router-featureenv-example/README.md +++ b/spring-cloud-tencent-examples/polaris-router-featureenv-example/README.md @@ -7,6 +7,7 @@ English | [简体中文](./README-zh.md) multi-feature environment structure As shown in the figure above, there are three environments. + 1. `baseline` environment, including `FrontService`, `MiddleService`, `BackendService` 2. `feature1` environment, including `MiddleService`, `BackendService` 3. `feature2` environment, including `FrontService`, `BackendService` @@ -14,30 +15,38 @@ As shown in the figure above, there are three environments. And at the entrance, deploy the `gateway` service. Three request links. -1. `baseline` environment link, `Gateway` -> `FrontService`(baseline) -> `MiddleService`(baseline) -> `BackendService`(baseline) -2. `feature1` environment link, `Gateway` -> `FrontService`(baseline) -> `MiddleService`(feature1) -> `BackendService`(feature1) -3. `feature2` environment link, `Gateway` -> `FrontService`(feature2) -> `MiddleService`(baseline) -> `BackendService`(feature2) +1. `baseline` environment link, `Gateway` -> `FrontService`(baseline) -> `MiddleService`(baseline) -> `BackendService`( + baseline) +2. `feature1` environment link, `Gateway` -> `FrontService`(baseline) -> `MiddleService`(feature1) -> `BackendService`( + feature1) +3. `feature2` environment link, `Gateway` -> `FrontService`(feature2) -> `MiddleService`(baseline) -> `BackendService`( + feature2) ## II. Running -Without any code changes, just start all the applications under `base`, `feature1`, `feature2`, `featureenv-gateway` directly. +Without any code changes, just start all the applications under `base`, `feature1`, `feature2`, `featureenv-gateway` +directly. -By default, the applications point to the official Polaris experience environment, and you can directly view the service registration data at the experience site after a successful launch. +By default, the applications point to the official Polaris experience environment, and you can directly view the service +registration data at the experience site after a successful launch. - Console address: http://14.116.241.63:8080/ - - Account:polaris - - Password: polaris + - Account:polaris + - Password: polaris ## III. Testing ### Mode 1: Client Request With `featureenv` Label #### `baseline` environment link + ```` curl http://127.0.0.1:9999/featureenv-front-example/router/rest ```` + Response results (base indicates baseline environment) + ```` featureenv-front-example[base] -> featureenv-middle-example[base] -> featureenv-backend-example[base] ```` @@ -49,7 +58,9 @@ Specify the feature environment via the `X-Polaris-Metadata-Transitive-featureen ```` curl -H'X-Polaris-Metadata-Transitive-featureenv:feature1' http://127.0.0.1:9999/featureenv-front-example/router/rest ```` + Response results + ```` featureenv-front-example[base] -> featureenv-middle-example[feature1] -> featureenv-backend-example[feature1] ```` @@ -61,7 +72,9 @@ Specify the feature environment via the `X-Polaris-Metadata-Transitive-featureen ```` curl -H'X-Polaris-Metadata-Transitive-featureenv:feature2' http://127.0.0.1:9999/featureenv-front-example/router/rest ```` + Response results + ```` featureenv-front-example[feature2] -> featureenv-middle-example[base] -> featureenv-backend-example[feature2] ```` @@ -69,6 +82,7 @@ featureenv-front-example[feature2] -> featureenv-middle-example[base] -> feature ### Mode 2: Gateway traffic staining Simulate a real-world scenario, assuming that the client request has a uid request parameter and expects: + 1. `uid=1000` requests hit the `feature1` environment 2. `uid=2000` requests hit the `feature2` environment 3. requests with other uid hit the `baseline` environment @@ -81,48 +95,55 @@ Modify the `rule/staining.json` configuration file and fill in the following rul ````json { - "rules":[ + "rules": [ + { + "conditions": [ { - "conditions":[ - { - "key":"${http.query.uid}", - "values":["1000"], - "operation":"EQUAL" - } - ], - "labels":[ - { - "key":"featureenv", - "value":"feature1" - } - ] - }, + "key": "${http.query.uid}", + "values": [ + "1000" + ], + "operation": "EQUALS" + } + ], + "labels": [ { - "conditions":[ - { - "key":"${http.query.uid}", - "values":["2000"], - "operation":"EQUAL" - } - ], - "labels":[ - { - "key":"featureenv", - "value":"feature2" - } - ] + "key": "featureenv", + "value": "feature1" } - ] + ] + }, + { + "conditions": [ + { + "key": "${http.query.uid}", + "values": [ + "2000" + ], + "operation": "EQUALS" + } + ], + "labels": [ + { + "key": "featureenv", + "value": "feature2" + } + ] + } + ] } ```` Just fill out and publish the configuration. #### `baseline` Environment Link + ```` curl http://127.0.0.1:9999/featureenv-front-example/router/rest?uid=3000 ```` + Response results (base indicates baseline environment) + ```` featureenv-front-example[base] -> featureenv-middle-example[base] -> featureenv-backend-example[base] ```` @@ -134,7 +155,9 @@ Specify the feature environment via the `X-Polaris-Metadata-Transitive-featureen ```` curl http://127.0.0.1:9999/featureenv-front-example/router/rest?uid=1000 ```` + Response results + ```` featureenv-front-example[base] -> featureenv-middle-example[feature1] -> featureenv-backend-example[feature1] ```` @@ -146,7 +169,9 @@ Specify the feature environment via the `X-Polaris-Metadata-Transitive-featureen ```` curl http://127.0.0.1:9999/featureenv-front-example/router/rest?uid=2000 ```` + Response results + ```` featureenv-front-example[feature2] -> featureenv-middle-example[base] -> featureenv-backend-example[feature2] ```` diff --git a/spring-cloud-tencent-plugin-starters/spring-cloud-tencent-gateway-plugin/src/test/java/com/tencent/cloud/plugin/gateway/staining/rule/StainingRuleManagerTest.java b/spring-cloud-tencent-plugin-starters/spring-cloud-tencent-gateway-plugin/src/test/java/com/tencent/cloud/plugin/gateway/staining/rule/StainingRuleManagerTest.java index 1ac88e3c8..c63dcdb9c 100644 --- a/spring-cloud-tencent-plugin-starters/spring-cloud-tencent-gateway-plugin/src/test/java/com/tencent/cloud/plugin/gateway/staining/rule/StainingRuleManagerTest.java +++ b/spring-cloud-tencent-plugin-starters/spring-cloud-tencent-gateway-plugin/src/test/java/com/tencent/cloud/plugin/gateway/staining/rule/StainingRuleManagerTest.java @@ -37,12 +37,11 @@ import static org.mockito.Mockito.when; @RunWith(MockitoJUnitRunner.class) public class StainingRuleManagerTest { - @Mock - private ConfigFileService configFileService; - private final String testNamespace = "testNamespace"; private final String testGroup = "testGroup"; private final String testFileName = "rule.json"; + @Mock + private ConfigFileService configFileService; @Test public void testNormalRule() { @@ -59,7 +58,7 @@ public class StainingRuleManagerTest { + " {\n" + " \"key\":\"${http.query.uid}\",\n" + " \"values\":[\"1000\"],\n" - + " \"operation\":\"EQUAL\"\n" + + " \"operation\":\"EQUALS\"\n" + " }\n" + " ],\n" + " \"labels\":[\n" @@ -99,7 +98,7 @@ public class StainingRuleManagerTest { + " {\n" + " \"key\":\"${http.query.uid}\",\n" + " \"values\":[\"1000\"],\n" - + " \"operation\":\"EQUAL\"\n" + + " \"operation\":\"EQUALS\"\n" + " }\n" + " ],\n" + " \"labels\":[\n"