Fix flaky test in profiling branch #1351
Merged
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.
When starting webrick in-process in a background thread WITH a fixed port, we need to make sure that the webrick thread has shut down between tests, otherwise a follow-up test can fail with
Errno::EADDRINUSE: Address already in use - bind(2) for [::]:6218
due to the main test runner thread being faster at starting the next test case before the old webrick thread has had time to shut down.
This is the same issue as fixed in #1350 (both tests are similar).
Tips for hunting down these kinds of issues:
rspec_n
gem (thanks @roberts1000 !) was very useful in running a given test case multiple times to cause it to triggersleep 1
to the webrick shutdown sequence, thus making sure the background thread always gets delayed