@@ -231,7 +231,7 @@ def test_pssh_client_exec_command_password(self):
231
231
msg = "Got unexpected command output - %s" % (output ,))
232
232
del client
233
233
server .join ()
234
-
234
+
235
235
def test_pssh_client_long_running_command (self ):
236
236
expected_lines = 5
237
237
server = start_server ({ self .long_running_cmd :
@@ -314,8 +314,32 @@ def test_pssh_pool_size(self):
314
314
def test_pssh_hosts_more_than_pool_size (self ):
315
315
"""Test we can successfully run on more hosts than our pool size and
316
316
get logs for all hosts"""
317
- raise NotImplementedError
318
-
317
+ # Make a second server on the same port as the first one
318
+ server2_socket = make_socket ('127.0.0.2' , port = self .listen_port )
319
+ server2_port = server2_socket .getsockname ()[1 ]
320
+ server1 = start_server ({ self .fake_cmd : self .fake_resp },
321
+ self .listen_socket )
322
+ server2 = start_server ({ self .fake_cmd : self .fake_resp },
323
+ server2_socket )
324
+ hosts = ['127.0.0.1' , '127.0.0.2' ]
325
+ client = ParallelSSHClient (hosts ,
326
+ port = self .listen_port ,
327
+ pkey = self .user_key ,
328
+ pool_size = 1 ,
329
+ )
330
+ output = client .run_command (self .fake_cmd )
331
+ stdout = [list (output [k ]['stdout' ]) for k in output ]
332
+ expected_stdout = [[self .fake_resp ], [self .fake_resp ]]
333
+ self .assertEqual (len (hosts ), len (output ),
334
+ msg = "Did not get output from all hosts. Got output for \
335
+ %s/%s hosts" % (len (output ), len (hosts ),))
336
+ self .assertEqual (expected_stdout , stdout ,
337
+ msg = "Did not get expected output from all hosts. \
338
+ Got %s - expected %s" % (stdout , expected_stdout ,))
339
+ del client
340
+ server1 .kill ()
341
+ server2 .kill ()
342
+
319
343
def test_ssh_proxy (self ):
320
344
"""Test connecting to remote destination via SSH proxy
321
345
client -> proxy -> destination
0 commit comments