@@ -68,13 +68,6 @@ def tearDown(self):
6868 del self .listen_socket
6969 del self .client
7070
71- def test_pssh_client_exec_command (self ):
72- cmd = self .client .exec_command (self .fake_cmd )[0 ]
73- output = self .client .get_stdout (cmd )
74- self .assertTrue (self .host in output ,
75- msg = "No output for host" )
76- self .assertTrue (output [self .host ]['exit_code' ] == 0 )
77-
7871 def test_pssh_client_no_stdout_non_zero_exit_code_immediate_exit (self ):
7972 output = self .client .run_command ('exit 1' )
8073 expected_exit_code = 1
@@ -85,31 +78,6 @@ def test_pssh_client_no_stdout_non_zero_exit_code_immediate_exit(self):
8578 (exit_code ,
8679 expected_exit_code ,))
8780
88- def test_pssh_client_exec_command_get_buffers (self ):
89- client = ParallelSSHClient ([self .host ], port = self .listen_port ,
90- pkey = self .user_key ,
91- agent = self .agent )
92- cmd = client .exec_command (self .fake_cmd )[0 ]
93- output = client .get_stdout (cmd , return_buffers = True )
94- expected_exit_code = 0
95- expected_stdout = [self .fake_resp ]
96- expected_stderr = []
97- exit_code = output [self .host ]['exit_code' ]
98- stdout = list (output [self .host ]['stdout' ])
99- stderr = list (output [self .host ]['stderr' ])
100- self .assertEqual (expected_exit_code , exit_code ,
101- msg = "Got unexpected exit code - %s, expected %s" %
102- (exit_code ,
103- expected_exit_code ,))
104- self .assertEqual (expected_stdout , stdout ,
105- msg = "Got unexpected stdout - %s, expected %s" %
106- (stdout ,
107- expected_stdout ,))
108- self .assertEqual (expected_stderr , stderr ,
109- msg = "Got unexpected stderr - %s, expected %s" %
110- (stderr ,
111- expected_stderr ,))
112-
11381 def test_pssh_client_run_command_get_output (self ):
11482 client = ParallelSSHClient ([self .host ], port = self .listen_port ,
11583 pkey = self .user_key ,
@@ -175,21 +143,15 @@ def test_pssh_client_run_long_command(self):
175143 del client
176144
177145 def test_pssh_client_auth_failure (self ):
178- listen_socket = make_socket (self .host )
179- listen_port = listen_socket .getsockname ()[1 ]
180- server = start_server (listen_socket , fail_auth = True )
146+ self .server .kill ()
147+ server_socket = make_socket (self .host )
148+ listen_port = server_socket .getsockname ()[1 ]
149+ server = start_server (server_socket , fail_auth = True )
181150 client = ParallelSSHClient ([self .host ], port = listen_port ,
182151 pkey = self .user_key ,
183152 agent = self .agent )
184- cmd = client .exec_command (self .fake_cmd )[0 ]
185- # Handle exception
186- try :
187- cmd .get ()
188- raise Exception ("Expected AuthenticationException, got none" )
189- except AuthenticationException :
190- pass
153+ self .assertRaises (AuthenticationException , client .run_command , self .fake_cmd )
191154 del client
192- server .kill ()
193155
194156 def test_pssh_client_hosts_list_part_failure (self ):
195157 """Test getting output for remainder of host list in the case where one
@@ -238,6 +200,7 @@ def test_pssh_client_ssh_exception(self):
238200 server .kill ()
239201
240202 def test_pssh_client_timeout (self ):
203+ self .server .kill ()
241204 listen_socket = make_socket (self .host )
242205 listen_port = listen_socket .getsockname ()[1 ]
243206 server_timeout = 0.2
@@ -258,40 +221,23 @@ def test_pssh_client_timeout(self):
258221 raise server .exception
259222 except gevent .Timeout :
260223 pass
261- # chan_timeout = output[self.host]['channel'].gettimeout()
262- # self.assertEqual(client_timeout, chan_timeout,
263- # msg="Channel timeout %s does not match requested timeout %s" %(
264- # chan_timeout, client_timeout,))
265224 del client
266225 server .kill ()
267226
268- def test_pssh_client_exec_command_password (self ):
227+ def test_pssh_client_run_command_password (self ):
269228 """Test password authentication. Embedded server accepts any password
270229 even empty string"""
271230 client = ParallelSSHClient ([self .host ], port = self .listen_port ,
272231 password = '' )
273- cmd = client .exec_command (self .fake_cmd )[ 0 ]
274- output = client .get_stdout ( cmd )
232+ output = client .run_command (self .fake_cmd )
233+ client .join ( output )
275234 self .assertTrue (self .host in output ,
276235 msg = "No output for host" )
277236 self .assertTrue (output [self .host ]['exit_code' ] == 0 ,
278237 msg = "Expected exit code 0, got %s" % (
279238 output [self .host ]['exit_code' ],))
280239 del client
281240
282- def test_pssh_client_long_running_command (self ):
283- expected_lines = 5
284- client = ParallelSSHClient ([self .host ], port = self .listen_port ,
285- pkey = self .user_key )
286- cmd = client .exec_command (self .long_cmd (expected_lines ))[0 ]
287- output = client .get_stdout (cmd , return_buffers = True )
288- self .assertTrue (self .host in output , msg = "Got no output for command" )
289- stdout = list (output [self .host ]['stdout' ])
290- self .assertTrue (len (stdout ) == expected_lines ,
291- msg = "Expected %s lines of response, got %s" % (
292- expected_lines , len (stdout )))
293- del client
294-
295241 def test_pssh_client_long_running_command_exit_codes (self ):
296242 expected_lines = 5
297243 client = ParallelSSHClient ([self .host ], port = self .listen_port ,
0 commit comments