test: flush redis for rate limiting tests #12957
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

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.
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.apisix/t/plugin/limit-count-redis-cluster.t
Lines 167 to 180 in c0c906e
Checklist