[Rust Frontend][CI] Remove TCP port races from mock-engine tests (#54481)

Co-authored-by: OpenAI Codex <codex@openai.com> Signed-off-by: Andreas Karatzas <Andreas.Karatzas@amd.com>

Andreas Karatzas committed Aug 31, 2026 at 12:02 UTC f9c7c6e0909eadc23f1aa2510a233f91692ed437
1 file changed +12 -24
rust/src/mock-engine/src/tests.rs
+12 -24
@@ -1,7 +1,6 @@
1 // SPDX-License-Identifier: Apache-2.0
2 // SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
4 -use std::net::TcpListener;
4 use std::time::Duration;
5
6 use anyhow::Result;
@@ -16,13 +15,6 @@ use vllm_engine_core_client::{EngineCoreClient, EngineCoreClientConfig, Transpor
15
16 use crate::{Opt, run};
17
19 -fn free_tcp_address() -> String {
20 - let listener = TcpListener::bind("127.0.0.1:0").expect("bind free port");
21 - let port = listener.local_addr().expect("local addr").port();
22 - drop(listener);
23 - format!("tcp://127.0.0.1:{port}")
24 -}
25 -
18 fn client_config(handshake_address: String, engine_count: usize) -> EngineCoreClientConfig {
19 EngineCoreClientConfig {
20 transport_mode: TransportMode::HandshakeOwner {
@@ -95,17 +87,6 @@ async fn shutdown_mock(
87 task.await.expect("mock join").expect("mock run");
88 }
89
98 -#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
99 -async fn mock_engine_connects_over_tcp() {
100 - let handshake_address = free_tcp_address();
101 - let (client, shutdown, task) = connect_with_mock(handshake_address, 1, 1).await;
102 - assert_eq!(client.engine_count(), 1);
103 - assert_eq!(client.engine_identities()[0], &[0, 0]);
104 - assert_eq!(client.max_model_len(), 1024 * 1024);
105 - assert_eq!(client.vllm_version(), "test-vllm-version");
106 - shutdown_mock(client, shutdown, task).await;
107 -}
108 -
90 #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
91 async fn mock_engine_connects_over_ipc() {
92 let ipc = IpcNamespace::new().expect("ipc namespace");
@@ -113,12 +94,15 @@ async fn mock_engine_connects_over_ipc() {
94 let (client, shutdown, task) = connect_with_mock(handshake_address, 1, 1).await;
95 assert_eq!(client.engine_count(), 1);
96 assert_eq!(client.engine_identities()[0], &[0, 0]);
97 + assert_eq!(client.max_model_len(), 1024 * 1024);
98 + assert_eq!(client.vllm_version(), "test-vllm-version");
99 shutdown_mock(client, shutdown, task).await;
100 }
101
102 #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
103 async fn mock_engine_registers_multiple_identities() {
121 - let handshake_address = free_tcp_address();
104 + let ipc = IpcNamespace::new().expect("ipc namespace");
105 + let handshake_address = ipc.handshake_endpoint();
106 let (client, shutdown, task) = connect_with_mock(handshake_address, 2, 1).await;
107 assert_eq!(client.engine_count(), 2);
108 assert_eq!(client.engine_identities(), vec![&[0, 0][..], &[1, 0][..]]);
@@ -127,7 +111,8 @@ async fn mock_engine_registers_multiple_identities() {
111
112 #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
113 async fn chunk_size_one_outputs_one_token_per_update() {
130 - let handshake_address = free_tcp_address();
114 + let ipc = IpcNamespace::new().expect("ipc namespace");
115 + let handshake_address = ipc.handshake_endpoint();
116 let (client, shutdown, task) = connect_with_mock(handshake_address, 1, 1).await;
117 let mut stream = client.call(sample_request("req-1", 3)).await.expect("call");
118
@@ -147,7 +132,8 @@ async fn chunk_size_one_outputs_one_token_per_update() {
132
133 #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
134 async fn chunk_size_clips_final_output_to_max_tokens() {
150 - let handshake_address = free_tcp_address();
135 + let ipc = IpcNamespace::new().expect("ipc namespace");
136 + let handshake_address = ipc.handshake_endpoint();
137 let (client, shutdown, task) = connect_with_mock(handshake_address, 1, 4).await;
138 let mut stream = client.call(sample_request("req-clip", 6)).await.expect("call");
139
@@ -164,7 +150,8 @@ async fn chunk_size_clips_final_output_to_max_tokens() {
150
151 #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
152 async fn abort_cancels_active_request_and_emits_terminal_output() {
167 - let handshake_address = free_tcp_address();
153 + let ipc = IpcNamespace::new().expect("ipc namespace");
154 + let handshake_address = ipc.handshake_endpoint();
155 let (client, shutdown, task) = connect_with_mock(handshake_address, 1, 1).await;
156 let mut stream = client.call(sample_request("req-abort", 1_000_000)).await.expect("call");
157 let first = stream.next().await.expect("first").expect("first ok");
@@ -189,7 +176,8 @@ async fn abort_cancels_active_request_and_emits_terminal_output() {
176
177 #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
178 async fn utility_requests_return_minimal_success_responses() {
192 - let handshake_address = free_tcp_address();
179 + let ipc = IpcNamespace::new().expect("ipc namespace");
180 + let handshake_address = ipc.handshake_endpoint();
181 let (client, shutdown, task) = connect_with_mock(handshake_address, 1, 1).await;
182
183 assert!(!client.is_sleeping().await.expect("is sleeping"));