Update limit core tests to avoid false negative

This commit is contained in:
Théophile Diot 2023-06-12 18:37:14 -04:00
parent 855ae89363
commit 5d7ef69c9d
No known key found for this signature in database
GPG Key ID: E752C80DB72BB014
1 changed files with 4 additions and 2 deletions

View File

@ -93,6 +93,7 @@ try:
stopped = True
break
total = time() - start
rate = int(limit_req_rate[:-3])
if use_limit_request and stopped:
print(
@ -112,7 +113,7 @@ try:
flush=True,
)
exit(0)
elif request_number < int(limit_req_rate[:-3]) + 1:
elif request_number < rate + 1 or request_number > rate + 3:
print(
f"❌ The limit_req directive is not working correctly, {request_number} requests were made in {total:.2f}s while the limit was set to {limit_req_rate}, exiting ...",
flush=True,
@ -152,6 +153,7 @@ try:
stopped = True
break
total = time() - start
rate = int(limit_req_rate_1[:-3])
if stopped:
print(
@ -159,7 +161,7 @@ try:
flush=True,
)
exit(1)
elif request_number < int(limit_req_rate_1[:-3]) + 1:
elif request_number < rate + 1 or request_number > rate + 3:
print(
f"❌ The limit_req_1 directive is not working correctly, {request_number} requests were made in {total:.2f}s while the limit was set to {limit_req_rate}, exiting ...",
flush=True,