def assertDataFromSlave1(srv, id, accum): ''' assert the structure and content of slave1's data, this includes both accum and the results file ''' _assert('assert fetched results', id) tag = getTag(accum) # assert on accum from here root = getRoot(accum) hosts = getHosts(accum) _assert(len(hosts), 4) _assert('test_framework/slave1', root) _assert('slave1', tag) with open(local_results_file_path_F(tag), 'rb') as f: results = json.load(f) _assert_contain('result_0', results) # assert on results file from here result_0 = results.get('result_0') _assert_contain( 'tmsp', result_0) _assert_contain( 'parameters', result_0) _assert_contain( 'query', result_0.get('parameters')) _assert_contain( 'Oryx and Crake', result_0.get('parameters').get('query')) _assert_contain( 'result', result_0) _assert(len(result_0.get('result')), 4)
def execute_runner_1(srv, run_id, accum): ''' helper method for hierarchy 1 ''' script = 'runner.py' root = getRoot(accum) parameters = { 'tag' : getTag(accum), 'run_id': run_id} return execute_injected_python_script(srv, script, root, parameters)
def assertDataFromSlave4(srv, id, accum): ''' assert the structure and content of slave4's data, this includes both accum and the results file ''' _assert('assert fetched results', id) # assert on accum from here tag = getTag(accum) root = getRoot(accum) hosts = getHosts(accum) _assert(len(hosts), 4) _assert('test_framework/slave4', root) _assert('slave4', tag) with open(local_results_file_path_F(tag), 'rb') as f: results = json.load(f) # assert on results file here _assert_contain('result_0', results) result_0 = results.get('result_0') _assert_contain( 'tmsp', result_0) _assert_contain( 'parameters', result_0) _assert_contain( 'The Jabberwocky', result_0.get('parameters').get('Dragon_no_1')) _assert_contain( 'The Tarasque', result_0.get('parameters').get('Dragon_no_2')) _assert_contain( 'result', result_0) _assert(result_0.get('result'), 42)
def collect_context_stat(srv, run_id, accum): ''' Helper method for hierarchy 3 ''' hosts = getHosts(accum) me = getTag(accum) tag2hosts = {} for tag, host in hosts.iteritems(): if tag != me: tag2hosts[tag] = host script = 'runner.py' root = getRoot(accum) parameters = {'tag2hosts':tag2hosts, 'run_id': run_id} execute_injected_python_script(srv, script, root, parameters)
def assertDataFromSlave2(srv, id, accum): ''' assert the structure and content of slave2's data, this includes both accum and the results file ''' _assert('assert fetched results', id) # assert on accum from here tag = getTag(accum) root = getRoot(accum) hosts = getHosts(accum) _assert(len(hosts), 4) _assert('test_framework/slave2', root) _assert('slave2', tag) assert os.path.exists(local_results_file_path_F(tag)) == False, \ 'slave 2 should not have generated any results' # assert on results file here
def put_my_init_file(srv, run_id, accum): my_tag = getTag(accum) root = getRoot(accum) lpath = ljoin(ctx.local_output_dir, my_tag+'.ini') put(srv, lpath, rjoin(root, 'inject'))
def let_my_millionaire_participate(srv, run_id, accum): tag = getTag(accum) root = getRoot(accum) params = '--no-ssl {my_initfile}'.format(my_initfile=(rjoin(root,'inject', tag+'.ini'))) execute_injected_python_script(srv, 'millionaires', root, params)
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)
def handle_results_print(srv, run_id, accum): # _accum_ is just a dictionary, and # _getTag_ a simple shorthand helper method # for extracting metadata. slavetag = getTag(accum) host = getCurrentHost(accum) with open(local_results_file_path_F(slavetag), 'rb') as f: results = json.load(f) # Open the database file, creating it if # none exists. conn = sqlite3.connect('output/my_database.sqlite') c = conn.cursor() # Create the table if requested if create_new_table: logger.info('creating a new table, dropping the old one') c.execute('''DROP TABLE IF EXISTS testdata;''') c.execute('''CREATE TABLE testdata ( slavetag TEXT, test_id TEXT, results_id INTEGER, host TEXT, params TEXT, ctime REAL, utime REAL, max_rss INTEGER, max_rss_delta INTEGER, func_output TEXT, transmitted INTEGER, recieved INTEGER, timestamp TIMESTAMP, id INTEGER PRIMARY KEY AUTOINCREMENT);''') # Iterate through the results for i, (key, result) in enumerate(results.iteritems()): parameters = result.get('parameters') timestamp = result.get('tmsp') tmp = result.get('result') if not isinstance(tmp, dict): tmp = {'func_output' : tmp} max_rss = tmp.get('max_rss', -1) max_rss_delta = tmp.get('max_rss_delta', -1) func_output = tmp.get('func_output', 'N/A') ctime = tmp.get('ctime', -1) utime = tmp.get('utime', -1) rx = tmp.get('rx', -1) tx = tmp.get('tx', -1) # Insert the row of data c.execute('''INSERT INTO testdata ( slavetag, test_id, results_id, host, params, ctime, utime, max_rss, max_rss_delta, func_output, transmitted, recieved, timestamp) VALUES(''' + "?,"*12 + "?)", (slavetag, test_id, i, host, str(parameters), ctime, utime, max_rss, max_rss_delta, str(func_output), tx, rx, timestamp)) # Commit the changes and close the connection conn.commit() conn.close()