From 3ad8f017412ef0ec3a378b49ebde85af03a65612 Mon Sep 17 00:00:00 2001 From: Luca Cominardi Date: Thu, 7 Nov 2024 10:52:20 +0100 Subject: [PATCH 1/3] Add fragmentation test --- io/zenoh-transport/tests/unicast_fragmentation.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/io/zenoh-transport/tests/unicast_fragmentation.rs b/io/zenoh-transport/tests/unicast_fragmentation.rs index 5fdabf2b2d..29cf9f8b09 100644 --- a/io/zenoh-transport/tests/unicast_fragmentation.rs +++ b/io/zenoh-transport/tests/unicast_fragmentation.rs @@ -122,6 +122,7 @@ impl TransportPeerEventHandler for SCRouter { fn handle_message(&self, message: NetworkMessage) -> ZResult<()> { assert_eq!(message, *MSG); self.count.fetch_add(1, Ordering::SeqCst); + std::thread::sleep(2 * SLEEP_SEND); Ok(()) } @@ -289,9 +290,9 @@ async fn test_transport(router_handler: Arc, client_transport: Transpo ztimeout!(async { let mut sent = 0; while router_handler.get_count() < MSG_COUNT { - let _ = client_transport.schedule(MSG.clone()); + client_transport.schedule(MSG.clone()).unwrap(); sent += 1; - tokio::time::sleep(SLEEP_SEND).await; + // tokio::time::sleep(SLEEP_SEND).await; } println!( "Sent: {sent}. Received: {}/{MSG_COUNT}", From f4b4cadddc57f6b48f82262f1e0d8ea672bcdfd4 Mon Sep 17 00:00:00 2001 From: Luca Cominardi Date: Thu, 7 Nov 2024 11:09:46 +0100 Subject: [PATCH 2/3] Improve logging for CI --- io/zenoh-transport/tests/unicast_fragmentation.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/io/zenoh-transport/tests/unicast_fragmentation.rs b/io/zenoh-transport/tests/unicast_fragmentation.rs index 29cf9f8b09..ad62dcb655 100644 --- a/io/zenoh-transport/tests/unicast_fragmentation.rs +++ b/io/zenoh-transport/tests/unicast_fragmentation.rs @@ -45,7 +45,7 @@ const TIMEOUT: Duration = Duration::from_secs(60); const SLEEP: Duration = Duration::from_secs(1); const SLEEP_SEND: Duration = Duration::from_millis(1); -const MSG_COUNT: usize = 1_000; +const MSG_COUNT: usize = 100; lazy_static! { #[derive(Debug)] static ref MSG: NetworkMessage = Push { @@ -292,12 +292,12 @@ async fn test_transport(router_handler: Arc, client_transport: Transpo while router_handler.get_count() < MSG_COUNT { client_transport.schedule(MSG.clone()).unwrap(); sent += 1; + println!( + "Sent: {sent}. Received: {}/{MSG_COUNT}", + router_handler.get_count() + ); // tokio::time::sleep(SLEEP_SEND).await; } - println!( - "Sent: {sent}. Received: {}/{MSG_COUNT}", - router_handler.get_count() - ); }); // Wait a little bit From 694e3fae9e05340e3ead5bcdcc9d3147e4e21107 Mon Sep 17 00:00:00 2001 From: Luca Cominardi Date: Thu, 7 Nov 2024 11:42:49 +0100 Subject: [PATCH 3/3] Don't unwrap on schedule error in fragmentation test --- io/zenoh-transport/tests/unicast_fragmentation.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/io/zenoh-transport/tests/unicast_fragmentation.rs b/io/zenoh-transport/tests/unicast_fragmentation.rs index ad62dcb655..f45e65702a 100644 --- a/io/zenoh-transport/tests/unicast_fragmentation.rs +++ b/io/zenoh-transport/tests/unicast_fragmentation.rs @@ -290,13 +290,13 @@ async fn test_transport(router_handler: Arc, client_transport: Transpo ztimeout!(async { let mut sent = 0; while router_handler.get_count() < MSG_COUNT { - client_transport.schedule(MSG.clone()).unwrap(); - sent += 1; - println!( - "Sent: {sent}. Received: {}/{MSG_COUNT}", - router_handler.get_count() - ); - // tokio::time::sleep(SLEEP_SEND).await; + if client_transport.schedule(MSG.clone()).is_ok() { + sent += 1; + println!( + "Sent: {sent}. Received: {}/{MSG_COUNT}", + router_handler.get_count() + ); + } } });