summaryrefslogtreecommitdiffstats
path: root/VNFs/DPPD-PROX/helper-scripts/rapid/runrapid.py
diff options
context:
space:
mode:
Diffstat (limited to 'VNFs/DPPD-PROX/helper-scripts/rapid/runrapid.py')
-rwxr-xr-xVNFs/DPPD-PROX/helper-scripts/rapid/runrapid.py169
1 files changed, 116 insertions, 53 deletions
diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/runrapid.py b/VNFs/DPPD-PROX/helper-scripts/rapid/runrapid.py
index db4e969b..7ec270a1 100755
--- a/VNFs/DPPD-PROX/helper-scripts/rapid/runrapid.py
+++ b/VNFs/DPPD-PROX/helper-scripts/rapid/runrapid.py
@@ -22,7 +22,10 @@ from __future__ import division
from future import standard_library
standard_library.install_aliases()
from builtins import object
+import os
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
@@ -40,23 +43,42 @@ class RapidTestManager(object):
"""
RapidTestManager Class
"""
+ def __init__(self):
+ """
+ Init Function
+ """
+ self.machines = []
+
+ 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 = []
+ configonly = test_params['configonly']
+ machine_names = []
+ machine_counter = {}
for machine_params in test_params['machines']:
+ if machine_params['name'] not in machine_names:
+ machine_names.append(machine_params['name'])
+ machine_counter[machine_params['name']] = 1
+ else:
+ machine_counter[machine_params['name']] += 1
+ machine_params['name'] = '{}_{}'.format(machine_params['name'],
+ machine_counter[machine_params['name']])
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['user'], test_params['password'],
+ test_params['vim_type'], test_params['rundir'],
+ test_params['resultsdir'], machine_params, configonly,
+ test_params['ipv6'])
if machine_params['monitor']:
if monitor_gen:
RapidLog.exception("Can only monitor 1 generator")
@@ -68,55 +90,89 @@ class RapidTestManager(object):
background_machines.append(machine)
else:
machine = RapidMachine(test_params['key'], test_params['user'],
- test_params['vim_type'], test_params['rundir'],
- machine_params)
+ test_params['password'], test_params['vim_type'],
+ test_params['rundir'], test_params['resultsdir'],
+ 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']:
- sys.exit()
- for machine in machines:
- machine.start_prox()
- result = True
- for test_param in test_params['tests']:
- RapidLog.info(test_param['test'])
- if test_param['test'] in ['flowsizetest', 'TST009test',
- 'fixed_rate']:
- test = FlowSizeTest(test_param, test_params['lat_percentile'],
- test_params['runtime'], test_params['pushgateway'],
- test_params['environment_file'], gen_machine,
- sut_machine, background_machines)
- elif test_param['test'] in ['corestats']:
- test = CoreStatsTest(test_param, test_params['runtime'],
- test_params['pushgateway'],
- test_params['environment_file'], machines)
- elif test_param['test'] in ['portstats']:
- test = PortStatsTest(test_param, test_params['runtime'],
- test_params['pushgateway'],
- test_params['environment_file'], machines)
- elif test_param['test'] in ['impairtest']:
- test = ImpairTest(test_param, test_params['lat_percentile'],
- test_params['runtime'], test_params['pushgateway'],
- test_params['environment_file'], gen_machine,
- sut_machine)
- elif test_param['test'] in ['irqtest']:
- test = IrqTest(test_param, test_params['runtime'],
- test_params['pushgateway'],
- test_params['environment_file'], 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()
- if not single_test_result:
- result = False
- return (result)
+ if machine_params['prox_socket']:
+ sut_machine = machine
+ self.machines.append(machine)
+ RapidLog.debug(test_params)
+ try:
+ 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()
+ socket_executor = concurrent.futures.ThreadPoolExecutor(max_workers=len(self.machines))
+ future_to_connect_prox = {socket_executor.submit(machine.connect_prox): machine for machine in self.machines}
+ concurrent.futures.wait(future_to_connect_prox,return_when=ALL_COMPLETED)
+ result = 0
+ for test_param in test_params['tests']:
+ RapidLog.info(test_param['test'])
+ if test_param['test'] in ['flowsizetest', 'TST009test',
+ 'fixed_rate', 'increment_till_fail']:
+ test = FlowSizeTest(test_param,
+ test_params['lat_percentile'],
+ test_params['runtime'],
+ test_params['TestName'],
+ test_params['environment_file'],
+ gen_machine,
+ sut_machine, background_machines,
+ test_params['sleep_time'])
+ elif test_param['test'] in ['corestatstest']:
+ test = CoreStatsTest(test_param,
+ test_params['runtime'],
+ test_params['TestName'],
+ test_params['environment_file'],
+ self.machines)
+ elif test_param['test'] in ['portstatstest']:
+ test = PortStatsTest(test_param,
+ test_params['runtime'],
+ test_params['TestName'],
+ test_params['environment_file'],
+ self.machines)
+ elif test_param['test'] in ['impairtest']:
+ test = ImpairTest(test_param,
+ test_params['lat_percentile'],
+ test_params['runtime'],
+ test_params['TestName'],
+ test_params['environment_file'],
+ gen_machine,
+ sut_machine, background_machines)
+ elif test_param['test'] in ['irqtest']:
+ test = IrqTest(test_param,
+ test_params['runtime'],
+ test_params['TestName'],
+ 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, result_details = test.run()
+ result = result + single_test_result
+ for machine in self.machines:
+ machine.close_prox()
+ concurrent.futures.wait(self.future_to_prox,
+ return_when=ALL_COMPLETED)
+ except (ConnectionError, KeyboardInterrupt) as e:
+ result = result_details = None
+ socket_executor.shutdown(wait=False)
+ socket_executor._threads.clear()
+ prox_executor.shutdown(wait=False)
+ prox_executor._threads.clear()
+ concurrent.futures.thread._threads_queues.clear()
+ RapidLog.error("Test interrupted: {} {}".format(
+ type(e).__name__,e))
+ return (result, result_details)
def main():
"""Main function.
@@ -125,12 +181,19 @@ def main():
# When no cli is used, the process_cli can be replaced by code modifying
# test_params
test_params = RapidCli.process_cli(test_params)
- log_file = 'RUN{}.{}.log'.format(test_params['environment_file'],
- test_params['test_file'])
+ _, test_file_name = os.path.split(test_params['test_file'])
+ _, environment_file_name = os.path.split(test_params['environment_file'])
+ if 'resultsdir' in test_params:
+ res_dir = test_params['resultsdir']
+ log_file = '{}/RUN{}.{}.log'.format(res_dir,environment_file_name,
+ test_file_name)
+ else:
+ log_file = 'RUN{}.{}.log'.format(environment_file_name, test_file_name)
RapidLog.log_init(log_file, test_params['loglevel'],
test_params['screenloglevel'] , test_params['version'] )
- test_result = RapidTestManager.run_tests(test_params)
- RapidLog.info('Test result is : {}'.format(test_result))
+ test_manager = RapidTestManager()
+ test_result, _ = test_manager.run_tests(test_params)
+ RapidLog.log_close()
if __name__ == "__main__":
main()