88from fake_server .fake_server import listen , make_socket , logger as server_logger
99import random
1010import logging
11+ import gevent
12+ import threading
1113
1214_setup_logger (server_logger )
1315
@@ -22,20 +24,17 @@ def setUp(self):
2224 def cleanUp (self ):
2325 del self .listener
2426
25- def test_pssh_client_exec_command (self ):
26- server = listen ({ self .fake_cmd : self .fake_resp }, self .listener )
27+ def _run_client_exec_command (self ):
2728 client = ParallelSSHClient (['localhost' ], port = self .listen_port )
2829 cmd = client .exec_command (self .fake_cmd )[0 ]
2930 output = client .get_stdout (cmd )
3031 expected = {'localhost' : {'exit_code' : 0 }}
3132 self .assertEqual (expected , output ,
3233 msg = "Got unexpected command output - %s" % (output ,))
34+ gevent .sleep (0 )
3335 del client
34- server .join ()
3536
36- def test_pssh_client_auth_failure (self ):
37- server = listen ({ self .fake_cmd : self .fake_resp },
38- self .listener , fail_auth = True )
37+ def _run_client_fail_auth (self ):
3938 client = ParallelSSHClient (['localhost' ], port = self .listen_port )
4039 cmd = client .exec_command (self .fake_cmd )[0 ]
4140 # Handle exception
@@ -45,4 +44,18 @@ def test_pssh_client_auth_failure(self):
4544 except AuthenticationException :
4645 pass
4746 del client
47+
48+ def test_pssh_client_exec_command (self ):
49+ server = listen ({ self .fake_cmd : self .fake_resp }, self .listener )
50+ client = threading .Thread (target = self ._run_client_exec_command )
51+ client .start ()
52+ client .join ()
53+ server .join ()
54+
55+ def test_pssh_client_auth_failure (self ):
56+ server = listen ({ self .fake_cmd : self .fake_resp },
57+ self .listener , fail_auth = True )
58+ client = threading .Thread (target = self ._run_client_fail_auth )
59+ client .start ()
60+ client .join ()
4861 server .join ()
0 commit comments