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 c46213a fix: route's timeout should not be overwrittern by service
(#5219)
c46213a is described below
commit c46213a6e2e579f59473a0145940bbe05a0aebfb
Author: oliver <[email protected]>
AuthorDate: Mon Oct 18 09:17:02 2021 +0800
fix: route's timeout should not be overwrittern by service (#5219)
---
apisix/plugin.lua | 4 +++
t/node/timeout-upstream.t | 67 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 71 insertions(+)
diff --git a/apisix/plugin.lua b/apisix/plugin.lua
index cee49bd..1e060cd 100644
--- a/apisix/plugin.lua
+++ b/apisix/plugin.lua
@@ -412,6 +412,10 @@ local function merge_service_route(service_conf,
route_conf)
new_conf.value.script = route_conf.value.script
end
+ if route_conf.value.timeout then
+ new_conf.value.timeout = route_conf.value.timeout
+ end
+
if route_conf.value.name then
new_conf.value.name = route_conf.value.name
else
diff --git a/t/node/timeout-upstream.t b/t/node/timeout-upstream.t
index c860559..a7dfb8b 100644
--- a/t/node/timeout-upstream.t
+++ b/t/node/timeout-upstream.t
@@ -128,3 +128,70 @@ GET /mysleep?seconds=1
qr/504 Gateway Time-out/
--- error_log
timed out) while reading response header from upstream
+
+
+
+=== TEST 5: set route inherit hosts from service
+--- config
+ location /t {
+ content_by_lua_block {
+ local t = require("lib.test_admin").test
+ local scode, sbody = t('/apisix/admin/services/1',
+ ngx.HTTP_PUT,
+ [[{
+ "desc":"test-service",
+ "hosts": ["foo.com"]
+ }]]
+ )
+
+ if scode >= 300 then
+ ngx.status = scode
+ end
+ ngx.say(sbody)
+
+ local rcode, rbody = t('/apisix/admin/routes/1',
+ ngx.HTTP_PUT,
+ [[{
+ "methods": ["GET"],
+ "service_id": "1",
+ "upstream": {
+ "nodes": {
+ "127.0.0.1:1980": 1
+ },
+ "type": "roundrobin",
+ "timeout": {
+ "connect": 0.5,
+ "send": 0.5,
+ "read": 0.5
+ }
+ },
+ "uri": "/mysleep"
+ }]]
+ )
+
+ if rcode >= 300 then
+ ngx.status = rcode
+ end
+ ngx.say(rbody)
+ }
+ }
+--- request
+GET /t
+--- response_body
+passed
+passed
+--- no_error_log
+[error]
+
+
+
+=== TEST 6: hit service route (timeout)
+--- request
+GET /mysleep?seconds=1
+--- more_headers
+Host: foo.com
+--- error_code: 504
+--- response_body eval
+qr/504 Gateway Time-out/
+--- error_log
+timed out) while reading response header from upstream