X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=nfvbench%2Ftraffic_client.py;h=ec63944d3df9ea2e293eef3acd72c8e3aa495db1;hb=f13f52f0a438f40840775d7e0af0e71f2137dc3c;hp=7c8367afe1b157afc3011b866547b9a33fa91c9e;hpb=5d2becfd9d6398ce9dfd4c83618de42e272ec830;p=nfvbench.git diff --git a/nfvbench/traffic_client.py b/nfvbench/traffic_client.py index 7c8367a..ec63944 100644 --- a/nfvbench/traffic_client.py +++ b/nfvbench/traffic_client.py @@ -25,6 +25,7 @@ from stats_collector import IterationCollector import struct import time import traffic_gen.traffic_utils as utils +from utils import cast_integer class TrafficClientException(Exception): @@ -419,12 +420,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 +539,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()) @@ -640,6 +645,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 @@ -737,7 +757,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 })