Repository navigation
test: bind mock servers to free ports so the suite can run in parallel - #2107
Draft
WilliamBergamin wants to merge 1 commit into
Draft
WilliamBergamin wants to merge 1 commit into
WilliamBergamin wants to merge 1 commit into
Conversation
Every mock server bound a fixed port (web API 8888/8889, Socket Mode 3001/3011/3012, RTM 8765) and tests hard-coded those URLs, so pytest-xdist workers collided and 203 tests failed under `-n auto`. - Mock servers bind 127.0.0.1:0 in the calling thread; tests read the URL back from `self.server_url` and `self.socket_mode_url`. - `apps.connections.open` and `rtm.start` return the companion websocket server's bound URL. - Store tests write to per-test temp dirs instead of logs/*.db and the home directory, which raced across workers. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2107 +/- ##
==========================================
- Coverage 84.96% 84.93% -0.04%
==========================================
Files 118 118
Lines 14287 14287
==========================================
- Hits 12139 12134 -5
- Misses 2148 2153 +5 ☔ View full report in Codecov by Harness. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This pull request makes the test suite safe to run in parallel with
pytest-xdist.Every mock server bound a fixed port (8888, 8889, 3001, 3011, 3012, 8765) and tests hard-coded those URLs, so
pytest -n autofailed 203 tests on port collisions.127.0.0.1:0and tests read the bound URL back (self.server_url,self.socket_mode_url), including the URLsapps.connections.openandrtm.starthand out.logs/*.dband the home directory. Those paths raced across workers (-n 8on the store files failed every run onmain).pytest-xdistto CI is left for a follow-up.Testing
pip install pytest-xdistPYTHONPATH=$PWD pytest -n auto tests/passes (about 115s locally, vs about 290s serial).PYTHONPATH=$PWD pytest tests/still passes serially (1124 passed).Category
/docs(Documents)/tutorial(PythOnBoardingBot tutorial)tests/integration_tests(Automated tests for this library)Requirements
python3 -m venv .venv && source .venv/bin/activate && ./scripts/run_validation.shafter making the changes.🤖 Generated with Claude Code