-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(limit-conn): always save the data of the limit object, and release it in log phase. #2465
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -989,7 +989,7 @@ done | |
|
||
|
||
=== TEST 26: create consumer and bind key-auth plugin | ||
--- config | ||
--- config | ||
location /t { | ||
content_by_lua_block { | ||
local t = require("lib.test_admin").test | ||
|
@@ -1019,7 +1019,7 @@ passed | |
|
||
|
||
|
||
=== TEST 27: create route and enable plugin 'key-auth' | ||
=== TEST 27: create route and enable plugin 'key-auth' | ||
--- config | ||
location /t { | ||
content_by_lua_block { | ||
|
@@ -1207,9 +1207,9 @@ qr/limit key: consumer_jackroute&consumer\d+/ | |
content_by_lua_block { | ||
local plugin = require("apisix.plugins.limit-conn") | ||
local ok, err = plugin.check_schema({ | ||
conn = 1, | ||
default_conn_delay = 0.1, | ||
rejected_code = 503, | ||
conn = 1, | ||
default_conn_delay = 0.1, | ||
rejected_code = 503, | ||
key = 'consumer_name' | ||
}) | ||
if not ok then | ||
|
@@ -1225,3 +1225,61 @@ property "burst" is required | |
done | ||
--- no_error_log | ||
[error] | ||
|
||
|
||
|
||
=== TEST 32: enable plugin: conn=1 | ||
--- config | ||
location /t { | ||
content_by_lua_block { | ||
local t = require("lib.test_admin").test | ||
local code, body = t('/apisix/admin/routes/1', | ||
ngx.HTTP_PUT, | ||
[[{ | ||
"plugins": { | ||
"limit-conn": { | ||
"conn": 1, | ||
"burst": 0, | ||
"default_conn_delay": 0.3, | ||
"rejected_code": 503, | ||
"key": "remote_addr" | ||
} | ||
}, | ||
"upstream": { | ||
"nodes": { | ||
"127.0.0.1:1980": 1 | ||
}, | ||
"type": "roundrobin" | ||
}, | ||
"uri": "/hello" | ||
}]] | ||
) | ||
if code >= 300 then | ||
ngx.status = code | ||
end | ||
ngx.say(body) | ||
} | ||
} | ||
--- request | ||
GET /t | ||
--- response_body | ||
passed | ||
--- no_error_log | ||
[error] | ||
|
||
|
||
|
||
=== TEST 33: hit route and should not be limited | ||
--- pipelined_requests eval | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't the request be rejected here? I did not understand There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All requests are sent one after another, they are not concurrent. So the request should never be limited for In the old code, it will be limited due to this bug. |
||
[ | ||
"GET /hello", "GET /hello", "GET /hello", | ||
"GET /hello", "GET /hello", "GET /hello", | ||
] | ||
--- timeout: 10s | ||
--- error_code eval | ||
[ | ||
200, 200, 200, | ||
200, 200, 200 | ||
] | ||
--- no_error_log | ||
[error] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why modify this test case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
old test cases have
space
at the end of line.my editor helps me do the
slim
, this is fine.