From 32bd9a3a89eac7cac6ad01e698c3488ef4d8fee0 Mon Sep 17 00:00:00 2001 From: xfy911 Date: Sun, 14 Jun 2026 15:20:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20Rate=20Limit=20=E9=9B=86?= =?UTF-8?q?=E6=88=90=E6=B5=8B=E8=AF=95=E7=9A=84=E7=A7=92=E8=BE=B9=E7=95=8C?= =?UTF-8?q?=E5=81=B6=E5=8F=91=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 原测试仅发送2个请求,容易跨秒边界导致限流计数器重置, 偶发出现 200+200 而非期望的 200+429。 改为连续发送3个请求,只要第1个是200且后续至少1个是429即算通过, 消除秒边界抖动导致的假阴性。 --- tests/integration_test.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/integration_test.sh b/tests/integration_test.sh index 047df5c..862dec7 100755 --- a/tests/integration_test.sh +++ b/tests/integration_test.sh @@ -849,11 +849,12 @@ for i in {1..30}; do done rl_first=$(curl -s -o /dev/null -w "%{http_code}" "$BASE/") rl_second=$(curl -s -o /dev/null -w "%{http_code}" "$BASE/") -if [[ "$rl_first" == "200" && "$rl_second" == "429" ]]; then - echo " ✓ Rate Limit 限流 — 第1次 200, 第2次 429" +rl_third=$(curl -s -o /dev/null -w "%{http_code}" "$BASE/") +if [[ "$rl_first" == "200" && ("$rl_second" == "429" || "$rl_third" == "429") ]]; then + echo " ✓ Rate Limit 限流 — 第1次 200, 后续请求中至少1次 429" pass else - echo " ✗ Rate Limit 限流 — 期望 200+429, 实际 $rl_first+$rl_second" + echo " ✗ Rate Limit 限流 — 期望 200+429, 实际 $rl_first+$rl_second+$rl_third" fail fi