summaryrefslogtreecommitdiffstats
path: root/nfvbench
diff options
context:
space:
mode:
authorKerim Gokarslan <kgokarsl@cisco.com>2017-09-21 15:30:43 -0700
committerKerim Gokarslan <kgokarsl@cisco.com>2017-09-21 17:19:35 -0700
commit97b452affb0e99816ad503a5f79b01f38b93059a (patch)
treeace763fd2eea217a663a73ea3491cb9f97e71aef /nfvbench
parent846250f4c570798a1058dd8d3a405513c4900932 (diff)
NFVBENCH-32 Check nan result values before integer casting
Change-Id: Ia675672b40f93d7503ebe5a355896a084e3d0cbf Signed-off-by: Kerim Gokarslan <kgokarsl@cisco.com>
Diffstat (limited to 'nfvbench')
-rw-r--r--nfvbench/traffic_client.py12
-rw-r--r--nfvbench/traffic_gen/traffic_utils.py1
-rw-r--r--nfvbench/traffic_gen/trex.py28
-rw-r--r--nfvbench/utils.py5
4 files changed, 29 insertions, 17 deletions
diff --git a/nfvbench/traffic_client.py b/nfvbench/traffic_client.py
index 7542d0b..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):
@@ -538,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'] = int(stats[port]['rx']['avg_delay_usec'])
- retDict[port]['rx']['min_delay_usec'] = int(stats[port]['rx']['min_delay_usec'])
- retDict[port]['rx']['max_delay_usec'] = int(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())
@@ -753,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
})
diff --git a/nfvbench/traffic_gen/traffic_utils.py b/nfvbench/traffic_gen/traffic_utils.py
index d3def42..7cf44a8 100644
--- a/nfvbench/traffic_gen/traffic_utils.py
+++ b/nfvbench/traffic_gen/traffic_utils.py
@@ -17,6 +17,7 @@ import bitmath
from traffic_base import AbstractTrafficGenerator
+
def convert_rates(l2frame_size, rate, intf_speed):
avg_packet_size = get_average_packet_size(l2frame_size)
if 'rate_pps' in rate:
diff --git a/nfvbench/traffic_gen/trex.py b/nfvbench/traffic_gen/trex.py
index a9effab..498ff50 100644
--- a/nfvbench/traffic_gen/trex.py
+++ b/nfvbench/traffic_gen/trex.py
@@ -17,6 +17,7 @@ from itertools import count
from nfvbench.log import LOG
from nfvbench.specs import ChainType
from nfvbench.traffic_server import TRexTrafficServer
+from nfvbench.utils import cast_integer
from nfvbench.utils import timeout
from nfvbench.utils import TimeoutError
import os
@@ -73,30 +74,31 @@ class TRex(AbstractTrafficGenerator):
stats = self.__combine_stats(in_stats, ph)
result[ph] = {
'tx': {
- 'total_pkts': int(stats['tx_pkts']['total']),
- 'total_pkt_bytes': int(stats['tx_bytes']['total']),
- 'pkt_rate': int(stats['tx_pps']['total']),
- 'pkt_bit_rate': int(stats['tx_bps']['total'])
+ 'total_pkts': cast_integer(stats['tx_pkts']['total']),
+ 'total_pkt_bytes': cast_integer(stats['tx_bytes']['total']),
+ 'pkt_rate': cast_integer(stats['tx_pps']['total']),
+ 'pkt_bit_rate': cast_integer(stats['tx_bps']['total'])
},
'rx': {
- 'total_pkts': int(stats['rx_pkts']['total']),
- 'total_pkt_bytes': int(stats['rx_bytes']['total']),
- 'pkt_rate': int(stats['rx_pps']['total']),
- 'pkt_bit_rate': int(stats['rx_bps']['total']),
- 'dropped_pkts': int(stats['tx_pkts']['total'] - stats['rx_pkts']['total'])
+ 'total_pkts': cast_integer(stats['rx_pkts']['total']),
+ 'total_pkt_bytes': cast_integer(stats['rx_bytes']['total']),
+ 'pkt_rate': cast_integer(stats['rx_pps']['total']),
+ 'pkt_bit_rate': cast_integer(stats['rx_bps']['total']),
+ 'dropped_pkts': cast_integer(
+ stats['tx_pkts']['total'] - stats['rx_pkts']['total'])
}
}
lat = self.__combine_latencies(in_stats, ph)
- result[ph]['rx']['max_delay_usec'] = int(
+ result[ph]['rx']['max_delay_usec'] = cast_integer(
lat['total_max']) if 'total_max' in lat else float('nan')
- result[ph]['rx']['min_delay_usec'] = int(
+ result[ph]['rx']['min_delay_usec'] = cast_integer(
lat['total_min']) if 'total_min' in lat else float('nan')
- result[ph]['rx']['avg_delay_usec'] = int(
+ result[ph]['rx']['avg_delay_usec'] = cast_integer(
lat['average']) if 'average' in lat else float(
'nan')
total_tx_pkts = result[0]['tx']['total_pkts'] + result[1]['tx']['total_pkts']
- result["total_tx_rate"] = int(total_tx_pkts / self.config.duration_sec)
+ result["total_tx_rate"] = cast_integer(total_tx_pkts / self.config.duration_sec)
return result
def __combine_stats(self, in_stats, port_handle):
diff --git a/nfvbench/utils.py b/nfvbench/utils.py
index 4d9749c..fc72517 100644
--- a/nfvbench/utils.py
+++ b/nfvbench/utils.py
@@ -17,6 +17,7 @@ import fcntl
from functools import wraps
import json
from log import LOG
+from math import isnan
import os
import re
import signal
@@ -141,6 +142,10 @@ def parse_flow_count(flow_count):
return flow_count * multiplier
+def cast_integer(value):
+ return int(value) if not isnan(value) else value
+
+
class RunLock(object):
"""
Attempts to lock file and run current instance of NFVbench as the first,