From 8cda974552bde3f0584457001383b63665c29400 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Sun, 12 Apr 2020 11:49:34 -0700 Subject: [PATCH] Fix flaky new_archiver_external_ip_test (#9457) automerge --- core/src/cluster_info.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/core/src/cluster_info.rs b/core/src/cluster_info.rs index 7c0dc38652..0f3e98f375 100644 --- a/core/src/cluster_info.rs +++ b/core/src/cluster_info.rs @@ -2014,20 +2014,23 @@ mod tests { #[test] fn new_archiver_external_ip_test() { + // Can't use VALIDATOR_PORT_RANGE because if this test runs in parallel with others, the + // port returned by `bind_in_range()` might be snatched up before `Node::new_with_external_ip()` runs + let port_range = (VALIDATOR_PORT_RANGE.1 + 20, VALIDATOR_PORT_RANGE.1 + 30); let ip = Ipv4Addr::from(0); let node = Node::new_archiver_with_external_ip( &Pubkey::new_rand(), &socketaddr!(ip, 0), - VALIDATOR_PORT_RANGE, + port_range, IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), ); let ip = IpAddr::V4(ip); - check_socket(&node.sockets.storage.unwrap(), ip, VALIDATOR_PORT_RANGE); - check_socket(&node.sockets.gossip, ip, VALIDATOR_PORT_RANGE); - check_socket(&node.sockets.repair, ip, VALIDATOR_PORT_RANGE); + check_socket(&node.sockets.storage.unwrap(), ip, port_range); + check_socket(&node.sockets.gossip, ip, port_range); + check_socket(&node.sockets.repair, ip, port_range); - check_sockets(&node.sockets.tvu, ip, VALIDATOR_PORT_RANGE); + check_sockets(&node.sockets.tvu, ip, port_range); } //test that all cluster_info objects only generate signed messages