mirror of
https://github.com/zyycn/codex-proxy-rs.git
synced 2026-11-25 16:01:26 +00:00
test(openai): prevent proxy port reuse in parallel tests
Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
@@ -10,6 +10,7 @@ use gateway_core::engine::{
|
||||
};
|
||||
use gateway_core::error::StoreError;
|
||||
use gateway_core::routing::AccountRoutingSnapshot;
|
||||
use tokio::net::TcpSocket;
|
||||
|
||||
struct NoopExecutionStore;
|
||||
|
||||
@@ -437,9 +438,13 @@ async fn refused_connections_respect_the_same_rotation_limit_over_http_and_webso
|
||||
continue;
|
||||
}
|
||||
let store = Arc::new(MemoryAccountStore::default());
|
||||
let listener = TcpListener::bind("127.0.0.1:0").await.unwrap();
|
||||
let endpoint = listener.local_addr().unwrap();
|
||||
drop(listener);
|
||||
let socket = TcpSocket::new_v4().unwrap();
|
||||
socket.bind("127.0.0.1:0".parse().unwrap()).unwrap();
|
||||
let endpoint = socket.local_addr().unwrap();
|
||||
// Linux 上保留未监听的 socket,让拨号被拒绝且并发测试无法占用端口
|
||||
// macOS 上未监听的绑定可能让拨号超时,继续使用已释放的端口
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
drop(socket);
|
||||
let proxy =
|
||||
gateway_core::account::OutboundProxy::parse(&format!("socks5h://{endpoint}"))
|
||||
.unwrap();
|
||||
|
||||
Reference in New Issue
Block a user