Skip to content

Commit

Permalink
Fix sporadic connect failure in Linux tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Brendan McMillion authored and vkrasnov committed Oct 28, 2020
1 parent ccadcf9 commit bbe37c0
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/device/integration_tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,24 @@ mod tests {
self.container_name = Some(peer_config_file);
}

fn get_request(&self) -> String {
fn connect(&self) -> std::net::TcpStream {
let http_addr = SocketAddr::new(self.allowed_ips[0].ip, 80);
let mut tcp_conn = std::net::TcpStream::connect(http_addr).unwrap();
for _i in 0..5 {
let res = std::net::TcpStream::connect(http_addr);
if let Err(err) = res {
println!("failed to connect: {:?}", err);
std::thread::sleep(std::time::Duration::from_millis(100));
continue;
}

return res.unwrap();
}

panic!("failed to connect");
}

fn get_request(&self) -> String {
let mut tcp_conn = self.connect();

write!(
tcp_conn,
Expand Down

0 comments on commit bbe37c0

Please sign in to comment.