Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(limiter): fix intermittent failures #2716

Merged
merged 1 commit into from
Nov 10, 2023

Conversation

nickajacks1
Copy link
Member

@nickajacks1 nickajacks1 commented Nov 10, 2023

The limiter middleware unit tests are failing due to a race between the storage garbage collector and the unit test itself. The sliding window limiter tracks requests using memory storage. In several of the unit tests, this storage expiry ends up being 4 seconds. The test waits for 4 seconds, then sends a request, expecting it to succeed. However, the unit test occasionally wakes up before the storage GC kicks in. As an effect of the very coarse timer (using seconds as units), the middleware correctly rejects the request, causing the test to fail.

Update the sleep to 4.5 seconds. This will not slow down the execution of the test suite, as these tests run in parallel with a separate 9 second long test.

I'm not 100% sure this solves the issue, and ideally we'd be able to run tests without time.Sleep.

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
Explain the details for making this change. What existing problem does the pull request solve?

Type of change

Please delete options that are not relevant.

  • Unit Tests

Checklist:

  • I have performed a self-review of my own code
  • New and existing unit tests pass locally with my changes

The limiter middleware unit tests are failing due to a race between the
storage garbage collector and the unit test itself. The sliding window
limiter tracks requests using memory storage. In several of the unit
tests, this storage expiry ends up being 4 seconds. The test waits for 4
seconds, then sends a request, expecting it to succeed. However, the
unit test occasionally wakes up before the storage GC kicks in. As an
effect of the very coarse timer (using seconds as units), the middleware
correctly rejects the request, causing the test to fail.

Update the sleep to 4.5 seconds. This will not slow down the execution
of the test suite, as these tests run in parallel with a separate 9
second long test.

I'm not 100% sure this solves the issue, and ideally we'd be able to
run tests without time.Sleep.
@nickajacks1
Copy link
Member Author

CI failed on CORS and Session middleware tests

@ReneWerner87 ReneWerner87 added this to the v2 Next Release milestone Nov 10, 2023
@ReneWerner87 ReneWerner87 merged commit 1e55045 into gofiber:master Nov 10, 2023
21 checks passed
@nickajacks1 nickajacks1 deleted the testfail-limit branch November 11, 2023 02:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants