huskies: merge 1175 bug Flaky tests intermittently fail merge gates
This commit is contained in:
@@ -89,7 +89,15 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn find_free_port_returns_bindable_port() {
|
||||
let port = find_free_port(3100);
|
||||
// Scan from an OS-assigned ephemeral port rather than a hardcoded low
|
||||
// port. Fixed ports like 3100 are also used as scan starts elsewhere
|
||||
// in production code and tests, so a second, independent bind on a
|
||||
// fixed port can race against those under parallel test execution.
|
||||
let reservation = std::net::TcpListener::bind(("127.0.0.1", 0)).unwrap();
|
||||
let start = reservation.local_addr().unwrap().port();
|
||||
drop(reservation);
|
||||
|
||||
let port = find_free_port(start);
|
||||
// The returned port must be bindable.
|
||||
assert!(
|
||||
std::net::TcpListener::bind(("127.0.0.1", port)).is_ok(),
|
||||
|
||||
Reference in New Issue
Block a user