standard_library.install_aliases()
from builtins import object
import sys
+import concurrent.futures
+from concurrent.futures import ALL_COMPLETED
from rapid_cli import RapidCli
from rapid_log import RapidLog
from rapid_parser import RapidConfigParser
"""
RapidTestManager Class
"""
+ def __del__(self):
+ for machine in self.machines:
+ machine.close_prox()
+
@staticmethod
def get_defaults():
return (RapidDefaults.test_params)
- @staticmethod
- def run_tests(test_params):
+ def run_tests(self, test_params):
test_params = RapidConfigParser.parse_config(test_params)
RapidLog.debug(test_params)
monitor_gen = monitor_sut = False
background_machines = []
sut_machine = gen_machine = None
- machines = []
+ self.machines = []
+ configonly = test_params['configonly']
for machine_params in test_params['machines']:
if 'gencores' in machine_params.keys():
machine = RapidGeneratorMachine(test_params['key'],
test_params['user'], test_params['vim_type'],
test_params['rundir'], machine_params,
- test_params['ipv6'])
+ configonly, test_params['ipv6'])
if machine_params['monitor']:
if monitor_gen:
RapidLog.exception("Can only monitor 1 generator")
else:
machine = RapidMachine(test_params['key'], test_params['user'],
test_params['vim_type'], test_params['rundir'],
- machine_params)
+ machine_params, configonly)
if machine_params['monitor']:
if monitor_sut:
RapidLog.exception("Can only monitor 1 sut")
raise Exception("Can only monitor 1 sut")
else:
monitor_sut = True
- sut_machine = machine
- machines.append(machine)
- if test_params['configonly']:
+ if machine_params['prox_socket']:
+ sut_machine = machine
+ self.machines.append(machine)
+ prox_executor = concurrent.futures.ThreadPoolExecutor(max_workers=len(self.machines))
+ self.future_to_prox = {prox_executor.submit(machine.start_prox): machine for machine in self.machines}
+ if configonly:
+ concurrent.futures.wait(self.future_to_prox,return_when=ALL_COMPLETED)
sys.exit()
- for machine in machines:
- machine.start_prox()
+ with concurrent.futures.ThreadPoolExecutor(max_workers=len(self.machines)) as executor:
+ future_to_connect_prox = {executor.submit(machine.connect_prox): machine for machine in self.machines}
+ concurrent.futures.wait(future_to_connect_prox,return_when=ALL_COMPLETED)
result = True
for test_param in test_params['tests']:
RapidLog.info(test_param['test'])
elif test_param['test'] in ['corestats']:
test = CoreStatsTest(test_param, test_params['runtime'],
test_params['TestName'],
- test_params['environment_file'], machines)
+ test_params['environment_file'], self.machines)
elif test_param['test'] in ['portstats']:
test = PortStatsTest(test_param, test_params['runtime'],
test_params['TestName'],
- test_params['environment_file'], machines)
+ test_params['environment_file'], self.machines)
elif test_param['test'] in ['impairtest']:
test = ImpairTest(test_param, test_params['lat_percentile'],
test_params['runtime'],
elif test_param['test'] in ['irqtest']:
test = IrqTest(test_param, test_params['runtime'],
test_params['TestName'],
- test_params['environment_file'], machines)
+ test_params['environment_file'], self.machines)
elif test_param['test'] in ['warmuptest']:
test = WarmupTest(test_param, gen_machine)
else:
RapidLog.debug('Test name ({}) is not valid:'.format(
test_param['test']))
- single_test_result = test.run()
+ single_test_result, result_details = test.run()
if not single_test_result:
result = False
- return (result)
+ return (result, result_details)
def main():
"""Main function.
test_params['test_file'])
RapidLog.log_init(log_file, test_params['loglevel'],
test_params['screenloglevel'] , test_params['version'] )
- test_result = RapidTestManager.run_tests(test_params)
+ test_manager = RapidTestManager()
+ test_result, _ = test_manager.run_tests(test_params)
RapidLog.info('Test result is : {}'.format(test_result))
if __name__ == "__main__":