X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=VNFs%2FDPPD-PROX%2Fhelper-scripts%2Frapid%2Frapid_parser.py;h=c1ab36a0a196633edf3a8172a6ea99807db23a05;hb=8442f6a8ce0962d818b7cd800150980c65983719;hp=99e0f6970ebf09de1c14d2763906b4564354e216;hpb=8f21fb5ed8231125bca3cec1329d9fd739f14684;p=samplevnf.git diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_parser.py b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_parser.py index 99e0f697..c1ab36a0 100644 --- a/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_parser.py +++ b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_parser.py @@ -1,7 +1,7 @@ #!/usr/bin/python ## -## Copyright (c) 2010-2020 Intel Corporation +## Copyright (c) 2020 Intel Corporation ## ## Licensed under the Apache License, Version 2.0 (the "License"); ## you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ except ImportError: # Python 2.x fallback import ConfigParser as configparser import ast +inf = float("inf") class RapidConfigParser(object): """ @@ -33,25 +34,29 @@ class RapidConfigParser(object): def parse_config(test_params): testconfig = configparser.RawConfigParser() testconfig.read(test_params['test_file']) - test_params['required_number_of_test_machines'] = int(testconfig.get('TestParameters', 'total_number_of_test_machines')) - test_params['number_of_tests'] = int(testconfig.get('TestParameters', 'number_of_tests')) + test_params['required_number_of_test_machines'] = int(testconfig.get( + 'TestParameters', 'total_number_of_test_machines')) + test_params['number_of_tests'] = int(testconfig.get('TestParameters', + 'number_of_tests')) test_params['TestName'] = testconfig.get('TestParameters', 'name') if testconfig.has_option('TestParameters', 'lat_percentile'): - test_params['lat_percentile'] = old_div(float(testconfig.get('TestParameters', 'lat_percentile')),100.0) + test_params['lat_percentile'] = old_div(float( + testconfig.get('TestParameters', 'lat_percentile')),100.0) else: test_params['lat_percentile'] = 0.99 - RapidLog.info('Latency percentile measured at {:.0f}%'.format(test_params['lat_percentile']*100)) + RapidLog.info('Latency percentile at {:.0f}%'.format( + test_params['lat_percentile']*100)) + if testconfig.has_option('TestParameters', 'ipv6'): + test_params['ipv6'] = testconfig.getboolean('TestParameters','ipv6') + else: + test_params['ipv6'] = False config = configparser.RawConfigParser() config.read(test_params['environment_file']) test_params['vim_type'] = config.get('Varia', 'vim') test_params['key'] = config.get('ssh', 'key') test_params['user'] = config.get('ssh', 'user') - test_params['total_number_of_machines'] = int(config.get('rapid', 'total_number_of_machines')) - if config.has_option('TestParameters', 'pushgateway'): - test_params['pushgateway'] = config.get('TestParameters', 'pushgateway') - RapidLog.info('Measurements will be pushed to %s'%test_params['pushgateway']) - else: - test_params['pushgateway'] = None + test_params['total_number_of_machines'] = int(config.get('rapid', + 'total_number_of_machines')) tests = [] test = {} for test_index in range(1, test_params['number_of_tests']+1): @@ -60,11 +65,15 @@ class RapidConfigParser(object): options = testconfig.options(section) for option in options: if option in ['imix','imixs','flows']: - test[option] = ast.literal_eval(testconfig.get(section, option)) -# test[option] = [int(i) for i in test[option]] - elif option in ['maxframespersecondallingress','stepsize']: + test[option] = ast.literal_eval(testconfig.get(section, + option)) + elif option in ['maxframespersecondallingress','stepsize', + 'flowsize']: test[option] = int(testconfig.get(section, option)) - elif option in ['startspeed','drop_rate_threshold','lat_avg_threshold','lat_perc_threshold','lat_max_threshold','accuracy','maxr','maxz','pass_threshold']: + elif option in ['startspeed', 'step', 'drop_rate_threshold', + 'lat_avg_threshold','lat_perc_threshold', + 'lat_max_threshold','accuracy','maxr','maxz', + 'ramp_step']: test[option] = float(testconfig.get(section, option)) else: test[option] = testconfig.get(section, option) @@ -73,37 +82,64 @@ class RapidConfigParser(object): if test['test'] in ['flowsizetest','TST009test']: if 'drop_rate_threshold' not in test.keys(): test['drop_rate_threshold'] = 0 + latency_thresholds = ['lat_avg_threshold','lat_perc_threshold','lat_max_threshold'] + for threshold in latency_thresholds: + if threshold not in test.keys(): + test[threshold] = inf test_params['tests'] = tests - if test_params['required_number_of_test_machines'] > test_params['total_number_of_machines']: + if test_params['required_number_of_test_machines'] > test_params[ + 'total_number_of_machines']: RapidLog.exception("Not enough VMs for this test: %d needed and only %d available" % (required_number_of_test_machines,total_number_of_machines)) raise Exception("Not enough VMs for this test: %d needed and only %d available" % (required_number_of_test_machines,total_number_of_machines)) + map_info = test_params['machine_map_file'].strip('[]').split(',') + map_info_length = len(map_info) + if map_info_length > 1: + if map_info_length < test_params[ + 'required_number_of_test_machines']: + RapidLog.exception('Not enough machine indices in --map \ + parameter: {}. Needing {} entries'.format(map_info, + test_params['required_number_of_test_machines'])) + machine_index = list(map(int,map_info)) + else: + machine_map = configparser.RawConfigParser() + machine_map.read(test_params['machine_map_file']) + machine_index = [] + for test_machine in range(1, + test_params['required_number_of_test_machines']+1): + machine_index.append(int(machine_map.get( + 'TestM%d'%test_machine, 'machine_index'))) machine_map = configparser.RawConfigParser() machine_map.read(test_params['machine_map_file']) machines = [] machine = {} - for test_machine in range(1, test_params['required_number_of_test_machines']+1): + for test_machine in range(1, test_params[ + 'required_number_of_test_machines']+1): machine.clear() - if not(testconfig.has_option('TestM%d'%test_machine, 'prox_socket') and not testconfig.getboolean('TestM%d'%test_machine, 'prox_socket')): - section = 'TestM%d'%test_machine - options = testconfig.options(section) - for option in options: - if option in ['prox_socket','prox_launch_exit','monitor']: - machine[option] = testconfig.getboolean(section, option) - elif option in ['cores', 'gencores','latcores']: - machine[option] = ast.literal_eval(testconfig.get(section, option)) - else: - machine[option] = testconfig.get(section, option) - for key in ['prox_socket','prox_launch_exit']: - if key not in machine.keys(): - machine[key] = True - if 'monitor' not in machine.keys(): - machine['monitor'] = True - index = int(machine_map.get('TestM%d'%test_machine, 'machine_index')) - section = 'M%d'%index - options = config.options(section) - for option in options: - machine[option] = config.get(section, option) - machines.append(dict(machine)) + section = 'TestM%d'%test_machine + options = testconfig.options(section) + for option in options: + if option in ['prox_socket','prox_launch_exit','monitor']: + machine[option] = testconfig.getboolean(section, option) + elif option in ['mcore', 'cores', 'gencores','latcores']: + machine[option] = ast.literal_eval(testconfig.get( + section, option)) + elif option in ['bucket_size_exp']: + machine[option] = int(testconfig.get(section, option)) + if machine[option] < 11: + RapidLog.exception( + "Minimum Value for bucket_size_exp is 11") + else: + machine[option] = testconfig.get(section, option) + for key in ['prox_socket','prox_launch_exit']: + if key not in machine.keys(): + machine[key] = True + if 'monitor' not in machine.keys(): + machine['monitor'] = True + section = 'M%d'%machine_index[test_machine-1] + options = config.options(section) + for option in options: + machine[option] = config.get(section, option) + machines.append(dict(machine)) for machine in machines: dp_ports = [] if 'dest_vm' in machine.keys(): @@ -126,7 +162,7 @@ class RapidConfigParser(object): while True: gw_ip_key = 'dp_ip{}'.format(index) if gw_ip_key in machines[int(machine['gw_vm'])-1].keys(): - gw_ip = machines[int(machine['dest_vm'])-1][gw_ip_key] + gw_ip = machines[int(machine['gw_vm'])-1][gw_ip_key] gw_ips.append(gw_ip) index += 1 else: