@@ -1294,7 +1294,9 @@ pub fn get_exclusive_local_address() -> IpAddr {
12941294mod tests {
12951295 use super :: * ;
12961296 use crate :: frame:: { read_frame, read_request_frame, FrameType } ;
1297- use crate :: { Condition , Reaction as _, RequestReaction , ResponseOpcode , ResponseReaction } ;
1297+ use crate :: {
1298+ setup_tracing, Condition , Reaction as _, RequestReaction , ResponseOpcode , ResponseReaction ,
1299+ } ;
12981300 use assert_matches:: assert_matches;
12991301 use bytes:: { BufMut , BytesMut } ;
13001302 use futures:: future:: { join, join3} ;
@@ -1308,15 +1310,6 @@ mod tests {
13081310 use tokio:: io:: { AsyncReadExt as _, AsyncWriteExt as _} ;
13091311 use tokio:: sync:: oneshot;
13101312
1311- // This is for convenient logs from failing tests. Just call it at the beginning of a test.
1312- #[ allow( unused) ]
1313- fn init_logger ( ) {
1314- let _ = tracing_subscriber:: fmt:: fmt ( )
1315- . with_env_filter ( tracing_subscriber:: EnvFilter :: from_default_env ( ) )
1316- . without_time ( )
1317- . try_init ( ) ;
1318- }
1319-
13201313 fn random_body ( ) -> Bytes {
13211314 let body_len = ( rand:: random :: < u32 > ( ) % 1000 ) as usize ;
13221315 let mut body = BytesMut :: zeroed ( body_len) ;
@@ -1437,19 +1430,21 @@ mod tests {
14371430 #[ tokio:: test]
14381431 #[ ntest:: timeout( 1000 ) ]
14391432 async fn identity_shard_unaware_proxy_does_not_mutate_frames ( ) {
1433+ setup_tracing ( ) ;
14401434 identity_proxy_does_not_mutate_frames ( ShardAwareness :: Unaware ) . await
14411435 }
14421436
14431437 #[ tokio:: test]
14441438 #[ ntest:: timeout( 1000 ) ]
14451439 async fn identity_shard_aware_proxy_does_not_mutate_frames ( ) {
1446- init_logger ( ) ;
1440+ setup_tracing ( ) ;
14471441 identity_proxy_does_not_mutate_frames ( ShardAwareness :: QueryNode ) . await
14481442 }
14491443
14501444 #[ tokio:: test]
14511445 #[ ntest:: timeout( 1000 ) ]
14521446 async fn shard_aware_proxy_is_transparent_for_connection_to_shards ( ) {
1447+ setup_tracing ( ) ;
14531448 async fn test_for_shards_num ( shards_num : u16 ) {
14541449 let node1_real_addr = next_local_address_with_port ( 9876 ) ;
14551450 let node1_proxy_addr = next_local_address_with_port ( 9876 ) ;
@@ -1499,6 +1494,7 @@ mod tests {
14991494 #[ tokio:: test]
15001495 #[ ntest:: timeout( 1000 ) ]
15011496 async fn shard_aware_proxy_queries_shards_number ( ) {
1497+ setup_tracing ( ) ;
15021498 async fn test_for_shards_num ( shards_num : u16 ) {
15031499 for shard_num in 0 ..shards_num {
15041500 let node1_real_addr = next_local_address_with_port ( 9876 ) ;
@@ -1554,6 +1550,7 @@ mod tests {
15541550 #[ tokio:: test]
15551551 #[ ntest:: timeout( 1000 ) ]
15561552 async fn forger_proxy_forges_response ( ) {
1553+ setup_tracing ( ) ;
15571554 let node1_real_addr = next_local_address_with_port ( 9876 ) ;
15581555 let node1_proxy_addr = next_local_address_with_port ( 9876 ) ;
15591556
@@ -1685,6 +1682,7 @@ mod tests {
16851682 #[ tokio:: test]
16861683 #[ ntest:: timeout( 1000 ) ]
16871684 async fn ad_hoc_rules_changing ( ) {
1685+ setup_tracing ( ) ;
16881686 let node1_real_addr = next_local_address_with_port ( 9876 ) ;
16891687 let node1_proxy_addr = next_local_address_with_port ( 9876 ) ;
16901688 let proxy = Proxy :: new ( [ Node :: new (
@@ -1779,6 +1777,7 @@ mod tests {
17791777 #[ tokio:: test]
17801778 #[ ntest:: timeout( 2000 ) ]
17811779 async fn limited_times_condition_expires ( ) {
1780+ setup_tracing ( ) ;
17821781 const FAILING_TRIES : usize = 4 ;
17831782 const PASSING_TRIES : usize = 5 ;
17841783
@@ -1880,6 +1879,7 @@ mod tests {
18801879 #[ tokio:: test]
18811880 #[ ntest:: timeout( 1000 ) ]
18821881 async fn proxy_reports_requests_and_responses_as_feedback ( ) {
1882+ setup_tracing ( ) ;
18831883 let node1_real_addr = next_local_address_with_port ( 9876 ) ;
18841884 let node1_proxy_addr = next_local_address_with_port ( 9876 ) ;
18851885
@@ -1952,6 +1952,7 @@ mod tests {
19521952 #[ tokio:: test]
19531953 #[ ntest:: timeout( 1000 ) ]
19541954 async fn sanity_check_reports_errors ( ) {
1955+ setup_tracing ( ) ;
19551956 let node1_real_addr = next_local_address_with_port ( 9876 ) ;
19561957 let node1_proxy_addr = next_local_address_with_port ( 9876 ) ;
19571958 let proxy = Proxy :: new ( [ Node :: new (
@@ -2002,7 +2003,7 @@ mod tests {
20022003 #[ tokio:: test]
20032004 #[ ntest:: timeout( 1000 ) ]
20042005 async fn proxy_processes_requests_concurrently ( ) {
2005- init_logger ( ) ;
2006+ setup_tracing ( ) ;
20062007 let node1_real_addr = next_local_address_with_port ( 9876 ) ;
20072008 let node1_proxy_addr = next_local_address_with_port ( 9876 ) ;
20082009
@@ -2076,6 +2077,7 @@ mod tests {
20762077 #[ tokio:: test]
20772078 #[ ntest:: timeout( 1000 ) ]
20782079 async fn dry_mode_proxy_drops_incoming_frames ( ) {
2080+ setup_tracing ( ) ;
20792081 let node1_proxy_addr = next_local_address_with_port ( 9876 ) ;
20802082 let proxy = Proxy :: new ( [ Node :: new_dry_mode ( node1_proxy_addr, None ) ] ) ;
20812083 let running_proxy = proxy. run ( ) . await . unwrap ( ) ;
@@ -2100,6 +2102,7 @@ mod tests {
21002102 #[ tokio:: test]
21012103 #[ ntest:: timeout( 1000 ) ]
21022104 async fn dry_mode_forger_proxy_forges_response ( ) {
2105+ setup_tracing ( ) ;
21032106 let node1_proxy_addr = next_local_address_with_port ( 9876 ) ;
21042107
21052108 let this_shall_pass = b"This.Shall.Pass." ;
@@ -2207,7 +2210,7 @@ mod tests {
22072210 #[ tokio:: test]
22082211 #[ ntest:: timeout( 1000 ) ]
22092212 async fn proxy_reports_target_shard_as_feedback ( ) {
2210- init_logger ( ) ;
2213+ setup_tracing ( ) ;
22112214
22122215 let node_port = 10101 ;
22132216 let node_real_addr = next_local_address_with_port ( node_port) ;
@@ -2355,6 +2358,7 @@ mod tests {
23552358 #[ tokio:: test]
23562359 #[ ntest:: timeout( 1000 ) ]
23572360 async fn proxy_ignores_control_connection_messages ( ) {
2361+ setup_tracing ( ) ;
23582362 let node1_real_addr = next_local_address_with_port ( 9876 ) ;
23592363 let node1_proxy_addr = next_local_address_with_port ( 9876 ) ;
23602364
0 commit comments