You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
test: Fix flaky full-stack tests by mocking service ports
Motivation:
Multiple full-stack tests were failing intermittently when run in parallel
due to "Address already in use" errors. They all defaulted to the same
base port (9526), causing conflicts in concurrent test environments.
Design Choices:
- Restored mock_service_ports in OpenQA::Test::Utils which was previously
removed as dead code in 8d7b9a5. It mocks OpenQA::Utils::service_port
via Test::MockModule to allocate independent free ports per service using
Mojo::IOLoop::Server->generate_port, which asks the OS for a truly free
port instead of blindly guessing.
- Applied mock_service_ports to t/05-scheduler-full.t, t/25-cache-service.t,
t/33-developer_mode.t, t/43-scheduling-and-worker-scalability.t, and
t/full-stack.t, replacing the prior setup_random_base_port approach.
- Each service gets an independently chosen free port (not a fixed-offset
block), eliminating the risk that one occupied port breaks all services.
- Removed duplicate randomization logic and redundant comments across
multiple test files.
- Cleaned up BEGIN blocks and imports in full-stack tests.
Benefits:
- Guarantees free ports via OS-level allocation, eliminating race conditions
that setup_random_base_port could not prevent.
- Eliminates port conflicts during parallel test execution.
- Improves test stability and reliability for CI/CD.
- Centralizes logic for easier future maintenance and consistent
port selection strategy.
- Cleaner and more maintainable test code.
0 commit comments