X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=nfvbench%2Ftraffic_client.py;h=2a42b876a4e63280c565c51a92783d07715c93af;hb=216233299e082d2f3a67a697be66bb894f23f011;hp=319dc0b2fd37b26e1cb66bc05ba2c73dc408f852;hpb=70e642c54ffbf50e860e87de3bdcb8fa65d8bac4;p=nfvbench.git diff --git a/nfvbench/traffic_client.py b/nfvbench/traffic_client.py index 319dc0b..2a42b87 100644 --- a/nfvbench/traffic_client.py +++ b/nfvbench/traffic_client.py @@ -25,6 +25,8 @@ from stats_collector import IterationCollector import struct import time import traffic_gen.traffic_utils as utils +from trex_stl_lib.api import STLError +from utils import cast_integer class TrafficClientException(Exception): @@ -419,12 +421,13 @@ class TrafficClient(object): # ensures enough traffic is coming back threshold = (self.config.service_chain_count - 1) / float(self.config.service_chain_count) - - for it in xrange(self.config.generic_retry_count): + retry_count = (self.config.check_traffic_time_sec + + self.config.generic_poll_sec - 1) / self.config.generic_poll_sec + for it in xrange(retry_count): self.gen.clear_stats() self.gen.start_traffic() LOG.info('Waiting for packets to be received back... ({} / {})'.format(it + 1, - self.config.generic_retry_count)) + retry_count)) time.sleep(self.config.generic_poll_sec) self.gen.stop_traffic() stats = self.gen.get_stats() @@ -537,9 +540,12 @@ class TrafficClient(object): retDict[port]['rx'][key] = int(stats[port]['rx'][key]) except ValueError: retDict[port]['rx'][key] = 0 - retDict[port]['rx']['avg_delay_usec'] = float(stats[port]['rx']['avg_delay_usec']) - retDict[port]['rx']['min_delay_usec'] = float(stats[port]['rx']['min_delay_usec']) - retDict[port]['rx']['max_delay_usec'] = float(stats[port]['rx']['max_delay_usec']) + retDict[port]['rx']['avg_delay_usec'] = cast_integer( + stats[port]['rx']['avg_delay_usec']) + retDict[port]['rx']['min_delay_usec'] = cast_integer( + stats[port]['rx']['min_delay_usec']) + retDict[port]['rx']['max_delay_usec'] = cast_integer( + stats[port]['rx']['max_delay_usec']) retDict[port]['drop_rate_percent'] = self.__get_dropped_rate(retDict[port]) ports = sorted(retDict.keys()) @@ -609,7 +615,8 @@ class TrafficClient(object): indicating the rate to send on each interface right the right side of the range to search as a % of line rate indicating the rate to send on each interface - targets a dict of drop rates to search (0.1 = 0.1%), indexed by the DR name or "tag" ('ndr', 'pdr') + targets a dict of drop rates to search (0.1 = 0.1%), indexed by the DR name or "tag" + ('ndr', 'pdr') results a dict to store results ''' if len(targets) == 0: @@ -623,8 +630,12 @@ class TrafficClient(object): # Obtain the average drop rate in for middle load middle = (left + right) / 2.0 - stats, rates = self.__run_search_iteration(middle) - + try: + stats, rates = self.__run_search_iteration(middle) + except STLError: + LOG.exception("Got exception from traffic generator during binary search") + self.__targets_found(left, targets, results) + return # Split target dicts based on the avg drop rate left_targets = {} right_targets = {} @@ -639,6 +650,21 @@ class TrafficClient(object): }) right_targets[tag] = target else: + # initialize to 0 all fields of result for + # the worst case scenario of the binary search (if ndr/pdr is not found) + if tag not in results: + results[tag] = dict.fromkeys(rates, 0) + empty_stats = self.__format_output_stats(dict(stats)) + for key in empty_stats: + if isinstance(empty_stats[key], dict): + empty_stats[key] = dict.fromkeys(empty_stats[key], 0) + else: + empty_stats[key] = 0 + results[tag].update({ + 'load_percent_per_direction': 0, + 'stats': empty_stats, + 'timestamp_sec': None + }) left_targets[tag] = target # search lower half @@ -736,7 +762,7 @@ class TrafficClient(object): config['direction-total'] = dict(config['direction-forward']) config['direction-total'].update({ 'rate_percent': load_total, - 'rate_pps': pps_total, + 'rate_pps': cast_integer(pps_total), 'rate_bps': bps_total })