#NEWLINE# def test_tags_async( sshd_manager , loop ) : #NEWLINE# #INDENT# with sshd_manager . run ( 1 ) as sshd_ports : #NEWLINE# #INDENT# workspace = str ( sshd_manager . tmpdir ) #NEWLINE# host_ports = [ '127.0.0.1:{}' . format ( port ) for port in sshd_ports ] #NEWLINE# targets = [ ] #NEWLINE# for _port in sshd_ports : #NEWLINE# #INDENT# _host = Node ( '127.0.0.1:{}' . format ( _port ) , { #NEWLINE# #INDENT# 'tag1' : 'test1' , #NEWLINE# 'tag2' : 'test2' , #NEWLINE# #UNINDENT# } ) #NEWLINE# targets . append ( _host ) #NEWLINE# #UNINDENT# runner = MultiRunner ( targets , ssh_user = getpass . getuser ( ) , ssh_key_path = ( workspace + '/host_key' ) ) #NEWLINE# chain = CommandChain ( 'test' ) #NEWLINE# chain . add_execute ( [ 'sleep' , '1' ] ) #NEWLINE# try : #NEWLINE# #INDENT# 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# with open ( ( workspace + '/test.json' ) ) as fh : #NEWLINE# #INDENT# result_json = json . load ( fh ) #NEWLINE# for host_port in host_ports : #NEWLINE# #INDENT# assert ( 'tags' in result_json [ 'hosts' ] [ host_port ] ) #NEWLINE# assert ( len ( result_json [ 'hosts' ] [ host_port ] [ 'tags' ] ) == 2 ) #NEWLINE# assert ( result_json [ 'hosts' ] [ host_port ] [ 'tags' ] [ 'tag1' ] == 'test1' ) #NEWLINE# assert ( result_json [ 'hosts' ] [ host_port ] [ 'tags' ] [ 'tag2' ] == 'test2' ) #NEWLINE# assert ( result_json [ 'hosts' ] [ host_port ] [ 'commands' ] [ 0 ] [ 'cmd' ] == [ '/usr/bin/ssh' , '-oConnectTimeout=10' , '-oStrictHostKeyChecking=no' , '-oUserKnownHostsFile=/dev/null' , '-oBatchMode=yes' , '-oPasswordAuthentication=no' , '-p{}' . format ( sshd_ports [ 0 ] ) , '-i' , '{}/host_key' . format ( workspace ) , '-tt' , '{}@127.0.0.1' . format ( getpass . getuser ( ) ) , 'sleep' , '1' ] )