8000
Skip to content

Testing improvements#3107

Merged
ahopkins merged 8 commits intomainfrom
testing-improvements
Dec 28, 2025
Merged

Testing improvements#3107
ahopkins merged 8 commits intomainfrom
testing-improvements

Conversation

@ahopkins
Copy link
Copy Markdown
Member

This pull request improves the test suite's reliability and parallelization by introducing pytest-xdist for parallel test execution, organizing tests into logical groups to avoid conflicts, and making minor test improvements. The changes ensure that tests which spawn processes or manipulate shared resources are grouped together, preventing race conditions and flaky test failures.

Test suite parallelization and grouping:

  • Added pytest-xdist and pytest-cov to test requirements in setup.py to enable parallel test execution and coverage reporting.
  • Updated tox.ini to run tests in parallel using three workers and the loadgroup distribution strategy, and documented the new xdist_group marker. [1] [2]

Test grouping to avoid conflicts:

  • Added pytestmark = pytest.mark.xdist_group(...) to multiple test files (such as test_keep_alive_timeout.py, test_multiprocessing.py, test_signal_handlers.py, test_static.py, test_static_directory.py, test_url_for_static.py, and test_unix_socket.py) to ensure tests that manipulate processes, static files, or sockets are run together on the same worker. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]
  • Added a pytest_collection_modifyitems hook in tests/worker/conftest.py to automatically group all worker-related tests under the process_spawning group.

Test improvements and cleanup:

  • Modified several tests to use a dynamically assigned port fixture instead of hardcoded ports, improving test reliability and reducing port conflicts. [1] [2] [3] [4] [5] [6]
  • Improved cleanup logic in static file link fixtures to remove existing symlinks or hard links before creation, preventing test failures due to leftover files. [1] [2]

Copilot AI review requested due to automatic review settings December 28, 2025 09:10
@ahopkins ahopkins requested review from a team as code owners December 28, 2025 09:10
Copy link
Copy Markdown
Contributor
Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request enhances the test suite's reliability and enables parallel test execution by introducing pytest-xdist. The changes add proper test grouping to prevent race conditions when tests manipulate shared resources or spawn processes, and include minor improvements to test fixtures.

Key changes:

  • Added pytest-xdist and pytest-cov dependencies to enable parallel test execution across multiple workers
  • Configured tox.ini to run tests with 3 workers using the loadgroup distribution strategy
  • Grouped tests that spawn processes or manipulate shared resources (static files, sockets) to run on the same worker, preventing conflicts

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
setup.py Added pytest-xdist and pytest-cov to test requirements for parallel execution and coverage reporting
tox.ini Updated to use pytest-xdist with 3 workers and loadgroup distribution; added xdist_group marker documentation
tests/worker/conftest.py Added hook to automatically group all worker tests under process_spawning group
tests/test_url_for_static.py Added xdist_group marker for static_files group
tests/test_unix_socket.py Combined existing skipif marker with xdist_group marker for unix_socket group
tests/test_tls.py Added xdist_group markers to specific process-spawning tests; updated tests to use dynamic port fixture
tests/test_static_directory.py Added xdist_group marker for static_files group
tests/test_static.py Added xdist_group marker for static_files group; improved fixture cleanup to remove existing files before creation
tests/test_signal_handlers.py Added xdist_group marker for process_spawning group
tests/test_routes.py Changed hardcoded port to avoid conflicts
tests/test_multiprocessing.py Added xdist_group marker for process_spawning group
tests/test_late_adds.py Added xdist_group marker for process_spawning group
tests/test_keep_alive_timeout.py Added xdist_group marker for keep_alive_timeout group
tests/test_config.py Updated test to use dynamic port fixture
tests/test_app.py Updated test to use dynamic port fixture

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/test_static_directory.py Outdated
Comment thread tests/test_static.py Outdated
Comment thread tests/test_signal_handlers.py Outdated
Comment thread tests/test_multiprocessing.py Outdated
Comment thread tests/test_late_adds.py
Comment thread tests/test_keep_alive_timeout.py Outdated
Comment thread tests/test_url_for_static.py Outdated
@codecov
Copy link
Copy Markdown
codecov bot commented Dec 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.683%. Comparing base (c0848da) to head (0c7e10a).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #3107   +/-   ##
=========================================
  Coverage   87.683%   87.683%           
=========================================
  Files          104       104           
  Lines         7778      7778           
  Branches      1236      1236           
=========================================
  Hits          6820      6820           
  Misses         662       662           
  Partials       296       296           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ahopkins ahopkins merged commit 3da9845 into main Dec 28, 2025
29 checks passed
@ahopkins ahopkins deleted the testing-improvements branch December 28, 2025 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0