Skip to content

Commit 8b626dd

Browse files
Test UserTerraphim AI
andcommitted
fix(tests): use portpicker for ephemeral port in default_role_integration_test
Hardcoded port 8085 caused intermittent "Address already in use (os error 98)" failures when the OS had not yet released the port from a prior test run. Replace with portpicker::pick_unused_port() following the pattern already used in tests/server.rs. portpicker is already a crate dependency. Refs #2947 Co-Authored-By: Terraphim AI <noreply@terraphim.ai>
1 parent 131a41f commit 8b626dd

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

terraphim_server/tests/default_role_integration_test.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,9 @@ async fn test_default_role_ripgrep_integration() {
115115
log::info!("✅ Default role configuration validated");
116116
log::info!(" - Ripgrep haystack: {}", ripgrep_haystack.location);
117117

118-
// Start server on a test port
119-
let server_addr = "127.0.0.1:8085".parse().unwrap();
118+
// Start server on an ephemeral port to avoid address-already-in-use conflicts
119+
let port = portpicker::pick_unused_port().expect("No unused ports available");
120+
let server_addr: std::net::SocketAddr = ([127, 0, 0, 1], port).into();
120121
let server_handle = tokio::spawn(async move {
121122
if let Err(e) = axum_server(server_addr, config_state).await {
122123
log::error!("Server error: {:?}", e);
@@ -129,7 +130,7 @@ async fn test_default_role_ripgrep_integration() {
129130

130131
let client = terraphim_service::http_client::create_default_client()
131132
.expect("Failed to create HTTP client");
132-
let base_url = "http://127.0.0.1:8085";
133+
let base_url = format!("http://127.0.0.1:{}", port);
133134

134135
// Test 1: Health check
135136
log::info!("🔍 Testing server health...");

0 commit comments

Comments
 (0)