@@ -18,8 +18,9 @@ use torrust_tracker_deployer_lib::adapters::ssh::{
1818} ;
1919use torrust_tracker_deployer_lib:: shared:: Username ;
2020use torrust_tracker_deployer_lib:: testing:: integration:: ssh_server:: {
21- MockSshServerContainer , RealSshServerContainer ,
21+ print_docker_debug_info , MockSshServerContainer , RealSshServerContainer ,
2222} ;
23+ use torrust_tracker_deployer_lib:: testing:: network:: PortChecker ;
2324
2425/// SSH test constants following testing conventions
2526///
@@ -183,9 +184,23 @@ pub async fn assert_connectivity_succeeds_eventually(client: &SshClient, max_sec
183184 // Use the built-in wait_for_connectivity method
184185 let result = test_client. wait_for_connectivity ( ) . await ;
185186
186- assert ! (
187- result. is_ok( ) ,
188- "Expected connectivity to succeed eventually within {max_seconds}s, but got error: {:?}" ,
189- result. err( )
190- ) ;
187+ if let Err ( error) = result {
188+ let socket_addr = test_client. ssh_config ( ) . socket_addr ;
189+ let tcp_probe_result = PortChecker :: new ( ) . is_port_open ( socket_addr) ;
190+ let one_shot_ssh_result = test_client. test_connectivity ( ) ;
191+
192+ eprintln ! (
193+ "\n === SSH Connectivity Failure Diagnostics ===\n \
194+ target: {socket_addr}\n \
195+ retry_window_secs: {max_seconds}\n \
196+ raw_tcp_port_open: {tcp_probe_result:?}\n \
197+ one_shot_ssh_connectivity: {one_shot_ssh_result:?}\n "
198+ ) ;
199+
200+ print_docker_debug_info ( socket_addr. port ( ) ) ;
201+
202+ panic ! (
203+ "Expected connectivity to succeed eventually within {max_seconds}s, but got error: {error:?}"
204+ ) ;
205+ }
191206}
0 commit comments