29
29
import random
30
30
import logging
31
31
import gevent
32
- import threading
33
32
import paramiko
34
33
import os
35
34
import warnings
@@ -308,7 +307,7 @@ def test_pssh_client_long_running_command_exit_codes(self):
308
307
msg = "Got non-zero exit code %s" % (
309
308
output [self .host ]['exit_code' ],))
310
309
del client
311
-
310
+
312
311
def test_pssh_client_retries (self ):
313
312
"""Test connection error retries"""
314
313
listen_socket = make_socket (self .host )
@@ -327,7 +326,19 @@ def test_pssh_client_retries(self):
327
326
% (num_tries , expected_num_tries ,))
328
327
else :
329
328
raise Exception ('No ConnectionErrorException' )
330
-
329
+
330
+ def test_sftp_exceptions (self ):
331
+ self .server .kill ()
332
+ # Make socket with no server listening on it on separate ip
333
+ host = '127.0.0.3'
334
+ _socket = make_socket (host )
335
+ port = _socket .getsockname ()[1 ]
336
+ client = ParallelSSHClient ([self .host ], port = port , num_retries = 1 )
337
+ cmds = client .copy_file ("test" , "test" )
338
+ client .pool .join ()
339
+ for cmd in cmds :
340
+ self .assertRaises (ConnectionErrorException , cmd .get )
341
+
331
342
def test_pssh_copy_file (self ):
332
343
"""Test parallel copy file"""
333
344
test_file_data = 'test'
@@ -348,7 +359,7 @@ def test_pssh_copy_file(self):
348
359
for filepath in [local_filename , remote_filename ]:
349
360
os .unlink (filepath )
350
361
del client
351
-
362
+
352
363
def test_pssh_client_directory (self ):
353
364
"""Tests copying directories with SSH client. Copy all the files from
354
365
local directory to server, then make sure they are all present."""
@@ -378,7 +389,7 @@ def test_pssh_client_directory(self):
378
389
self .assertTrue (os .path .isfile (path ))
379
390
shutil .rmtree (local_test_path )
380
391
shutil .rmtree (remote_test_path )
381
-
392
+
382
393
def test_pssh_pool_size (self ):
383
394
"""Test setting pool size to non default values"""
384
395
hosts = ['host-%01d' % d for d in xrange (5 )]
0 commit comments