Esempio n. 1
0
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)
Esempio n. 2
0
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)
Esempio n. 3
0
	def inner(srv, run_id, accum):
		script = 'runner.py'
		root = getRoot(accum)
		parameters = {
					'root': getRoot(accum), 
					'fortune' :  fortune, 
					'program': 'progs/Millionaires.txt', 
					'run_id' : run_id, 
					'player': player}
		if host_slavetag:
			host = getHosts(accum).get(host_slavetag)
			parameters['addr_of_host'] = host
		return execute_injected_python_script(srv, script, root, parameters)
Esempio n. 4
0
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)
Esempio n. 5
0
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 inner(srv, run_id, accum):
        root = getRoot(accum)
        hosts = getHosts(accum)

        host = hosts["bob"]
        logger.info("alice on host: " + getMetadata(accum).get("host"))
        logger.info("connecting to bob on host: " + host)

        command = "run_alice"
        path = rjoin(root, inject_folder_name, "run")
        cmd = r"cd %s; echo %d | ./%s -r %s abcdefghijk %s" % (path, fortune, command, program, host)

        logger.info("execute: " + cmd)

        t1 = clock()
        (stdout, stderr) = srv.execute(cmd)
        t2 = clock()

        print_remote_out((None, stderr))
        logger.info("".join(stdout).replace("\n", ". "))
        logger.info("execution time took %d seconds" % (t2 - t1))
Esempio n. 7
0
	def inner(srv, run_id, accum):
		addresses = []
		slaves = getHosts(accum)
		slave_keyorder = []
		port = port_start
		for key in slaves:
			if key in tags:
				host = slaves[key]
				port += 1
				slave_keyorder.append(key)
				addresses.append([host,port])
		
		
		pallier = ViffPaillier(1024)
		configs = generate_configs(n=len(tags), 
								   t=1, addresses=addresses, 
								   skip_prss=False, 
								   paillier=pallier)
		
		if not os.path.exists(ctx.local_output_dir): #TODO: hack
			os.makedirs(ctx.local_output_dir)
		for i, config in enumerate(configs.values()):
			with open(ljoin(ctx.local_output_dir, slave_keyorder[i]) +'.ini', 'w') as f:
				config.write(outfile=f)