print results: outprint the local results file together with the accumulated parameters for the thread ------------------------------------------------------------------------------- ''' from shared_lib.collection import setupLogger, INFO, ljoin, master_log_path_F, ctx from master_lib.collection import jtf, deploy, handle_results_print, fetch_and_teardown, Master # setup logger import injections ipath = ''.join(injections.__path__) ctx.local_output_dir = ljoin(ipath, 'output') logger = setupLogger(master_log_path_F(), INFO, INFO) # define slave tags slaves = [ { 'tag' : 'slave1', },] # hierarchy thread_hierarchy = [ { 'slave1' : ('setup', deploy(ljoin(ipath, 'java_inject'), 'test_framework/mytmp_java')) }, { 'slave1' : ('compile java', jtf.compile_java('Example')) }, { 'slave1' : ('run java', jtf.run_java('Example')) }, { 'slave1' : ('fetch and delete', fetch_and_teardown) }, { 'slave1' : ('print results', handle_results_print) } ] Master(slaves, thread_hierarchy).run()
slave4 : ('hello world', lambda srv, run_id, accum: logger.info('hello world from %s' % run_id)), }, # tier 2: setup # setup four remote servers, # slave1: setup with access to slave_script_1.py # slave2: setup with access to slave_script_2.py # slave3: setup with access to slave_script_2.py : duplicates are allowed # slave4: setup with access to slave_script_3 : which is a folder # containing slave_script_3.py, slave_script_4.py, and some additiona lib files # # tier 3: setup the slaves for later script execution # it is possible to partially specify what the containing remote folder should be named # which is practical for repeated executions without removal # if none is specified, a unique temporary folder is created { slave1 : ('setup script 1.', deploy(rjoin(ipath, 'slave_scripts', 'slave_script_1.py'), 'test_framework/slave1')), slave2 : ('setup script 2.', deploy(rjoin(ipath, 'slave_scripts', 'slave_script_2.py'), 'test_framework/slave2')), slave3 : ('setup script 2. again ', deploy(rjoin(ipath, 'slave_scripts', 'slave_script_2.py'), 'test_framework/slave3')), slave4 : ('setup folder with script 3, 4, 5', deploy(rjoin(ipath, 'some_other_slave_scripts'), 'test_framework/slave4')), }, # tier 4: call a script and see how the logger handles remote prints # call slave_script 3: which simply prints to stdout what parameters is gets # this is an example of directly executing a remote script. # note the necessity of supplying a function which takes srv, run_id and accum # note also how to get the name of the root folder (as it might be generated on runtime, we need this) # should simply be evident in the log output { slave4 : ('echo', lambda srv, run_id, accum : execute_injected_python_script(srv, 'slave_script_3.py', getRoot(accum), {'Sherlock Holmes':'Arthur Conan Doyle', 'Conan the barbarian': 'Robert E. Howard'})),
#deploy logger import injections ipath = ''.join(injections.__path__) ctx.local_output_dir = ljoin(ipath, 'output') logger = setupLogger(master_log_path_F(), DEBUG, None) #define slave tags slaves = [ { 'tag' : 'bob', }, { 'tag' : 'alice', }] #hierarchy thread_hierarchy = [ { 'bob' : ('deploy', deploy(ljoin(ipath, 'example'), rjoin('test_framework', 'benchmarking_example1'))), 'alice' : ('deploy', deploy(ljoin(ipath, 'example'), rjoin('test_framework', 'benchmarking_example2'))), # 'bob' : ('deploy', lambda a, b, c: ('metadata', {'root' : 'test_framework/benchmarking_example1'})), # 'alice' : ('deploy', lambda a, b, c: ('metadata', {'root' : 'test_framework/benchmarking_example2'})), }, { 'bob' : ('compile_fairplay', ftf.compile_fairplay('run_bob', 'progs/Billionaires.txt')), 'alice' : ('compile_fairplay', ftf.compile_fairplay('run_alice', 'progs/Billionaires.txt')), }, { 'bob' : ('execute_fairplay', ftf.execute_fairplay_billionare_part1(498754, 'progs/Billionaires.txt')), 'alice' : ('execute_fairplay', ftf.execute_fairplay_billionare_part2(2987654, 'progs/Billionaires.txt')), }, ]
def execute_deploy_1(): ''' helper method for hierarchy 1 ''' localpath = ljoin(ipath, 'viff_three_millionaires') remote_root = rjoin('test_framework', 'benchmarking_example') return deploy(localpath, remote_root)
def execute_deploy_4(): ''' helper method for hierarchy 4 ''' localpath = ljoin(ipath, 'fib') remotepath = rjoin('test_framework', 'benchmarking_example') return deploy(localpath, remotepath)
def execute_deploy_2(): ''' helper method for hierarchy 2 ''' localpath = ljoin(ipath, 'fairplay_two_millionaires') remote_root = rjoin('test_framework', 'benchmarking_example') return deploy(localpath, remote_root)
# define slave tags slaves = [{"tag": "slave1"}, {"tag": "slave2"}, {"tag": "slave3"}] def calculate(srv, run_id, accum): root = getRoot(accum) tag = getTag(accum) params = "--no-ssl {my_initfile}".format(my_initfile=rjoin(root, "inject", tag + ".ini")) execute_injected_python_script(srv, "benchmark.py", root, params) # hirarchy thread_hierarchy = [ { "slave1": ("deploy", deploy(ljoin(ipath, "mult"), "test_framework/mytmp_viff_mult")), "slave2": ("deploy", deploy(ljoin(ipath, "mult"), "test_framework/mytmp_viff_mult")), "slave3": ("deploy", deploy(ljoin(ipath, "mult"), "test_framework/mytmp_viff_mult")), }, {"slave1": ("generate init files", vtf.generate_init_files(["slave1", "slave2", "slave3"], 9001))}, { "slave1": ("put init file", vtf.put_my_init_file), "slave2": ("put init file", vtf.put_my_init_file), "slave3": ("put init file", vtf.put_my_init_file), }, { "slave1": ("do some multiplication", calculate), "slave2": ("do some multiplication", calculate), "slave3": ("do some multiplication", calculate), }, {
#setup logger logger = setupLogger(master_log_path_F(), DEBUG, None) #define slave tags slaves = [ { 'tag' : 'slave1', }, { 'tag' : 'slave2', }, { 'tag' : 'slave3', }, ] #hierarchy thread_hierarchy = [ { 'slave1' : ('setup', deploy(ljoin(ipath, 'example'), 'test_framework/millionaires')), 'slave2' : ('setup', deploy(ljoin(ipath, 'example'), 'test_framework/millionaires')), 'slave3' : ('setup', deploy(ljoin(ipath, 'example'), 'test_framework/millionaires')), }, { 'slave1' : ('generate init files', vtf.generate_init_files(['slave1', 'slave2', 'slave3'], 9050)), }, { 'slave1' : ('put init file', vtf.put_my_init_file), 'slave2' : ('put init file', vtf.put_my_init_file), 'slave3' : ('put init file', vtf.put_my_init_file), }, # The results will only be visible in in the log and when the debug flag is set. {