<s> from testtools import content as test_content <EOL> import tempest . cloudscaling . base as base <EOL> import tempest . cloudscaling . thirdparty . scenario . aws_compat . base as aws_base <EOL> from tempest . common . utils . linux import remote_client <EOL> from tempest import test <EOL> import logging <EOL> logging . getLogger ( '<STR_LIT>' ) . setLevel ( logging . CRITICAL ) <EOL> LOG = logging . getLogger ( __name__ ) <EOL> class UnixBenchTest ( base . BaseBenchmarkTest , aws_base . BaseAWSTest ) : <EOL> """<STR_LIT>""" <EOL> @ classmethod <EOL> @ test . safe_setup <EOL> def setUpClass ( cls ) : <EOL> super ( UnixBenchTest , cls ) . setUpClass ( ) <EOL> cls . _load_benchmark_data ( "<STR_LIT>" ) <EOL> cfg = cls . config . cloudscaling <EOL> image_name = cfg . general_image_name <EOL> cls . ssh_user = cfg . general_ssh_user_name <EOL> cls . image_id = cls . _prepare_image_id ( image_name ) <EOL> cls . keypair = cls . _prepare_key_pair ( ) <EOL> sg = cls . _prepare_security_group ( ) <EOL> cls . sec_group_name = sg . name <EOL> reservation = cls . ec2_client . run_instances ( cls . image_id , <EOL> instance_type = cls . instance_type , <EOL> key_name = cls . keypair . name , <EOL> security_groups = ( cls . sec_group_name , ) ) <EOL> cls . addResourceCleanUp ( cls . destroy_reservation , reservation ) <EOL> cls . instance = reservation . instances [ <NUM_LIT:0> ] <EOL> LOG . info ( "<STR_LIT>" , cls . instance . state ) <EOL> cls . _wait_instance_state ( cls . instance , "<STR_LIT>" ) <EOL> cls . _prepare_public_ip ( cls . instance ) <EOL> ip_address = cls . _prepare_public_ip ( cls . instance ) <EOL> cls . ssh = remote_client . RemoteClient ( ip_address , <EOL> cls . ssh_user , <EOL> pkey = cls . keypair . material ) <EOL> @ test . attr ( type = '<STR_LIT>' ) <EOL> def test_run_benchmark ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . ssh is None : <EOL> raise self . skipException ( "<STR_LIT>" ) <EOL> ssh = self . ssh <EOL> self . _correct_ns_if_needed ( ssh ) <EOL> ssh . exec_command ( "<STR_LIT>" ) <EOL> ssh . exec_command ( "<STR_LIT>" ) <EOL> ssh . exec_command ( "<STR_LIT>" ) <EOL> ssh . exec_command ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> ssh . exec_command ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> ssh . exec_command ( "<STR_LIT>" ) <EOL> resp = ssh . exec_command ( "<STR_LIT>" ) <EOL> i = resp . find ( "<STR_LIT>" ) <EOL> if i != - <NUM_LIT:1> : <EOL> resp = resp [ i : ] <EOL> resp = "<STR_LIT>" + self . instance . placement + "<STR_LIT:\n>" + resp <EOL> fail = None <EOL> reference = self . _get_benchmark_data ( ) <EOL> for k , v in reference . iteritems ( ) : <EOL> i1 = resp . lower ( ) . find ( k ) <EOL> if i1 == - <NUM_LIT:1> : <EOL> continue <EOL> k = resp [ i1 : i1 + len ( k ) ] <EOL> i2 = resp . find ( "<STR_LIT:\n>" , i1 ) <EOL> outp = resp [ i1 + len ( k ) : i2 ] . split ( ) [ : <NUM_LIT:2> ] <EOL> if len ( outp ) < <NUM_LIT:2> : <EOL> continue <EOL> self . addDetail ( k , test_content . text_content ( <EOL> outp [ <NUM_LIT:1> ] + "<STR_LIT:|>" + outp [ <NUM_LIT:0> ] + "<STR_LIT>" + v [ <NUM_LIT:0> ] + "<STR_LIT>" + v [ <NUM_LIT:1> ] ) ) <EOL> if fail is None and float ( outp [ <NUM_LIT:0> ] ) < float ( v [ <NUM_LIT:0> ] ) : <EOL> fail = ( outp [ <NUM_LIT:0> ] , outp [ <NUM_LIT:1> ] , k , v [ <NUM_LIT:0> ] ) <EOL> if fail is not None : <EOL> self . assertGreaterEqual ( fail [ <NUM_LIT:0> ] , fail [ <NUM_LIT:1> ] , <EOL> fail [ <NUM_LIT:2> ] + "<STR_LIT>" + <EOL> fail [ <NUM_LIT:0> ] + "<STR_LIT:U+0020>" + fail [ <NUM_LIT:1> ] + "<STR_LIT>" + <EOL> fail [ <NUM_LIT:3> ] + "<STR_LIT:U+0020>" + fail [ <NUM_LIT:1> ] + "<STR_LIT>" ) </s>
