Ejemplo n.º 1
0
def execute_fairplay(player, **kwargs):
	if player == 'bob': cmd = cmd_for_bob(**kwargs)
	else: cmd = cmd_for_alice(**kwargs)

	root = kwargs.get('root')
	fortune = kwargs.pop('fortune')

	logger = setupLogger(remote_logs_dir_F(root), DEBUG, DEBUG)

	logger.info('begin ~')
	path = rjoin(root, inject_folder_name, 'run')
	results_wrapper()(ubt.benchmark_wrapper()(lambda : do(cmd, fortune, path)))()
	logger.info('end ~')
Ejemplo n.º 2
0
	and delete the remote folder 
	
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()  
Ejemplo n.º 3
0
wrapping the function in a results wrapper and
a benchmark wrapper.

Notice how the optional timeout parameter is managed.
-------------------------------------------------------------------------------
"""

import sys
from shared_lib.collection import ubt 
from shared_lib.collection import \
	setupLogger, DEBUG, remote_logs_dir_F, root, \
	results_wrapper, parse_params 
	
	
# _Setup logger_
logger = setupLogger(remote_logs_dir_F(root), DEBUG, DEBUG)


# _Fib, the function to be tested_
def fib(x):
	if x < 3: return x
	else: return fib(x-1) + fib(x-2)
	
	
#
# Results wrapper and benchmark wrapper  
# transparently handles benchmarking,  
# the given script and saves it to a results file
#     
if __name__ == '__main__':
	params = parse_params(sys.argv)
Ejemplo n.º 4
0
purge of the remote directory,
error handling and remote logging
-------------------------------------------------------------------------------
'''

from master_lib.collection import Master, getRoot, print_accum, \
execute_injected_python_script, fetch_and_teardown, rjoin, deploy, handle_results_print
from shared_lib.collection import setupLogger, ljoin, master_log_path_F, ctx

def throw_exc(): raise Exception('This is a locally grown exception!')

# setup -----------------------------------------------------------
import injections 
ipath = ''.join(injections.__path__) 
ctx.local_output_dir = ljoin(ipath, 'output')
logger = setupLogger(master_log_path_F(), ctx.cmd_log_level, ctx.file_log_level)

ctx.hosts = ['host1', 'host2', 'host3', 'host4']
ctx.username = '******'
ctx.private_key = 'insert key path here'

# named slaves - each to execute functions in parallel on different machines
slave1 = 'slave1'
slave2 = 'slave2'
slave3 = 'slave3'
slave4 = 'slave4'


# config uses a dict, to make it easy to extend 
# with more specific configuration options
slave_data = [  { 'tag' : slave1, }, 
Ejemplo n.º 5
0
"""

from db_adaptor import handle_results_db
from shared_lib.collection import setupLogger,  INFO, DEBUG, ljoin, rjoin, ctx
from master_lib.collection import handle_results_print, deploy, \
                                  fetch_and_teardown, Master, ftf, vtf, \
                                  getRoot, getHosts, getTag, \
                                  execute_injected_python_script
#
#Housekeeping
#------------------------------------------------------------------------------
#Setup of logger  
#Define slave tags   
#Overwrite default hosts, username and private key  
#
logger = setupLogger('output/master_logs', DEBUG, INFO)

slaves = [ 
	{ 'tag' : 'bob', },	
   	{ 'tag' : 'alice', },
   	{ 'tag' : 'conrad', }, 
] 

import injections
ipath = ''.join(injections.__path__) 

#
#Define thread hierarchy 1
#------------------------------------------------------------------------------
#Benchmark the Viff program 'millionaire'.  
#**First tier**: deploy  
Ejemplo n.º 6
0
    fetch_and_teardown,
    Master,
    vtf,
    rjoin,
    execute_injected_python_script,
    getRoot,
    getTag,
)
from shared_lib.collection import setupLogger, DEBUG, ctx, ljoin, master_log_path_F


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": "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 = [