@@ -188,7 +188,8 @@ def test_pssh_client_auth_failure(self):
188188 client = ParallelSSHClient ([self .host ], port = listen_port ,
189189 pkey = self .user_key ,
190190 agent = self .agent )
191- self .assertRaises (AuthenticationException , client .run_command , self .fake_cmd )
191+ self .assertRaises (
192+ AuthenticationException , client .run_command , self .fake_cmd )
192193 del client
193194 server .kill ()
194195
@@ -607,7 +608,8 @@ def test_ssh_proxy_target_host_failure(self):
607608 proxy_port = proxy_server_port ,
608609 )
609610 try :
610- self .assertRaises (ConnectionErrorException , client .run_command , self .fake_cmd )
611+ self .assertRaises (
612+ ConnectionErrorException , client .run_command , self .fake_cmd )
611613 finally :
612614 del client
613615 proxy_server .kill ()
@@ -663,7 +665,8 @@ def test_ssh_proxy_auth_fail(self):
663665 num_retries = 1 ,
664666 )
665667 try :
666- self .assertRaises (AuthenticationException , client .run_command , self .fake_cmd )
668+ self .assertRaises (
669+ AuthenticationException , client .run_command , self .fake_cmd )
667670 finally :
668671 del client
669672 server .kill ()
@@ -912,7 +915,8 @@ def test_per_host_tuple_args(self):
912915 cmd , host_args = [host_args [0 ]])
913916 # Invalid number of args
914917 host_args = (('arg1' , ),)
915- self .assertRaises (TypeError , client .run_command , cmd , host_args = host_args )
918+ self .assertRaises (
919+ TypeError , client .run_command , cmd , host_args = host_args )
916920 for server in [server2 , server3 ]:
917921 server .kill ()
918922
@@ -954,7 +958,8 @@ def test_per_host_dict_args_invalid(self):
954958 cmd = 'echo %(host_arg1)s %(host_arg2)s'
955959 # Invalid number of host args
956960 host_args = [{'host_arg1' : 'arg1' }]
957- self .assertRaises (KeyError , self .client .run_command , cmd , host_args = host_args )
961+ self .assertRaises (
962+ KeyError , self .client .run_command , cmd , host_args = host_args )
958963
959964 def test_ssh_client_utf_encoding (self ):
960965 """Test that unicode output works"""
@@ -1046,5 +1051,37 @@ def test_run_command_no_shell(self):
10461051 self .assertTrue (len (stdout ) > 0 )
10471052 self .assertTrue (output [self .host ].exit_code == 0 )
10481053
1054+ def test_proxy_remote_host_failure_timeout (self ):
1055+ """Test that timeout setting is passed on to proxy to be used for the
1056+ proxy->remote host connection timeout
1057+ """
1058+ self .server .kill ()
1059+ server_timeout = 0.2
1060+ client_timeout = server_timeout - 0.1
1061+ server , listen_port = start_server_from_ip (self .host ,
1062+ timeout = server_timeout )
1063+ proxy_host = '127.0.0.2'
1064+ proxy_server , proxy_server_port = start_server_from_ip (proxy_host )
1065+ proxy_user = 'proxy_user'
1066+ proxy_password = 'fake'
1067+ client = ParallelSSHClient ([self .host ], port = listen_port ,
1068+ pkey = self .user_key ,
1069+ proxy_host = '127.0.0.2' ,
1070+ proxy_port = proxy_server_port ,
1071+ proxy_user = proxy_user ,
1072+ proxy_password = 'fake' ,
1073+ proxy_pkey = self .user_key ,
1074+ num_retries = 1 ,
1075+ timeout = client_timeout ,
1076+ )
1077+ try :
1078+ self .assertRaises (
1079+ ConnectionErrorException , client .run_command , self .fake_cmd )
1080+ finally :
1081+ del client
1082+ server .kill ()
1083+ proxy_server .kill ()
1084+
1085+
10491086if __name__ == '__main__' :
10501087 unittest .main ()
0 commit comments