[Serve] Add unit tests for NodePortManager (#61491)
Why
NodePortManagerhandles per-node port allocation for direct ingress replicas but has zero unit test coverage in OSS. Any regression in allocation, release, or cleanup logic would go undetected until integration tests or production.What
Add
test_node_port_manager.pycovering:
- HTTP/gRPC port allocation and release
- Port reuse after release
- Port blocking (post-release exclusion)
- Re-allocation of an already-allocated replica (idempotency)
- Cleanup/pruning of inactive replicas and stale node managers
- Port exhaustion (
NoAvailablePortError)- Invalid port release (wrong port number)
- Concurrent allocation within a single node
- Mixed-protocol allocation for the same replica
- Blocked port persistence across allocation cycles
get_porterror path for unallocated replicasAll tests use monkeypatched port ranges (5 ports each for HTTP/gRPC) to keep execution fast and deterministic.
Test plan
pytest python/ray/serve/tests/unit/test_node_port_manager.py -v— 11/11 passed locallySigned-off-by: Seiji Eicher seiji@anyscale.com
版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9
京公网安备 11010802032778号