#NEWLINE# def test_ssh_command_terminate_async( sshd_manager , loop ) : #NEWLINE# #INDENT# with sshd_manager . run ( 1 ) as sshd_ports : #NEWLINE# #INDENT# workspace = str ( sshd_manager . tmpdir ) #NEWLINE# runner = MultiRunner ( [ '127.0.0.1:{}' . format ( port ) for port in sshd_ports ] , ssh_user = getpass . getuser ( ) , ssh_key_path = sshd_manager . key_path , process_timeout = 2 ) #NEWLINE# chain = CommandChain ( 'test' ) #NEWLINE# chain . add_execute ( [ 'sleep' , '20' ] ) #NEWLINE# start_time = time . time ( ) #NEWLINE# try : #NEWLINE# #INDENT# results = loop . run_until_complete ( runner . run_commands_chain_async ( [ chain ] , block = True , state_json_dir = workspace ) ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# loop . close ( ) #NEWLINE# #UNINDENT# elapsed_time = ( time . time ( ) - start_time ) #NEWLINE# assert ( elapsed_time < 5 ) #NEWLINE# assert os . path . isfile ( ( workspace + '/test.json' ) ) #NEWLINE# with open ( ( workspace + '/test.json' ) ) as fh : #NEWLINE# #INDENT# result_json = json . load ( fh ) #NEWLINE# assert ( result_json [ 'total_hosts' ] == 1 ) #NEWLINE# assert ( 'hosts_failed' not in result_json ) #NEWLINE# assert ( 'hosts_success' not in result_json ) #NEWLINE# #UNINDENT# for host_result in results : #NEWLINE# #INDENT# for command_result in host_result : #NEWLINE# #INDENT# for ( host , process_result ) in command_result . items ( ) : #NEWLINE# #INDENT# assert ( result_json [ 'hosts' ] [ host ] [ 'host_status' ] == 'terminated' ) #NEWLINE# assert ( process_result [ 'stdout' ] == [ '' ] ) #NEWLINE# assert ( process_result [ 'stderr' ] == [ '' ] ) #NEWLINE# assert ( process_result [ 'returncode' ] is None )