Firstsawyou commented on a change in pull request #3955:
URL: https://github.com/apache/apisix/pull/3955#discussion_r605453298



##########
File path: docs/zh/latest/plugins/traffic-split.md
##########
@@ -47,7 +47,7 @@ traffic-split 插件使用户可以逐步引导各个上游之间的流量百分
 | rules.weighted_upstreams       | array[object] | 可选   |        |        | 
上游配置规则列表。 |
 | weighted_upstreams.upstream_id | string / integer | 可选   |        |        | 
通过上游 id 绑定对应上游。 |
 | weighted_upstreams.upstream    | object | 可选   |        |        | 上游配置信息。 |
-| upstream.type                  | enum   | 可选   |   roundrobin |  
[roundrobin, chash]      | roundrobin 支持权重的负载,chash 一致性哈希,两者是二选一的(目前只支持 
`roundrobin`)。 |
+| upstream.type                  | enum   | 可选   |   roundrobin |  
[roundrobin, chash]      | roundrobin 支持权重的负载,chash 一致性哈希,两者是二选一。 |

Review comment:
       Updated.

##########
File path: t/plugin/traffic-split2.t
##########
@@ -311,3 +311,93 @@ host: localhost
 x-real-ip: 127.0.0.1
 --- no_error_log
 [error]
+
+
+
+=== TEST 10: the upstream.type is `chash` and `key` is header
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            local code, body = t('/apisix/admin/routes/1',
+                ngx.HTTP_PATCH,
+                [=[{
+                    "uri": "/server_port",
+                    "plugins": {
+                        "traffic-split": {
+                            "rules": [
+                                {
+                                    "weighted_upstreams": [
+                                        {
+                                            "upstream": {
+                                                "name": "chash_test",
+                                                "type": "chash",
+                                                "hash_on": "header",
+                                                "key": "custom_header",
+                                                "nodes": {
+                                                    "127.0.0.1:1981":1,
+                                                    "127.0.0.1:1982":1
+                                                }
+                                            },
+                                            "weight": 1
+                                        }
+                                    ]
+                                }
+                            ]
+                        }
+                    },
+                    "upstream": {
+                            "type": "roundrobin",
+                            "nodes": {
+                                "127.0.0.1:1980": 1
+                            }
+                    }
+                }]=]
+            )
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.say(body)
+        }
+    }
+--- request
+GET /t
+--- response_body
+passed
+--- no_error_log

Review comment:
       Updated.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to