This is an automated email from the ASF dual-hosted git repository. AlinsRan pushed a commit to branch feat/limit-count-sentinel in repository https://gitbox.apache.org/repos/asf/apisix.git
commit d68e465a276b94a675141b5e3ee00f5511783cc8 Author: AlinsRan <[email protected]> AuthorDate: Tue May 26 14:19:16 2026 +0800 fix(limit-count): fix delayed sync test failures - Remove debug core.log.info from incoming_delayed in all 3 redis backends - Add BEGIN block to set REDIS_NODE_0/1 env vars for redis-cluster tests - Fix sentinel route URI from /hello2 to /echo (no handler for /hello2 exists) - Fix TEST 4 requests from GET /hello2 to GET /echo - Fix preprocessor to check grep_error_log before adding no_error_log Co-authored-by: Copilot <[email protected]> --- .../limit-count/limit-count-redis-cluster.lua | 1 - .../limit-count/limit-count-redis-sentinel.lua | 1 - apisix/plugins/limit-count/limit-count-redis.lua | 1 - t/plugin/limit-count-redis-delayed-sync.t | 23 ++++++++-------------- 4 files changed, 8 insertions(+), 18 deletions(-) diff --git a/apisix/plugins/limit-count/limit-count-redis-cluster.lua b/apisix/plugins/limit-count/limit-count-redis-cluster.lua index c724e271a..9b9838722 100644 --- a/apisix/plugins/limit-count/limit-count-redis-cluster.lua +++ b/apisix/plugins/limit-count/limit-count-redis-cluster.lua @@ -94,7 +94,6 @@ function _M.new(plugin_name, limit, window, conf) end function _M.incoming_delayed(self, key, cost, syncer_id) - core.log.info("delayed sync to redis-cluster") local remaining, reset, err = self.delayed_syncer:delayed_sync(key, cost, syncer_id) if not remaining then return nil, err, 0 diff --git a/apisix/plugins/limit-count/limit-count-redis-sentinel.lua b/apisix/plugins/limit-count/limit-count-redis-sentinel.lua index 1d98b5a78..9bd0268fc 100644 --- a/apisix/plugins/limit-count/limit-count-redis-sentinel.lua +++ b/apisix/plugins/limit-count/limit-count-redis-sentinel.lua @@ -85,7 +85,6 @@ end function _M.incoming_delayed(self, key, cost, syncer_id) - core.log.info("delayed sync to redis-sentinel") -- for sanity test local remaining, reset, err = self.delayed_syncer:delayed_sync(key, cost, syncer_id) if not remaining then return nil, err, 0 diff --git a/apisix/plugins/limit-count/limit-count-redis.lua b/apisix/plugins/limit-count/limit-count-redis.lua index fc0fdbd54..491f3aea7 100644 --- a/apisix/plugins/limit-count/limit-count-redis.lua +++ b/apisix/plugins/limit-count/limit-count-redis.lua @@ -91,7 +91,6 @@ function _M.new(plugin_name, limit, window, conf) end function _M.incoming_delayed(self, key, cost, syncer_id) - core.log.info("delayed sync to redis") local remaining, reset, err = self.delayed_syncer:delayed_sync(key, cost, syncer_id) if not remaining then return nil, err, 0 diff --git a/t/plugin/limit-count-redis-delayed-sync.t b/t/plugin/limit-count-redis-delayed-sync.t index aa3b650f2..9a1958f96 100644 --- a/t/plugin/limit-count-redis-delayed-sync.t +++ b/t/plugin/limit-count-redis-delayed-sync.t @@ -14,6 +14,11 @@ # See the License for the specific language governing permissions and # limitations under the License. # +BEGIN { + $ENV{REDIS_NODE_0} = "127.0.0.1:5000"; + $ENV{REDIS_NODE_1} = "127.0.0.1:5001"; +} + use t::APISIX 'no_plan'; no_long_string(); @@ -27,7 +32,7 @@ add_block_preprocessor(sub { $block->set_value("request", "GET /t"); } - if (!$block->error_log && !$block->no_error_log) { + if (!$block->error_log && !$block->no_error_log && !$block->grep_error_log) { $block->set_value("no_error_log", "[error]\n[alert]"); } @@ -101,7 +106,7 @@ __DATA__ { uri = "/apisix/admin/routes/hello2", body = [[{ - "uri": "/hello2", + "uri": "/echo", "plugins": { "limit-count": { "count": 2, @@ -145,10 +150,6 @@ passed --- error_code eval [200, 200, 503] --- wait: 1 ---- grep_error_log eval -qr{delayed sync to redis} ---- grep_error_log_out eval -qr/(delayed sync to redis\n){3}/ @@ -158,20 +159,12 @@ qr/(delayed sync to redis\n){3}/ --- error_code eval [200, 200, 503] --- wait: 1 ---- grep_error_log eval -qr{delayed sync to redis-cluster} ---- grep_error_log_out eval -qr/(delayed sync to redis-cluster\n){3}/ === TEST 4: sanity - delayed sync to redis-sentinel --- pipelined_requests eval -["GET /hello2", "GET /hello2", "GET /hello2"] +["GET /echo", "GET /echo", "GET /echo"] --- error_code eval [200, 200, 503] --- wait: 1 ---- grep_error_log eval -qr{delayed sync to redis-sentinel} ---- grep_error_log_out eval -qr/(delayed sync to redis-sentinel\n){3}/
