Add per-worker HTTP port support for parallel test execution #91
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 PR implements per-worker HTTP port allocation to enable parallel test execution with pytest-xdist, resolving "Address already in use" errors that caused 513 test failures when running tests in parallel mode.
Problem
When running tests with
pytest -n auto --odoo-database test, all workers attempted to bind to the same HTTP port (8069), causing port conflicts and test failures. While database isolation worked correctly (each worker gottest-gw0,test-gw1, etc.), HTTP port configuration was missing worker-specific logic.Solution
This PR adds per-worker HTTP port allocation using a simple formula:
base_port + worker_num + 1Port Allocation Strategy
Changes
--odoo-http-portCLI option - Allows customizing the base HTTP port (default: 8069)_get_worker_number()helper - Parses worker IDs like "gw0", "gw1" into integerspytest_cmdline_mainhook - Sets worker-specific port before HTTP server starts_worker_db_name()context manager - Now handles both database and HTTP port allocation with proper cleanupload_registryfixture - Passes config parameter to access CLI optionsload_httpfixture - Configures worker-specific ports for--odoo-httpflagImplementation Details
Benefits
Testing
Tested with:
Related Issues
Resolves parallel test execution failures caused by HTTP port conflicts in pytest-xdist mode.
🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com