You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by sp...@apache.org on 2020/10/20 12:46:04 UTC
[apisix] branch master updated: fix(limit-conn): conn and
default_conn_delay should > 0 (#2478)
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 ed1f08f fix(limit-conn): conn and default_conn_delay should > 0 (#2478)
ed1f08f is described below
commit ed1f08f926df23acc275fd82585c5fc0ff8ce158
Author: 罗泽轩 <sp...@gmail.com>
AuthorDate: Tue Oct 20 20:45:51 2020 +0800
fix(limit-conn): conn and default_conn_delay should > 0 (#2478)
Close #2472.
---
apisix/plugins/limit-conn.lua | 4 ++--
t/plugin/limit-conn.t | 34 ++++++++++++++++++++++++++++++++--
2 files changed, 34 insertions(+), 4 deletions(-)
diff --git a/apisix/plugins/limit-conn.lua b/apisix/plugins/limit-conn.lua
index 7979b5f..ca8ca3c 100644
--- a/apisix/plugins/limit-conn.lua
+++ b/apisix/plugins/limit-conn.lua
@@ -23,9 +23,9 @@ local plugin_name = "limit-conn"
local schema = {
type = "object",
properties = {
- conn = {type = "integer", minimum = 0},
+ conn = {type = "integer", exclusiveMinimum = 0},
burst = {type = "integer", minimum = 0},
- default_conn_delay = {type = "number", minimum = 0},
+ default_conn_delay = {type = "number", exclusiveMinimum = 0},
key = {type = "string",
enum = {"remote_addr", "server_addr", "http_x_real_ip",
"http_x_forwarded_for"},
diff --git a/t/plugin/limit-conn.t b/t/plugin/limit-conn.t
index 4bc99d4..4401857 100644
--- a/t/plugin/limit-conn.t
+++ b/t/plugin/limit-conn.t
@@ -428,7 +428,7 @@ GET /t
GET /t
--- error_code: 400
--- response_body
-{"error_msg":"failed to check the configuration of plugin limit-conn err: property \"conn\" validation failed: expected -1 to be greater than 0"}
+{"error_msg":"failed to check the configuration of plugin limit-conn err: property \"conn\" validation failed: expected -1 to be sctrictly greater than 0"}
--- no_error_log
[error]
@@ -511,7 +511,7 @@ GET /t
GET /t
--- error_code: 400
--- response_body
-{"error_msg":"failed to check the configuration of plugin limit-conn err: property \"conn\" validation failed: expected -1 to be greater than 0"}
+{"error_msg":"failed to check the configuration of plugin limit-conn err: property \"conn\" validation failed: expected -1 to be sctrictly greater than 0"}
--- no_error_log
[error]
@@ -956,3 +956,33 @@ GET /test_concurrency
200
--- no_error_log
[error]
+
+
+
+=== TEST 25: invalid schema
+--- config
+ location /t {
+ content_by_lua_block {
+ local plugin = require("apisix.plugins.limit-conn")
+ local cases = {
+ {conn = 0, burst = 0, default_conn_delay = 0.1, rejected_code = 503, key = 'remote_addr'},
+ {conn = 1, burst = 0, default_conn_delay = 0, rejected_code = 503, key = 'remote_addr'},
+ }
+ for _, c in ipairs(cases) do
+ local ok, err = plugin.check_schema(c)
+ if not ok then
+ ngx.say(err)
+ end
+ end
+
+ ngx.say("done")
+ }
+ }
+--- request
+GET /t
+--- response_body
+property "conn" validation failed: expected 0 to be sctrictly greater than 0
+property "default_conn_delay" validation failed: expected 0 to be sctrictly greater than 0
+done
+--- no_error_log
+[error]