X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=vsperf;h=6f248f89a83442f11c4fafa8ce1ebf71cbcd72d6;hb=62cc56705f9ec94c59b2b0597ffdd1fa41008982;hp=36c12df9a810cdcbe45731536f6f0ca3a9ca73fe;hpb=430bb728a4ab0f9a037a2157a9ff00a00ad0ac72;p=vswitchperf.git diff --git a/vsperf b/vsperf index 36c12df9..6f248f89 100755 --- a/vsperf +++ b/vsperf @@ -147,6 +147,8 @@ def parse_arguments(): help='list all system forwarding applications and exit') parser.add_argument('--list-vnfs', action='store_true', 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-settings', action='store_true', help='list effective settings configuration and exit') parser.add_argument('exact_test_name', nargs='*', help='Exact names of\ @@ -174,6 +176,7 @@ def parse_arguments(): group.add_argument('--vswitch', help='vswitch implementation to use') group.add_argument('--fwdapp', help='packet forwarding application to use') group.add_argument('--vnf', help='vnf to use') + group.add_argument('--loadgen', help='loadgen to use') group.add_argument('--sysmetrics', help='system metrics logger to use') group = parser.add_argument_group('test behavior options') group.add_argument('--xunit', action='store_true', @@ -439,23 +442,45 @@ def handle_list_options(args): print(Loader().get_pktfwds_printable()) sys.exit(0) + if args['list_loadgens']: + print(Loader().get_loadgens_printable()) + sys.exit(0) + if args['list_settings']: print(str(settings)) sys.exit(0) if args['list']: - # configure tests - if args['integration']: - testcases = settings.getValue('INTEGRATION_TESTS') + list_testcases(args) + sys.exit(0) + + +def list_testcases(args): + """ Print list of testcases requested by --list CLI argument + + :param args: A dictionary with all CLI arguments + """ + # configure tests + if args['integration']: + testcases = settings.getValue('INTEGRATION_TESTS') + else: + testcases = settings.getValue('PERFORMANCE_TESTS') + + print("Available Tests:") + print("================") + + for test in testcases: + description = functions.format_description(test['Description'], 70) + if len(test['Name']) < 40: + print('* {:40} {}'.format('{}:'.format(test['Name']), description[0])) else: - testcases = settings.getValue('PERFORMANCE_TESTS') + print('* {}'.format('{}:'.format(test['Name']))) + print(' {:40} {}'.format('', description[0])) + for i in range(1, len(description)): + print(' {:40} {}'.format('', description[i])) + - print("Available Tests:") - print("================") - for test in testcases: - print('* %-30s %s' % ('%s:' % test['Name'], test['Description'])) - sys.exit(0) def vsperf_finalize(): @@ -539,8 +564,8 @@ def main(): settings.setValue('mode', args['mode']) - # set dpdk and ovs paths according to VNF and VSWITCH - if settings.getValue('mode') != 'trafficgen': + # update paths to trafficgens if required + if settings.getValue('mode') == 'trafficgen': functions.settings_update_paths() # if required, handle list-* operations @@ -591,6 +616,14 @@ def main(): settings.getValue('VNF_DIR')) sys.exit(1) + if args['loadgen']: + loadgens = Loader().get_loadgens() + if args['loadgen'] not in loadgens: + _LOGGER.error('There are no loadgens matching \'%s\' found in' + ' \'%s\'. Exiting...', args['loadgen'], + settings.getValue('LOADGEN_DIR')) + sys.exit(1) + if args['exact_test_name'] and args['tests']: _LOGGER.error("Cannot specify tests with both positional args and --test.") sys.exit(1) @@ -678,6 +711,7 @@ def main(): # testcases.integration.IntegrationTestCase to testcases.performance.PerformanceTestCase # pylint: disable=redefined-variable-type suite = unittest.TestSuite() + settings_snapshot = copy.deepcopy(settings.__dict__) for cfg in selected_tests: test_name = cfg.get('Name', '') try: @@ -692,6 +726,8 @@ def main(): _LOGGER.exception("Failed to run test: %s", test_name) suite.addTest(MockTestCase(str(ex), False, test_name)) _LOGGER.info("Continuing with next test...") + finally: + settings.restore_from_dict(settings_snapshot) # generate final rst report with results of all executed TCs generate_final_report() @@ -708,12 +744,16 @@ def main(): pkg_list = settings.getValue('PACKAGE_LIST') int_data = {'pod': pod_name, - 'criteria': "PASS", 'build_tag': get_build_tag(), 'installer': installer_name, 'pkg_list': pkg_list, - 'db_url': opnfv_url} - opnfvdashboard.results2opnfv_dashboard(results_path, int_data) + 'db_url': opnfv_url, + # pass vswitch name from configuration to be used for failed + # TCs; In case of successful TCs it is safer to use vswitch + # name from CSV as TC can override global configuration + 'vswitch': str(settings.getValue('VSWITCH')).lower()} + tc_names = [tc['Name'] for tc in selected_tests] + opnfvdashboard.results2opnfv_dashboard(tc_names, results_path, int_data) # cleanup before exit vsperf_finalize()