From b7e19134b8706b0497bdcd02c3f620f3d5b319b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Tue, 18 Apr 2023 23:22:47 +0200 Subject: test: fix flaky tcp tests (#18755) https://github.com/denoland/deno/actions/runs/4734473301/jobs/8403453096?pr=18749 --- ext/net/ops.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'ext') diff --git a/ext/net/ops.rs b/ext/net/ops.rs index a9f038ecc..115e0518d 100644 --- a/ext/net/ops.rs +++ b/ext/net/ops.rs @@ -786,6 +786,8 @@ mod tests { use std::net::Ipv4Addr; use std::net::Ipv6Addr; use std::path::Path; + use std::sync::Arc; + use std::sync::Mutex; use trust_dns_proto::rr::rdata::caa::KeyValue; use trust_dns_proto::rr::rdata::caa::CAA; use trust_dns_proto::rr::rdata::mx::MX; @@ -1009,7 +1011,7 @@ mod tests { assert!(socket.nodelay().unwrap()); assert!(!socket.keepalive().unwrap()); }); - check_sockopt(String::from("127.0.0.1:4245"), set_nodelay, test_fn).await; + check_sockopt(String::from("127.0.0.1:4145"), set_nodelay, test_fn).await; } #[tokio::test(flavor = "multi_thread", worker_threads = 1)] @@ -1021,7 +1023,7 @@ mod tests { assert!(!socket.nodelay().unwrap()); assert!(socket.keepalive().unwrap()); }); - check_sockopt(String::from("127.0.0.1:4246"), set_keepalive, test_fn).await; + check_sockopt(String::from("127.0.0.1:4146"), set_keepalive, test_fn).await; } #[allow(clippy::type_complexity)] @@ -1030,10 +1032,12 @@ mod tests { set_sockopt_fn: Box, test_fn: Box, ) { + let sockets = Arc::new(Mutex::new(vec![])); let clone_addr = addr.clone(); tokio::spawn(async move { let listener = TcpListener::bind(addr).await.unwrap(); - let _ = listener.accept().await.unwrap(); + let socket = listener.accept().await.unwrap(); + sockets.lock().unwrap().push(socket); }); deno_core::extension!( -- cgit v1.2.3