<s> import time <EOL> from concurrent . futures import ThreadPoolExecutor <EOL> from eucaops import Eucaops <EOL> from eucaops import S3ops <EOL> from eutester . eutestcase import EutesterTestCase <EOL> class WalrusConcurrent ( EutesterTestCase ) : <EOL> def __init__ ( self ) : <EOL> self . setuptestcase ( ) <EOL> self . setup_parser ( ) <EOL> self . parser . add_argument ( "<STR_LIT>" , "<STR_LIT>" , type = int , default = <NUM_LIT:100> ) <EOL> self . parser . add_argument ( "<STR_LIT:-c>" , "<STR_LIT>" , type = int , default = <NUM_LIT:10> ) <EOL> self . parser . add_argument ( "<STR_LIT>" , "<STR_LIT>" , type = int , default = <NUM_LIT> ) <EOL> self . get_args ( ) <EOL> if self . args . region : <EOL> self . tester = S3ops ( credpath = self . args . credpath , region = self . args . region ) <EOL> else : <EOL> self . tester = Eucaops ( credpath = self . args . credpath , config_file = self . args . config , password = self . args . password ) <EOL> self . start = time . time ( ) <EOL> self . bucket_name = "<STR_LIT>" + str ( int ( self . start ) ) <EOL> self . tester . create_bucket ( self . bucket_name ) <EOL> def clean_method ( self ) : <EOL> self . tester . clear_bucket ( self . bucket_name ) <EOL> def Concurrent ( self ) : <EOL> key_payload = self . tester . id_generator ( self . args . size ) <EOL> thread_count = self . args . number <EOL> thread_pool = [ ] <EOL> with ThreadPoolExecutor ( max_workers = thread_count ) as executor : <EOL> for i in xrange ( thread_count ) : <EOL> thread_pool . append ( executor . submit ( self . tester . upload_object , bucket_name = self . bucket_name , key_name = "<STR_LIT:test>" + str ( i ) , contents = key_payload ) ) <EOL> end = time . time ( ) <EOL> total = end - self . start <EOL> self . tester . debug ( "<STR_LIT>" . format ( <EOL> total , self . args . number , self . args . size , self . args . concurrent ) ) <EOL> with ThreadPoolExecutor ( max_workers = thread_count ) as executor : <EOL> for object in thread_pool : <EOL> thread_pool . append ( executor . submit ( self . tester . delete_object , object ) ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> testcase = WalrusConcurrent ( ) <EOL> list = testcase . args . tests or [ "<STR_LIT>" ] <EOL> unit_list = [ ] <EOL> for test in list : <EOL> unit_list . append ( testcase . create_testunit_by_name ( test ) ) <EOL> result = testcase . run_test_case_list ( unit_list ) <EOL> exit ( result ) </s>
