Skip to content

Commit

Permalink
Fix nginx race
Browse files Browse the repository at this point in the history
NGINX was also returning before binding to the port, sometimes leading to
port contention with other test services
  • Loading branch information
DanGould committed Dec 30, 2024
1 parent 9cbec68 commit e591dd5
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,15 @@ mod integration {
.spawn()
.expect("Failed to start nginx");

let start = std::time::Instant::now();
let timeout = std::time::Duration::from_secs(5);
while start.elapsed() < timeout {
if let Ok(_) = std::net::TcpStream::connect(format!("127.0.0.1:{}", n_https_port)) {
break;
}
tokio::time::sleep(std::time::Duration::from_millis(100)).await;
}

// Keep the config file open as long as NGINX is using it
std::mem::forget(config_file);

Expand Down

0 comments on commit e591dd5

Please sign in to comment.