body['network']['provider:segmentation_id'] = self.segmentation_id
if self.physical_network:
body['network']['provider:physical_network'] = self.physical_network
-
self.network = self.manager.neutron_client.create_network(body)['network']
body = {
'subnet': {'name': network_config.subnet,
self.device = device
self.shared = shared
# RX and TX counters for this interface
+ # A None value can be set to mean that the data is not available
self.tx = 0
self.rx = 0
+ # This is a special field to hold an optional total rx count that is only
+ # used for column aggregation to compute a total intertface stats
+ # Set to non zero to be picked by the add interface stats method for rx total
+ self.rx_total = None
def get_packet_count(self, direction):
"""Get packet count for given direction.
def add_if_stats(self, if_stats):
"""Add another ifstats to this instance."""
- self.tx += if_stats.tx
- self.rx += if_stats.rx
+ def added_counter(old_value, new_value_to_add):
+ if new_value_to_add:
+ if old_value is None:
+ return new_value_to_add
+ return old_value + new_value_to_add
+ return old_value
+
+ self.tx = added_counter(self.tx, if_stats.tx)
+ self.rx = added_counter(self.rx, if_stats.rx)
+ # Add special rx total value if set
+ self.rx = added_counter(self.rx, if_stats.rx_total)
def update_stats(self, tx, rx, diff):
"""Update stats for this interface.
'total': {...}
}
- In the case of shared net, some columns in packets array can have ''
+ In the case of shared net, some columns in packets array can have ''.
+ Some columns cab also be None which means the data is not available.
"""
for stats in chain_stats.values():
packets = stats['packets']
# an empty string indicates an unknown counter for a shared interface
# do not annotate those
annotated_value = ''
+ elif cur_count is None:
+ # Not available
+ annotated_value = 'n/a'
else:
drop = cur_count - prev_count
if drop:
self.udp_src_port = gen_config.udp_src_port
self.udp_dst_port = gen_config.udp_dst_port
self.vteps = gen_config.get('vteps')
- self.vnis = gen_config.get('vnis')
self.devices = [Device(port, self) for port in [0, 1]]
# This should normally always be [0, 1]
self.ports = [device.port for device in self.devices]
# interface stats for the pps because it could have been modified to contain
# additional interface stats
self.gen.get_stream_stats(stats, ifs, self.pps_list[chain_idx].latencies, chain_idx)
-
+ # special handling for vxlan
+ # in case of vxlan, flow stats are not available so all rx counters will be
+ # zeros when the total rx port counter is non zero.
+ # in that case,
+ for port in range(2):
+ total_rx = 0
+ for ifs in self.ifstats:
+ total_rx += ifs[port].rx
+ if total_rx == 0:
+ # check if the total port rx from Trex is also zero
+ port_rx = stats[port]['rx']['total_pkts']
+ if port_rx:
+ # the total rx for all chains from port level stats is non zero
+ # which means that the per-chain stats are not available
+ if len(self.ifstats) == 1:
+ # only one chain, simply report the port level rx to the chain rx stats
+ self.ifstats[0][port].rx = port_rx
+ else:
+ for ifs in self.ifstats:
+ # mark this data as unavailable
+ ifs[port].rx = None
+ # pitch in the total rx only in the last chain pps
+ self.ifstats[-1][port].rx_total = port_rx
@staticmethod
def compare_tx_rates(required, actual):
'total': {'packets': [30000004, 30000004, 30000004, 30000004, 30000004, 30000004]}},
{0: {'packets': [15000002, '', 14000002, 14000002, '', 13000002]},
1: {'packets': [15000002, '', 15000002, 15000002, '', 15000002]},
- 'total': {'packets': [30000004, 29000004, 29000004, 29000004, 29000004, 28000004]}}]
+ 'total': {'packets': [30000004, 29000004, 29000004, 29000004, 29000004, 28000004]}},
+ # example with non-available rx count in last position
+ {0: {'packets': [2000054, 1999996, None]},
+ 1: {'packets': [2000054, 2000054, None]},
+ 'total': {'packets': [4000108, 4000050, 4000050]}}]
XP_CHAIN_STATS = [{0: {'packets': [2000054, '-58 (-0.0029%)', 1999996]}},
{0: {'packets': [2000054, '-58 (-0.0029%)', 1999996]},
1: {'packets': [2000054, '=>', 2000054]},
'-1,000,000 (-7.1429%)']},
1: {'packets': [15000002, '', '=>', '=>', '', 15000002]},
'total': {'packets': [30000004, '-1,000,000 (-3.3333%)', '=>', '=>', '=>',
- '-1,000,000 (-3.4483%)']}}]
+ '-1,000,000 (-3.4483%)']}},
+ {0: {'packets': [2000054, '-58 (-0.0029%)', 'n/a']},
+ 1: {'packets': [2000054, '=>', 'n/a']},
+ 'total': {'packets': [4000108, '-58 (-0.0014%)', 4000050]}}]
def test_summarizer():