Skip to content

test: bind mock servers to free ports so the suite can run in parallel - #2107

Draft
WilliamBergamin wants to merge 1 commit into
mainfrom
test/parallel-safe-tests
Draft

WilliamBergamin wants to merge 1 commit into
mainfrom
test/parallel-safe-tests

Conversation

@WilliamBergamin

Copy link
Copy Markdown
Contributor

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 auto failed 203 tests on port collisions.

  • Mock servers bind 127.0.0.1:0 and tests read the bound URL back (self.server_url, self.socket_mode_url), including the URLs apps.connections.open and rtm.start hand out.
  • Store tests use per-test temp dirs instead of logs/*.db and the home directory. Those paths raced across workers (-n 8 on the store files failed every run on main).
  • Tests only. Adding pytest-xdist to CI is left for a follow-up.

Testing

  1. pip install pytest-xdist
  2. PYTHONPATH=$PWD pytest -n auto tests/ passes (about 115s locally, vs about 290s serial).
  3. PYTHONPATH=$PWD pytest tests/ still passes serially (1124 passed).

Category

  • slack_sdk.web.WebClient (sync/async) (Web API client)
  • slack_sdk.webhook.WebhookClient (sync/async) (Incoming Webhook, response_url sender)
  • slack_sdk.socket_mode (Socket Mode client)
  • slack_sdk.signature (Request Signature Verifier)
  • slack_sdk.oauth (OAuth Flow Utilities)
  • slack_sdk.models (UI component builders)
  • slack_sdk.scim (SCIM API client)
  • slack_sdk.audit_logs (Audit Logs API client)
  • slack_sdk.rtm_v2 (RTM client)
  • /docs (Documents)
  • /tutorial (PythOnBoardingBot tutorial)
  • tests/integration_tests (Automated tests for this library)

Requirements

  • I've read and understood the Contributing Guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I have signed the Salesforce CLA (required before your PR can be reviewed or merged).
  • I've run python3 -m venv .venv && source .venv/bin/activate && ./scripts/run_validation.sh after making the changes.

🤖 Generated with Claude Code

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>
@WilliamBergamin WilliamBergamin added the tests M-T: Testing work only label Dec 2, 2026
@WilliamBergamin WilliamBergamin self-assigned this Dec 2, 2026
@codecov

codecov Bot commented Dec 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.93%. Comparing base (6703d74) to head (cf6e9e2).
✅ All tests successful. No failed tests found.

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.
📢 Have feedback on the report? Share it here.

This branch has not been deployed

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

Labels

tests M-T: Testing work only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant