This is an automated email from the ASF dual-hosted git repository.
spacewander pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git
The following commit(s) were added to refs/heads/master by this push:
new ea7dda050 fix(traffic-split): the default timeout doesn't match the
one in Nginx (#7277)
ea7dda050 is described below
commit ea7dda050720f42208342a5e2ae92c9ac3014278
Author: 罗泽轩 <[email protected]>
AuthorDate: Mon Jun 20 14:13:56 2022 +0800
fix(traffic-split): the default timeout doesn't match the one in Nginx
(#7277)
Signed-off-by: spacewander <[email protected]>
---
apisix/plugins/traffic-split.lua | 6 +---
t/plugin/traffic-split5.t | 59 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 60 insertions(+), 5 deletions(-)
diff --git a/apisix/plugins/traffic-split.lua b/apisix/plugins/traffic-split.lua
index 9ba0997f6..38e272b7b 100644
--- a/apisix/plugins/traffic-split.lua
+++ b/apisix/plugins/traffic-split.lua
@@ -172,11 +172,7 @@ local function set_upstream(upstream_info, ctx)
upstream_host = upstream_info.upstream_host,
key = upstream_info.key,
nodes = new_nodes,
- timeout = {
- send = upstream_info.timeout and upstream_info.timeout.send or 15,
- read = upstream_info.timeout and upstream_info.timeout.read or 15,
- connect = upstream_info.timeout and upstream_info.timeout.connect
or 15
- }
+ timeout = upstream_info.timeout,
}
local ok, err = upstream.check_schema(up_conf)
diff --git a/t/plugin/traffic-split5.t b/t/plugin/traffic-split5.t
index 5e2b80ac3..1de76cea5 100644
--- a/t/plugin/traffic-split5.t
+++ b/t/plugin/traffic-split5.t
@@ -405,3 +405,62 @@ passed
}
--- response_body
1970, 1970, 1971, 1972
+
+
+
+=== TEST 7: set up traffic-split rule
+--- config
+ location /t {
+ content_by_lua_block {
+ local json = require("toolkit.json")
+ local t = require("lib.test_admin").test
+ local data = {
+ uri = "/server_port",
+ plugins = {
+ ["traffic-split"] = {
+ rules = { {
+ match = { {
+ vars = { { "arg_name", "==", "jack" } }
+ } },
+ weighted_upstreams = { {
+ upstream = {
+ type = "roundrobin",
+ nodes = {
+ ["127.0.0.1:1979"] = 1
+ },
+ },
+ } }
+ } }
+ }
+ },
+ upstream = {
+ type = "roundrobin",
+ nodes = {
+ ["127.0.0.1:1980"] = 1
+ }
+ }
+ }
+ local code, body = t('/apisix/admin/routes/1',
+ ngx.HTTP_PUT,
+ json.encode(data)
+ )
+ if code >= 300 then
+ ngx.status = code
+ end
+ ngx.say(body)
+ }
+ }
+--- response_body
+passed
+
+
+
+=== TEST 8: hit and check default timeout
+--- http_config
+proxy_connect_timeout 12345s;
+--- request
+GET /server_port?name=jack
+--- log_level: debug
+--- error_log eval
+qr/event timer add: \d+: 12345000:\d+/
+--- error_code: 502