diff options
Diffstat (limited to 'vsperf')
-rwxr-xr-x | vsperf | 105 |
1 files changed, 89 insertions, 16 deletions
@@ -40,11 +40,13 @@ import core.component_factory as component_factory from core.loader import Loader from testcases import PerformanceTestCase from testcases import IntegrationTestCase +from testcases import K8sPerformanceTestCase from tools import tasks from tools import networkcard from tools import functions from tools.pkt_gen import trafficgen from tools.opnfvdashboard import opnfvdashboard +from tools.os_deploy_tgen import osdt sys.dont_write_bytecode = True VERBOSITY_LEVELS = { @@ -68,6 +70,7 @@ _TEMPLATE_MATRIX = "Performance Matrix\n------------------\n\n"\ "currently run tests. The metric used for comparison is {}.\n\n{}\n\n" _LOGGER = logging.getLogger() +logging.getLogger('matplotlib').setLevel(logging.ERROR) def parse_param_string(values): """ @@ -178,6 +181,8 @@ def parse_arguments(): help='list all system vnfs and exit') parser.add_argument('--list-loadgens', action='store_true', help='list all background load generators') + parser.add_argument('--list-pods', action='store_true', + help='list all system pods') parser.add_argument('--list-settings', action='store_true', help='list effective settings configuration and exit') parser.add_argument('exact_test_name', nargs='*', help='Exact names of\ @@ -201,6 +206,8 @@ def parse_arguments(): group.add_argument('--verbosity', choices=list_logging_levels(), help='debug level') group.add_argument('--integration', action='store_true', help='execute integration tests') + group.add_argument('--k8s', action='store_true', help='execute Kubernetes tests') + group.add_argument('--openstack', action='store_true', help='Run VSPERF with openstack') group.add_argument('--trafficgen', help='traffic generator to use') group.add_argument('--vswitch', help='vswitch implementation to use') group.add_argument('--fwdapp', help='packet forwarding application to use') @@ -235,13 +242,31 @@ def parse_arguments(): def configure_logging(level): """Configure logging. """ + name, ext = os.path.splitext(settings.getValue('LOG_FILE_DEFAULT')) + rename_default = "{name}_{uid}{ex}".format(name=name, + uid=settings.getValue( + 'LOG_TIMESTAMP'), + ex=ext) log_file_default = os.path.join( - settings.getValue('LOG_DIR'), settings.getValue('LOG_FILE_DEFAULT')) + settings.getValue('RESULTS_PATH'), rename_default) + name, ext = os.path.splitext(settings.getValue('LOG_FILE_HOST_CMDS')) + rename_hostcmd = "{name}_{uid}{ex}".format(name=name, + uid=settings.getValue( + 'LOG_TIMESTAMP'), + ex=ext) log_file_host_cmds = os.path.join( - settings.getValue('LOG_DIR'), settings.getValue('LOG_FILE_HOST_CMDS')) + settings.getValue('RESULTS_PATH'), rename_hostcmd) + name, ext = os.path.splitext(settings.getValue('LOG_FILE_TRAFFIC_GEN')) + rename_traffic = "{name}_{uid}{ex}".format(name=name, + uid=settings.getValue( + 'LOG_TIMESTAMP'), + ex=ext) log_file_traffic_gen = os.path.join( - settings.getValue('LOG_DIR'), - settings.getValue('LOG_FILE_TRAFFIC_GEN')) + settings.getValue('RESULTS_PATH'), rename_traffic) + metrics_file = (settings.getValue('LOG_FILE_INFRA_METRICS_PFX') + + settings.getValue('LOG_TIMESTAMP') + '.log') + log_file_infra_metrics = os.path.join(settings.getValue('LOG_DIR'), + metrics_file) _LOGGER.setLevel(logging.DEBUG) @@ -253,6 +278,8 @@ def configure_logging(level): file_logger = logging.FileHandler(filename=log_file_default) file_logger.setLevel(logging.DEBUG) + file_logger.setFormatter(logging.Formatter( + '%(asctime)s : %(message)s')) _LOGGER.addHandler(file_logger) class CommandFilter(logging.Filter): @@ -265,6 +292,11 @@ def configure_logging(level): def filter(self, record): return record.getMessage().startswith(trafficgen.CMD_PREFIX) + class CollectdMetricsFilter(logging.Filter): + """Filter out strings beginning with 'COLLECTD' :'""" + def filter(self, record): + return record.getMessage().startswith('COLLECTD') + cmd_logger = logging.FileHandler(filename=log_file_host_cmds) cmd_logger.setLevel(logging.DEBUG) cmd_logger.addFilter(CommandFilter()) @@ -275,6 +307,12 @@ def configure_logging(level): gen_logger.addFilter(TrafficGenCommandFilter()) _LOGGER.addHandler(gen_logger) + if settings.getValue('COLLECTOR') == 'Collectd': + met_logger = logging.FileHandler(filename=log_file_infra_metrics) + met_logger.setLevel(logging.DEBUG) + met_logger.addFilter(CollectdMetricsFilter()) + _LOGGER.addHandler(met_logger) + def apply_filter(tests, tc_filter): """Allow a subset of tests to be conveniently selected @@ -546,6 +584,10 @@ def handle_list_options(args): print(Loader().get_loadgens_printable()) sys.exit(0) + if args['list_pods']: + print(Loader().get_pods_printable()) + sys.exit(0) + if args['list_settings']: print(str(settings)) sys.exit(0) @@ -563,6 +605,8 @@ def list_testcases(args): # configure tests if args['integration']: testcases = settings.getValue('INTEGRATION_TESTS') + elif args['k8s']: + testcases = settings.getValue('K8SPERFORMANCE_TESTS') else: testcases = settings.getValue('PERFORMANCE_TESTS') @@ -641,9 +685,26 @@ def main(): settings.load_from_dir(os.path.join(_CURR_DIR, 'conf')) - # Load non performance/integration tests + # define the timestamp to be used by logs and results + date = datetime.datetime.fromtimestamp(time.time()) + timestamp = date.strftime('%Y-%m-%d_%H-%M-%S') + settings.setValue('LOG_TIMESTAMP', timestamp) + + # generate results directory name + # integration test use vswitchd log in test step assertions, ensure that + # correct value will be set before loading integration test configuration + results_dir = "results_" + timestamp + results_path = os.path.join(settings.getValue('LOG_DIR'), results_dir) + settings.setValue('RESULTS_PATH', results_path) + # create results directory + if not os.path.exists(results_path): + os.makedirs(results_path) + + # load non performance/integration tests if args['integration']: settings.load_from_dir(os.path.join(_CURR_DIR, 'conf/integration')) + if args['k8s']: + settings.load_from_dir(os.path.join(_CURR_DIR, 'conf/kubernetes')) # load command line parameters first in case there are settings files # to be used @@ -661,6 +722,19 @@ def main(): settings.setValue('mode', args['mode']) + if args['k8s']: + settings.setValue('K8S', True) + else: + settings.setValue('K8S', False) + + if args['openstack']: + result = osdt.deploy_testvnf() + if result: + _LOGGER.info('TestVNF successfully deployed on Openstack') + settings.setValue('mode', 'trafficgen') + else: + _LOGGER.error('Failed to deploy TestVNF in Openstac') + sys.exit(1) # update paths to trafficgens if required if settings.getValue('mode') == 'trafficgen': functions.settings_update_paths() @@ -670,6 +744,9 @@ def main(): configure_logging(settings.getValue('VERBOSITY')) + # CI build support + _LOGGER.info("Creating result directory: %s", results_path) + # check and fix locale check_and_set_locale() @@ -749,16 +826,7 @@ def main(): # for backward compatibility settings.setValue('WHITELIST_NICS', list(nic['pci'] for nic in nic_list)) - # generate results directory name - date = datetime.datetime.fromtimestamp(time.time()) - results_dir = "results_" + date.strftime('%Y-%m-%d_%H-%M-%S') - results_path = os.path.join(settings.getValue('LOG_DIR'), results_dir) - settings.setValue('RESULTS_PATH', results_path) - # create results directory - if not os.path.exists(results_path): - _LOGGER.info("Creating result directory: %s", results_path) - os.makedirs(results_path) # pylint: disable=too-many-nested-blocks if settings.getValue('mode') == 'trafficgen': # execute only traffic generator @@ -783,6 +851,8 @@ def main(): # configure tests if args['integration']: testcases = settings.getValue('INTEGRATION_TESTS') + elif args['k8s']: + testcases = settings.getValue('K8SPERFORMANCE_TESTS') else: testcases = settings.getValue('PERFORMANCE_TESTS') @@ -825,6 +895,8 @@ def main(): if args['integration']: test = IntegrationTestCase(cfg) + elif args['k8s']: + test = K8sPerformanceTestCase(cfg) else: test = PerformanceTestCase(cfg) @@ -857,8 +929,9 @@ def main(): output=settings.getValue('XUNIT_DIR'), outsuffix="", verbosity=0).run(suite) - if args['opnfvpod']: - pod_name = args['opnfvpod'] + if args['opnfvpod'] or settings.getValue('OPNFVPOD'): + pod_name = (args['opnfvpod'] if args['opnfvpod'] else + settings.getValue('OPNFVPOD')) installer_name = str(settings.getValue('OPNFV_INSTALLER')).lower() opnfv_url = settings.getValue('OPNFV_URL') pkg_list = settings.getValue('PACKAGE_LIST') |