Skip to content

Conversation

@beardnick
Copy link
Contributor

@beardnick beardnick commented Feb 1, 2026

Description

Which issue(s) this PR fixes:

This is a separate PR from #12751. That PR is too large to review, so I decided to split it into several smaller PRs. This particular PR focuses solely on improving the stability of tests for rate-limiting plugins that require Redis.

Notice

To use code like this, I had to adjust some cases to ensure the test results were independent.

    $extra_init_worker_by_lua .= <<_EOC_;
        require("lib.test_redis").flush_all()
_EOC_

For example:
The rate limit here is 2 requests per minute. Previously, there was no cleanup process between tests, so TEST 5 depended on TEST 4. TEST 4 increased the counter by 1, which made TEST 5 expect [200, 503, 503]. My PR introduced a cleanup process for each test case, so now TEST 5 expects [200, 200, 503]. I believe having independent test cases is more stable and easier to understand.

=== TEST 4: up the limit
--- request
GET /hello
--- error_log
try to lock with key route#1#redis-cluster
unlock with key route#1#redis-cluster
=== TEST 5: up the limit
--- pipelined_requests eval
["GET /hello", "GET /hello", "GET /hello"]
--- error_code eval
[200, 503, 503]

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Feb 1, 2026
@dosubot
Copy link

dosubot bot commented Feb 1, 2026

Related Documentation

No published documentation to review for changes on this repository.

Write your first living document

How did I do? Any feedback?  Join Discord

@beardnick
Copy link
Contributor Author

beardnick commented Feb 2, 2026

image The failed tests were unrelated to my PR. All the rate limiting tests passed successfully. @Baoyuantop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants