This is an automated email from the ASF dual-hosted git repository.
nic-6443 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 127e6bb28 test: give the redis counter poll five seconds instead of
one (#13892)
127e6bb28 is described below
commit 127e6bb28cd3238c97bc4e99aa0733d402fb16bd
Author: Nic <[email protected]>
AuthorDate: Mon Aug 31 11:41:45 2026 +0800
test: give the redis counter poll five seconds instead of one (#13892)
---
t/lib/test_redis.lua | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/t/lib/test_redis.lua b/t/lib/test_redis.lua
index 6947bb01c..ca435bd7d 100644
--- a/t/lib/test_redis.lua
+++ b/t/lib/test_redis.lua
@@ -218,18 +218,32 @@ function _M.sum_counters(pattern, opts)
return total
end
+-- Bounded poll for an asynchronous counter write. The old bound, 100
iterations
+-- of a 10ms sleep, gave up after roughly one second, which a loaded CI runner
+-- exceeds often enough to make callers flaky. Bound the wait by wall clock
+-- rather than by iteration count: every pass also does a full sum_counters()
+-- round trip, so counting iterations understates the ceiling exactly when
redis
+-- is the slow part. The loop still returns as soon as the counter moves, so a
+-- healthy run costs what it did before.
+local WAIT_COUNTERS_TIMEOUT = 5
+
function _M.wait_counters_above(pattern, previous, opts)
local last_err
- for _ = 1, 100 do
+ ngx.update_time()
+ local deadline = ngx.now() + WAIT_COUNTERS_TIMEOUT
+
+ repeat
local total, err = _M.sum_counters(pattern, opts)
if total and total > previous then
return true
end
last_err = err
ngx.sleep(0.01)
- end
+ ngx.update_time()
+ until ngx.now() >= deadline
return nil, "counters matching " .. pattern .. " stayed at " .. previous ..
+ " for " .. WAIT_COUNTERS_TIMEOUT .. "s" ..
(last_err and (", last error: " .. last_err) or "")
end