This is an automated email from the ASF dual-hosted git repository.

monkeydluffy 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 c12002e76 feat(limit-count): set minLength of redis_cluster_nodes to 1 
(#10612)
c12002e76 is described below

commit c12002e76a33d5b9c2e12125ec3989760e31e19d
Author: ikatlinsky <[email protected]>
AuthorDate: Mon Dec 11 09:53:29 2023 +0100

    feat(limit-count): set minLength of redis_cluster_nodes to 1 (#10612)
---
 apisix/plugins/limit-count.lua        |  2 +-
 apisix/plugins/limit-count/init.lua   |  2 +-
 t/plugin/limit-count-redis-cluster3.t | 51 +++++++++++++++++++++++++++++++++++
 3 files changed, 53 insertions(+), 2 deletions(-)

diff --git a/apisix/plugins/limit-count.lua b/apisix/plugins/limit-count.lua
index 72ab574df..3e2443d0e 100644
--- a/apisix/plugins/limit-count.lua
+++ b/apisix/plugins/limit-count.lua
@@ -18,7 +18,7 @@ local limit_count = require("apisix.plugins.limit-count.init")
 
 local plugin_name = "limit-count"
 local _M = {
-    version = 0.4,
+    version = 0.5,
     priority = 1002,
     name = plugin_name,
     schema = limit_count.schema,
diff --git a/apisix/plugins/limit-count/init.lua 
b/apisix/plugins/limit-count/init.lua
index a280592b9..049e238e9 100644
--- a/apisix/plugins/limit-count/init.lua
+++ b/apisix/plugins/limit-count/init.lua
@@ -74,7 +74,7 @@ local policy_to_additional_properties = {
         properties = {
             redis_cluster_nodes = {
                 type = "array",
-                minItems = 2,
+                minItems = 1,
                 items = {
                     type = "string", minLength = 2, maxLength = 100
                 },
diff --git a/t/plugin/limit-count-redis-cluster3.t 
b/t/plugin/limit-count-redis-cluster3.t
index b534c3a2c..017c3048e 100644
--- a/t/plugin/limit-count-redis-cluster3.t
+++ b/t/plugin/limit-count-redis-cluster3.t
@@ -77,3 +77,54 @@ __DATA__
     }
 --- response_body
 remaining: 1
+
+
+
+=== TEST 2: set route, with single node in redis_cluster_nodes and 
redis_cluster_name
+--- 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,
+                [[{
+                    "uri": "/hello",
+                    "plugins": {
+                        "limit-count": {
+                            "count": 2,
+                            "time_window": 60,
+                            "rejected_code": 503,
+                            "key": "remote_addr",
+                            "policy": "redis-cluster",
+                            "redis_timeout": 1001,
+                            "redis_cluster_nodes": [
+                                "127.0.0.1:5000"
+                            ],
+                            "redis_cluster_name": "redis-cluster-1"
+                        }
+                    },
+                    "upstream": {
+                        "nodes": {
+                            "127.0.0.1:1980": 1
+                        },
+                        "type": "roundrobin"
+                    }
+                }]]
+                )
+
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.say(body)
+        }
+    }
+--- response_body
+passed
+
+
+
+=== TEST 3: up the limit for single node in redis_cluster_nodes
+--- pipelined_requests eval
+["GET /hello", "GET /hello", "GET /hello"]
+--- error_code eval
+[200, 200, 503]

Reply via email to