From 50a7fe975576e1602bf0ba2f4b87ac11a5f09826 Mon Sep 17 00:00:00 2001 From: Qi Date: Sat, 7 Oct 2023 14:14:26 +0800 Subject: [PATCH] tests(rate-limiting): fix a flaky test --- spec/03-plugins/23-rate-limiting/04-access_spec.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/03-plugins/23-rate-limiting/04-access_spec.lua b/spec/03-plugins/23-rate-limiting/04-access_spec.lua index 63268657e2cc..80636b33f674 100644 --- a/spec/03-plugins/23-rate-limiting/04-access_spec.lua +++ b/spec/03-plugins/23-rate-limiting/04-access_spec.lua @@ -762,6 +762,8 @@ if limit_by == "ip" then assert .with_timeout(15) .with_max_tries(10) + .with_step(0.5) -- the windows is 1 second, we wait 0.5 seconds between each retry, + -- that can avoid some unlucky case (we are at the end of the window) .ignore_exceptions(false) .eventually(function() local res1 = GET(test_path, { headers = { ["X-Real-IP"] = "127.0.0.3" }})