@@ -6,7 +6,7 @@ use crate::{
66 socket:: Protocol ,
77 testing:: { self , Stream , MAX_DATAGRAM_SIZE } ,
88 } ,
9- testing:: { ext:: * , sim, sleep, spawn, task:: spawn_named, timeout} ,
9+ testing:: { ext:: * , sim, sleep, spawn, task:: spawn_named, timeout, without_tracing } ,
1010} ;
1111use bolero:: { produce, TypeGenerator , ValueGenerator as _} ;
1212use core:: time:: Duration ;
@@ -186,9 +186,9 @@ async fn check_read(
186186 let offset = data. offset ( ) ;
187187 let capacity = data. buffered_len ( ) ;
188188 let mut data = data. with_write_limit ( capacity. min ( max_read_len) ) ;
189- tracing:: info !( offset, capacity = data. remaining_capacity( ) , "read_into" ) ;
189+ tracing:: debug !( offset, capacity = data. remaining_capacity( ) , "read_into" ) ;
190190 let len = stream. read_into ( & mut data) . await ?;
191- tracing:: info !( len, "read_into_result" ) ;
191+ tracing:: debug !( len, "read_into_result" ) ;
192192 if len == 0 {
193193 break ;
194194 }
@@ -203,13 +203,13 @@ async fn check_write(stream: &mut Stream, delays: &Delays, amount: usize) -> io:
203203 info ! ( writing = amount) ;
204204 let mut data = Data :: new ( amount as _ ) ;
205205 while !data. is_finished ( ) {
206- tracing:: info !(
206+ tracing:: debug !(
207207 offset = data. offset( ) ,
208208 remaining = data. buffered_len( ) ,
209209 "write_from"
210210 ) ;
211211 let len = stream. write_from ( & mut data) . await ?;
212- tracing:: info !( len, "write_from_result" ) ;
212+ tracing:: debug !( len, "write_from_result" ) ;
213213 }
214214 info ! ( amount, "write_from_finished" ) ;
215215 Ok ( ( ) )
@@ -356,15 +356,19 @@ impl Harness {
356356 }
357357
358358 if is_sim {
359- // TODO limit concurrency
359+ // TODO limit concurrency - for now we just stagger clients
360360
361361 for idx in 0 ..self . client . count {
362362 let config = self . client ;
363363 let requests = requests. clone ( ) ;
364364 let client = client. clone ( ) ;
365365 let server = server. clone ( ) ;
366366 let task = async move {
367+ // delay connecting by 1us per client
368+ ( 1 . us ( ) * idx as u32 ) . sleep ( ) . await ;
369+
367370 info ! ( "connecting" ) ;
371+
368372 let stream = client. connect_to ( & server) . await . unwrap ( ) ;
369373 info ! ( peer_addr = %stream. peer_addr( ) . unwrap( ) , local_addr = %stream. local_addr( ) . unwrap( ) ) ;
370374
@@ -429,8 +433,8 @@ struct Runtime {
429433}
430434
431435impl Runtime {
432- fn new ( harness : Harness ) -> Self {
433- let rt = tokio:: runtime:: Builder :: new_multi_thread ( )
436+ fn new ( harness : & Harness ) -> Self {
437+ let rt = tokio:: runtime:: Builder :: new_current_thread ( )
434438 . enable_all ( )
435439 . build ( )
436440 . unwrap ( ) ;
@@ -452,6 +456,10 @@ impl Runtime {
452456 }
453457 }
454458
459+ fn run ( & self , harness : Harness ) {
460+ self . rt . block_on ( harness. run ( ) ) ;
461+ }
462+
455463 fn run_with ( & self , client : Client , server : Server , requests : Vec < Request > ) {
456464 let harness = Harness {
457465 client,
@@ -528,11 +536,6 @@ macro_rules! tests {
528536 $test!( multi_request_test, {
529537 let harness = harness( ) ;
530538
531- // TODO make this not flaky with UDP
532- if harness. protocol. is_udp( ) {
533- return ;
534- }
535-
536539 Harness {
537540 requests: vec![ Request {
538541 count: 10 ,
@@ -628,46 +631,54 @@ macro_rules! tests {
628631
629632macro_rules! tokio_test {
630633 ( $name: ident, $harness: expr) => {
631- #[ tokio:: test]
632- async fn $name( ) {
633- $harness. run( ) . await ;
634+ #[ test]
635+ fn $name( ) {
636+ let harness = $harness;
637+ without_tracing( || {
638+ Runtime :: new( & harness) . run( harness) ;
639+ } ) ;
634640 }
635641 } ;
636642}
637643
638644macro_rules! tokio_fuzz_test {
639645 ( ) => {
640646 #[ test]
641- #[ ignore = "TODO the CI currently doesn't like running these tests - need to figure out why" ]
642647 fn fuzz_test( ) {
643- use std:: sync:: OnceLock ;
644-
645- bolero:: check!( )
646- . with_generator( ( produce( ) , produce( ) , produce:: <Vec <_>>( ) . with( ) . len( 1 ..5 ) ) )
647- . cloned( )
648- . with_test_time( Duration :: from_secs( 45 ) )
649- . for_each( |( client, server, requests) | {
650- static RUNTIME : OnceLock <Runtime > = OnceLock :: new( ) ;
651- RUNTIME
652- . get_or_init( || Runtime :: new( harness( ) ) )
653- . run_with( client, server, requests) ;
654- } ) ;
648+ without_tracing( || {
649+ use std:: sync:: OnceLock ;
650+
651+ bolero:: check!( )
652+ . with_generator( ( produce( ) , produce( ) , produce:: <Vec <_>>( ) . with( ) . len( 1 ..5 ) ) )
653+ . cloned( )
654+ // limit the amount of time in tests since they can produce a log of tracing data
655+ . with_test_time( Duration :: from_secs( 10 ) )
656+ . for_each( |( client, server, requests) | {
657+ static RUNTIME : OnceLock <Runtime > = OnceLock :: new( ) ;
658+ RUNTIME
659+ . get_or_init( || Runtime :: new( & harness( ) ) )
660+ . run_with( client, server, requests) ;
661+ } ) ;
662+ } ) ;
655663 }
656- }
664+ } ;
657665}
658666
659667macro_rules! sim_test {
660668 ( $name: ident, $harness: expr) => {
661669 #[ test]
662670 fn $name( ) {
663- sim( || {
664- spawn_named( $harness. run( ) . primary( ) , "harness" ) ;
665-
666- async {
667- sleep( Duration :: from_secs( 120 ) ) . await ;
668- panic!( "test timed out after {}" , bach:: time:: Instant :: now( ) ) ;
669- }
670- . spawn( ) ;
671+ // The tracing logs end up consuming a bunch of memory and failing the tests
672+ without_tracing( || {
673+ sim( || {
674+ spawn_named( $harness. run( ) . primary( ) , "harness" ) ;
675+
676+ async {
677+ sleep( Duration :: from_secs( 120 ) ) . await ;
678+ panic!( "test timed out after {}" , bach:: time:: Instant :: now( ) ) ;
679+ }
680+ . spawn( ) ;
681+ } ) ;
671682 } ) ;
672683 }
673684 } ;
@@ -715,24 +726,26 @@ mod udp_sim {
715726 tests ! ( sim_test) ;
716727
717728 #[ test]
718- #[ ignore = "TODO the CI currently doesn't like running these tests - need to figure out why" ]
719729 fn fuzz_test ( ) {
720- bolero:: check!( )
721- . with_generator ( ( produce ( ) , produce ( ) , produce :: < Vec < _ > > ( ) . with ( ) . len ( 1 ..5 ) ) )
722- . cloned ( )
723- . with_test_time ( Duration :: from_secs ( 60 ) )
724- . for_each ( |( client, server, requests) | {
725- crate :: testing:: sim ( || {
726- Harness {
727- client,
728- server,
729- requests,
730- ..harness ( )
731- }
732- . run ( )
733- . primary ( )
734- . spawn ( ) ;
735- } ) ;
736- } ) ;
730+ // The tracing logs end up consuming a bunch of memory and failing the tests
731+ without_tracing ( || {
732+ bolero:: check!( )
733+ . with_generator ( ( produce ( ) , produce ( ) , produce :: < Vec < _ > > ( ) . with ( ) . len ( 1 ..5 ) ) )
734+ . cloned ( )
735+ . with_test_time ( Duration :: from_secs ( 60 ) )
736+ . for_each ( |( client, server, requests) | {
737+ crate :: testing:: sim ( || {
738+ Harness {
739+ client,
740+ server,
741+ requests,
742+ ..harness ( )
743+ }
744+ . run ( )
745+ . primary ( )
746+ . spawn ( ) ;
747+ } ) ;
748+ } )
749+ } ) ;
737750 }
738751}
0 commit comments