nic-6443 commented on code in PR #12861:
URL: https://github.com/apache/apisix/pull/12861#discussion_r2726342028
##########
t/plugin/limit-req-redis.t:
##########
@@ -143,7 +143,59 @@ passed
-=== TEST 5: update plugin with username password
+=== TEST 5: verify redis keepalive
+--- extra_init_by_lua
+ local limit_req = require("apisix.plugins.limit-req.limit-req-redis")
+ local core = require("apisix.core")
+
+ limit_req.origin_incoming = limit_req.incoming
+ limit_req.incoming = function(self, key, commit)
+ local redis = require("resty.redis")
+ local conf = self.conf
+ local delay, err = self:origin_incoming(key, commit)
+ if not delay then
+ ngx.say("limit fail: ", err)
+ return delay, err
+ end
+
+ -- verify connection reused time
+ local red, err = redis:new()
+ if err then
+ core.log.error("failed to create redis cli: ", err)
+ ngx.say("failed to create redis cli: ", err)
+ return nil, err
+ end
+ red:set_timeout(1000)
+ local ok, err = red:connect(conf.redis_host, conf.redis_port)
+ if not ok then
+ core.log.error("failed to connect: ", err)
+ ngx.say("failed to connect: ", err)
+ return nil, err
+ end
+ local reused_time, err = red:get_reused_times()
+ if reused_time == 0 then
+ core.log.error("redis connection is not keepalive")
+ ngx.say("redis connection is not keepalive")
+ return nil, err
+ end
Review Comment:
ditto
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]