diff options
Diffstat (limited to 'yardstick')
16 files changed, 1588 insertions, 368 deletions
diff --git a/yardstick/benchmark/core/task.py b/yardstick/benchmark/core/task.py index 477dbcc57..afd805f94 100644 --- a/yardstick/benchmark/core/task.py +++ b/yardstick/benchmark/core/task.py @@ -621,7 +621,7 @@ class TaskParser(object): # pragma: no cover scenario: nodes: - tg__0: tg_0.yardstick + tg__0: trafficgen_0.yardstick vnf__0: vnf_0.yardstick NOTE: in Kubernetes context, the separator character between the server diff --git a/yardstick/benchmark/scenarios/networking/vnf_generic.py b/yardstick/benchmark/scenarios/networking/vnf_generic.py index c88ea51c3..c5e75d093 100644 --- a/yardstick/benchmark/scenarios/networking/vnf_generic.py +++ b/yardstick/benchmark/scenarios/networking/vnf_generic.py @@ -627,3 +627,58 @@ class NetworkServiceRFC2544(NetworkServiceBase): output.push(self.collector.get_kpi()) self.collector.stop() + +class NetworkServiceRFC3511(NetworkServiceBase): + """Class handles RFC3511 Network service testing""" + + __scenario_type__ = "NSPerf-RFC3511" + + def __init__(self, scenario_cfg, context_cfg): # pragma: no cover + super(NetworkServiceRFC3511, self).__init__(scenario_cfg, context_cfg) + + def setup(self): + """Setup infrastructure, provision VNFs""" + self.map_topology_to_infrastructure() + self.load_vnf_models() + + traffic_runners = [vnf for vnf in self.vnfs if vnf.runs_traffic] + non_traffic_runners = [vnf for vnf in self.vnfs if not vnf.runs_traffic] + try: + for vnf in chain(traffic_runners, non_traffic_runners): + LOG.info("Instantiating %s", vnf.name) + vnf.instantiate(self.scenario_cfg, self.context_cfg) + LOG.info("Waiting for %s to instantiate", vnf.name) + vnf.wait_for_instantiate() + except: + LOG.exception("") + for vnf in self.vnfs: + vnf.terminate() + raise + + self._generate_pod_yaml() + + def run(self, output): + """ Run experiment + + :param output: scenario output to push results + :return: None + """ + + self._fill_traffic_profile() + + traffic_runners = [vnf for vnf in self.vnfs if vnf.runs_traffic] + + for traffic_gen in traffic_runners: + traffic_gen.listen_traffic(self.traffic_profile) + + self.collector = Collector(self.vnfs, + context_base.Context.get_physical_nodes()) + self.collector.start() + + for traffic_gen in traffic_runners: + LOG.info("Run traffic on %s", traffic_gen.name) + traffic_gen.run_traffic(self.traffic_profile) + + output.push(self.collector.get_kpi()) + + self.collector.stop() diff --git a/yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py b/yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py index ebef7fd9a..89a855480 100644 --- a/yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py +++ b/yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py @@ -94,12 +94,6 @@ class IxNextgen(object): # pragma: no cover "port_name": 'Port Name', "Frames_Tx": 'Frames Tx.', "Valid_Frames_Rx": 'Valid Frames Rx.', - "Frames_Tx_Rate": 'Frames Tx. Rate', - "Valid_Frames_Rx_Rate": 'Valid Frames Rx. Rate', - "Tx_Rate_Kbps": 'Tx. Rate (Kbps)', - "Rx_Rate_Kbps": 'Rx. Rate (Kbps)', - "Tx_Rate_Mbps": 'Tx. Rate (Mbps)', - "Rx_Rate_Mbps": 'Rx. Rate (Mbps)', "Bytes_Tx": 'Bytes Tx.', "Bytes_Rx": 'Bytes Rx.' } diff --git a/yardstick/network_services/traffic_profile/__init__.py b/yardstick/network_services/traffic_profile/__init__.py index 72a61b6b4..c5d8eff0b 100644 --- a/yardstick/network_services/traffic_profile/__init__.py +++ b/yardstick/network_services/traffic_profile/__init__.py @@ -30,6 +30,7 @@ def register_modules(): 'yardstick.network_services.traffic_profile.rfc2544', 'yardstick.network_services.traffic_profile.pktgen', 'yardstick.network_services.traffic_profile.landslide_profile', + 'yardstick.network_services.traffic_profile.vpp_rfc2544', ] for module in modules: diff --git a/yardstick/network_services/traffic_profile/ixia_rfc2544.py b/yardstick/network_services/traffic_profile/ixia_rfc2544.py index 5a9c06aba..ca45b500d 100644 --- a/yardstick/network_services/traffic_profile/ixia_rfc2544.py +++ b/yardstick/network_services/traffic_profile/ixia_rfc2544.py @@ -195,13 +195,13 @@ class IXIARFC2544Profile(trex_traffic_profile.TrexProfile): num_ifaces = len(samples) duration = self.config.duration in_packets_sum = sum( - [samples[iface]['in_packets'] for iface in samples]) + [samples[iface]['InPackets'] for iface in samples]) out_packets_sum = sum( - [samples[iface]['out_packets'] for iface in samples]) + [samples[iface]['OutPackets'] for iface in samples]) in_bytes_sum = sum( - [samples[iface]['in_bytes'] for iface in samples]) + [samples[iface]['InBytes'] for iface in samples]) out_bytes_sum = sum( - [samples[iface]['out_bytes'] for iface in samples]) + [samples[iface]['OutBytes'] for iface in samples]) rx_throughput = round(float(in_packets_sum) / duration, 3) tx_throughput = round(float(out_packets_sum) / duration, 3) # Rx throughput in Bps @@ -243,15 +243,10 @@ class IXIARFC2544Profile(trex_traffic_profile.TrexProfile): "completed=%s", tolerance, precision, drop_percent, completed) - latency_ns_avg = float( - sum([samples[iface]['Store-Forward_Avg_latency_ns'] - for iface in samples])) / num_ifaces - latency_ns_min = float( - sum([samples[iface]['Store-Forward_Min_latency_ns'] - for iface in samples])) / num_ifaces - latency_ns_max = float( - sum([samples[iface]['Store-Forward_Max_latency_ns'] - for iface in samples])) / num_ifaces + latency_ns_avg = float(sum( + [samples[iface]['LatencyAvg'] for iface in samples])) / num_ifaces + latency_ns_min = min([samples[iface]['LatencyMin'] for iface in samples]) + latency_ns_max = max([samples[iface]['LatencyMax'] for iface in samples]) samples['Status'] = self.STATUS_FAIL if round(drop_percent, precision) <= tolerance: @@ -262,9 +257,9 @@ class IXIARFC2544Profile(trex_traffic_profile.TrexProfile): samples['TxThroughputBps'] = tx_throughput_bps samples['RxThroughputBps'] = rx_throughput_bps samples['DropPercentage'] = drop_percent - samples['latency_ns_avg'] = latency_ns_avg - samples['latency_ns_min'] = latency_ns_min - samples['latency_ns_max'] = latency_ns_max + samples['LatencyAvg'] = latency_ns_avg + samples['LatencyMin'] = latency_ns_min + samples['LatencyMax'] = latency_ns_max samples['Rate'] = last_rate samples['PktSize'] = self._get_framesize() samples['Iteration'] = self.iteration @@ -315,10 +310,10 @@ class IXIARFC2544PppoeScenarioProfile(IXIARFC2544Profile): drop_percent = 100 for prio_id in stats: prio_flow = stats[prio_id] - sum_packet_drop = abs(prio_flow['out_packets'] - prio_flow['in_packets']) + sum_packet_drop = abs(prio_flow['OutPackets'] - prio_flow['InPackets']) try: drop_percent = round( - (sum_packet_drop / float(prio_flow['out_packets'])) * 100, + (sum_packet_drop / float(prio_flow['OutPackets'])) * 100, self.DROP_PERCENT_ROUND) except ZeroDivisionError: LOG.info('No traffic is flowing') @@ -327,10 +322,10 @@ class IXIARFC2544PppoeScenarioProfile(IXIARFC2544Profile): def _get_summary_pppoe_subs_counters(self, samples): result = {} - keys = ['sessions_up', - 'sessions_down', - 'sessions_not_started', - 'sessions_total'] + keys = ['SessionsUp', + 'SessionsDown', + 'SessionsNotStarted', + 'SessionsTotal'] for key in keys: result[key] = \ sum([samples[port][key] for port in samples @@ -348,13 +343,13 @@ class IXIARFC2544PppoeScenarioProfile(IXIARFC2544Profile): priority_stats = self._get_prio_flows_drop_percentage(priority_stats) summary_subs_stats = self._get_summary_pppoe_subs_counters(samples) in_packets_sum = sum( - [samples[iface]['in_packets'] for iface in samples]) + [samples[iface]['InPackets'] for iface in samples]) out_packets_sum = sum( - [samples[iface]['out_packets'] for iface in samples]) + [samples[iface]['OutPackets'] for iface in samples]) in_bytes_sum = sum( - [samples[iface]['in_bytes'] for iface in samples]) + [samples[iface]['InBytes'] for iface in samples]) out_bytes_sum = sum( - [samples[iface]['out_bytes'] for iface in samples]) + [samples[iface]['OutBytes'] for iface in samples]) rx_throughput = round(float(in_packets_sum) / duration, 3) tx_throughput = round(float(out_packets_sum) / duration, 3) # Rx throughput in Bps @@ -370,25 +365,20 @@ class IXIARFC2544PppoeScenarioProfile(IXIARFC2544Profile): except ZeroDivisionError: LOG.info('No traffic is flowing') - latency_ns_avg = float( - sum([samples[iface]['Store-Forward_Avg_latency_ns'] - for iface in samples])) / num_ifaces - latency_ns_min = float( - sum([samples[iface]['Store-Forward_Min_latency_ns'] - for iface in samples])) / num_ifaces - latency_ns_max = float( - sum([samples[iface]['Store-Forward_Max_latency_ns'] - for iface in samples])) / num_ifaces + latency_ns_avg = float(sum( + [samples[iface]['LatencyAvg'] for iface in samples])) / num_ifaces + latency_ns_min = min([samples[iface]['LatencyMin'] for iface in samples]) + latency_ns_max = max([samples[iface]['LatencyMax'] for iface in samples]) samples['TxThroughput'] = tx_throughput samples['RxThroughput'] = rx_throughput samples['TxThroughputBps'] = tx_throughput_bps samples['RxThroughputBps'] = rx_throughput_bps samples['DropPercentage'] = sum_drop_percent - samples['latency_ns_avg'] = latency_ns_avg - samples['latency_ns_min'] = latency_ns_min - samples['latency_ns_max'] = latency_ns_max - samples['priority'] = priority_stats + samples['LatencyAvg'] = latency_ns_avg + samples['LatencyMin'] = latency_ns_min + samples['LatencyMax'] = latency_ns_max + samples['Priority'] = priority_stats samples['Rate'] = last_rate samples['PktSize'] = self._get_framesize() samples['Iteration'] = self.iteration @@ -397,7 +387,7 @@ class IXIARFC2544PppoeScenarioProfile(IXIARFC2544Profile): if tc_rfc2544_opts: priority = tc_rfc2544_opts.get('priority') if priority: - drop_percent = samples['priority'][priority]['DropPercentage'] + drop_percent = samples['Priority'][priority]['DropPercentage'] else: drop_percent = sum_drop_percent else: diff --git a/yardstick/network_services/traffic_profile/rfc2544.py b/yardstick/network_services/traffic_profile/rfc2544.py index b12fa9360..aaa491b75 100644 --- a/yardstick/network_services/traffic_profile/rfc2544.py +++ b/yardstick/network_services/traffic_profile/rfc2544.py @@ -82,7 +82,6 @@ class RFC2544Profile(trex_traffic_profile.TrexProfile): self.rate = self.config.frame_rate self.max_rate = self.config.frame_rate self.min_rate = 0 - self.drop_percent_max = 0 def register_generator(self, generator): self.generator = generator @@ -275,7 +274,7 @@ class RFC2544Profile(trex_traffic_profile.TrexProfile): return streams def get_drop_percentage(self, samples, tol_low, tol_high, - correlated_traffic, resolution): + correlated_traffic, resolution): # pylint: disable=unused-argument """Calculate the drop percentage and run the traffic""" completed = False status = self.STATUS_FAIL @@ -321,26 +320,43 @@ class RFC2544Profile(trex_traffic_profile.TrexProfile): LOG.debug("rate=%s, next_rate=%s, resolution=%s, completed=%s", last_rate, self.rate, resolution, completed) - throughput = rx_rate_fps * 2 if correlated_traffic else rx_rate_fps - - if drop_percent > self.drop_percent_max: - self.drop_percent_max = drop_percent - - latency = {port_num: value['latency'] - for port_num, value in samples[-1].items()} - - output = { - 'TxThroughput': tx_rate_fps, - 'RxThroughput': rx_rate_fps, - 'RxThroughputBps': round(float(in_bytes) / time_diff, 3), - 'TxThroughputBps': round(float(out_bytes) / time_diff, 3), - 'CurrentDropPercentage': drop_percent, - 'Throughput': throughput, - 'DropPercentage': self.drop_percent_max, - 'Rate': last_rate, - 'Latency': latency, - 'PktSize': self._get_framesize(), - 'Iteration': self.iteration, - 'Status': status - } + ports = samples[-1].keys() + num_ports = len(ports) + + output = {} + for port in ports: + output[port] = {} + first = samples[0][port] + last = samples[-1][port] + output[port]['InPackets'] = last['in_packets'] - first['in_packets'] + output[port]['OutPackets'] = last['out_packets'] - first['out_packets'] + output[port]['InBytes'] = last['in_bytes'] - first['in_bytes'] + output[port]['OutBytes'] = last['out_bytes'] - first['out_bytes'] + if self.config.enable_latency: + output[port]['LatencyAvg'] = float(sum( + [last['latency'][id]['average'] for id in + last['latency']]) * 1000) / len(last['latency']) + output[port]['LatencyMin'] = min( + [last['latency'][id]['total_min'] for id in + last['latency']]) * 1000 + output[port]['LatencyMax'] = max( + [last['latency'][id]['total_max'] for id in + last['latency']]) * 1000 + + output['TxThroughput'] = tx_rate_fps + output['RxThroughput'] = rx_rate_fps + output['RxThroughputBps'] = round(float(in_bytes) / time_diff, 3) + output['TxThroughputBps'] = round(float(out_bytes) / time_diff, 3) + output['DropPercentage'] = drop_percent + output['Rate'] = last_rate + output['PktSize'] = self._get_framesize() + output['Iteration'] = self.iteration + output['Status'] = status + + if self.config.enable_latency: + output['LatencyAvg'] = float( + sum([output[port]['LatencyAvg'] for port in ports])) / num_ports + output['LatencyMin'] = min([output[port]['LatencyMin'] for port in ports]) + output['LatencyMax'] = max([output[port]['LatencyMax'] for port in ports]) + return completed, output diff --git a/yardstick/network_services/traffic_profile/vpp_rfc2544.py b/yardstick/network_services/traffic_profile/vpp_rfc2544.py new file mode 100644 index 000000000..0f8185f90 --- /dev/null +++ b/yardstick/network_services/traffic_profile/vpp_rfc2544.py @@ -0,0 +1,321 @@ +# Copyright (c) 2019 Viosoft Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import datetime +import logging +from random import choice +from string import ascii_letters + +from ipaddress import ip_address +from trex_stl_lib import api as Pkt +from trex_stl_lib import trex_stl_client +from trex_stl_lib import trex_stl_packet_builder_scapy +from trex_stl_lib import trex_stl_streams + +from yardstick.common import constants +from yardstick.network_services.traffic_profile.rfc2544 import RFC2544Profile, \ + PortPgIDMap +from yardstick.network_services.traffic_profile.trex_traffic_profile import IP, \ + DST + +LOGGING = logging.getLogger(__name__) + + +class VppRFC2544Profile(RFC2544Profile): + + def __init__(self, traffic_generator): + super(VppRFC2544Profile, self).__init__(traffic_generator) + + self.duration = self.config.duration + self.precision = self.config.test_precision + self.lower_bound = self.config.lower_bound + self.upper_bound = self.config.upper_bound + self.step_interval = self.config.step_interval + self.enable_latency = self.config.enable_latency + + self.pkt_size = None + self.flow = None + + self.tolerance_low = 0 + self.tolerance_high = 0 + + self.queue = None + self.port_pg_id = None + + self.current_lower = self.lower_bound + self.current_upper = self.upper_bound + + self.ports = [] + self.profiles = {} + + @property + def delta(self): + return self.current_upper - self.current_lower + + @property + def mid_point(self): + return (self.current_lower + self.current_upper) / 2 + + @staticmethod + def calculate_frame_size(imix): + if not imix: + return 64, 100 + + imix_count = {size.upper().replace('B', ''): int(weight) + for size, weight in imix.items()} + imix_sum = sum(imix_count.values()) + if imix_sum <= 0: + return 64, 100 + packets_total = sum([int(size) * weight + for size, weight in imix_count.items()]) + return packets_total / imix_sum, imix_sum + + @staticmethod + def _gen_payload(length): + payload = "" + for _ in range(length): + payload += choice(ascii_letters) + + return payload + + def bounds_iterator(self, logger=None): + self.current_lower = self.lower_bound + self.current_upper = self.upper_bound + + test_value = self.current_upper + while abs(self.delta) >= self.precision: + if logger: + logger.debug("New interval [%s, %s), precision: %d", + self.current_lower, + self.current_upper, self.step_interval) + logger.info("Testing with value %s", test_value) + + yield test_value + test_value = self.mid_point + + def register_generator(self, generator): + super(VppRFC2544Profile, self).register_generator(generator) + self.init_traffic_params(generator) + + def init_queue(self, queue): + self.queue = queue + self.queue.cancel_join_thread() + + def init_traffic_params(self, generator): + if generator.rfc2544_helper.latency: + self.enable_latency = True + self.tolerance_low = generator.rfc2544_helper.tolerance_low + self.tolerance_high = generator.rfc2544_helper.tolerance_high + self.max_rate = generator.scenario_helper.all_options.get('vpp_config', + {}).get( + 'max_rate', self.rate) + + def create_profile(self, profile_data, current_port): + streams = [] + for packet_name in profile_data: + imix = (profile_data[packet_name]. + get('outer_l2', {}).get('framesize')) + self.pkt_size, imix_sum = self.calculate_frame_size(imix) + self._create_vm(profile_data[packet_name]) + if self.max_rate > 100: + imix_data = self._create_imix_data(imix, + constants.DISTRIBUTION_IN_PACKETS) + else: + imix_data = self._create_imix_data(imix) + _streams = self._create_single_stream(current_port, imix_data, + imix_sum) + streams.extend(_streams) + return trex_stl_streams.STLProfile(streams) + + def _set_outer_l3v4_fields(self, outer_l3v4): + """ setup outer l3v4 fields from traffic profile """ + ip_params = {} + if 'proto' in outer_l3v4: + ip_params['proto'] = outer_l3v4['proto'] + self._set_proto_fields(IP, **ip_params) + + self.flow = int(outer_l3v4['count']) + src_start_ip, _ = outer_l3v4['srcip4'].split('-') + dst_start_ip, _ = outer_l3v4['dstip4'].split('-') + + self.ip_packet = Pkt.IP(src=src_start_ip, + dst=dst_start_ip, + proto=outer_l3v4['proto']) + if self.flow > 1: + dst_start_int = int(ip_address(str(dst_start_ip))) + dst_end_ip_new = ip_address(dst_start_int + self.flow - 1) + # self._set_proto_addr(IP, SRC, outer_l3v4['srcip4'], outer_l3v4['count']) + self._set_proto_addr(IP, DST, + "{start_ip}-{end_ip}".format( + start_ip=dst_start_ip, + end_ip=str(dst_end_ip_new)), + self.flow) + + def _create_single_packet(self, size=64): + ether_packet = self.ether_packet + ip_packet = self.ip6_packet if self.ip6_packet else self.ip_packet + base_pkt = ether_packet / ip_packet + payload_len = max(0, size - len(base_pkt) - 4) + packet = trex_stl_packet_builder_scapy.STLPktBuilder( + pkt=base_pkt / self._gen_payload(payload_len), + vm=self.trex_vm) + packet_lat = trex_stl_packet_builder_scapy.STLPktBuilder( + pkt=base_pkt / self._gen_payload(payload_len)) + + return packet, packet_lat + + def _create_single_stream(self, current_port, imix_data, imix_sum, + isg=0.0): + streams = [] + for size, weight in ((int(size), float(weight)) for (size, weight) + in imix_data.items() if float(weight) > 0): + if current_port == 1: + isg += 10.0 + if self.max_rate > 100: + mode = trex_stl_streams.STLTXCont( + pps=int(weight * imix_sum / 100)) + mode_lat = mode + else: + mode = trex_stl_streams.STLTXCont( + percentage=weight * self.max_rate / 100) + mode_lat = trex_stl_streams.STLTXCont(pps=9000) + + packet, packet_lat = self._create_single_packet(size) + streams.append( + trex_stl_client.STLStream(isg=isg, packet=packet, mode=mode)) + if self.enable_latency: + pg_id = self.port_pg_id.increase_pg_id(current_port) + stl_flow = trex_stl_streams.STLFlowLatencyStats(pg_id=pg_id) + stream_lat = trex_stl_client.STLStream(isg=isg, + packet=packet_lat, + mode=mode_lat, + flow_stats=stl_flow) + streams.append(stream_lat) + return streams + + def execute_traffic(self, traffic_generator=None): + if traffic_generator is not None and self.generator is None: + self.generator = traffic_generator + + self.ports = [] + self.profiles = {} + self.port_pg_id = PortPgIDMap() + for vld_id, intfs in sorted(self.generator.networks.items()): + profile_data = self.params.get(vld_id) + if not profile_data: + continue + if (vld_id.startswith(self.DOWNLINK) and + self.generator.rfc2544_helper.correlated_traffic): + continue + for intf in intfs: + current_port = int(self.generator.port_num(intf)) + self.port_pg_id.add_port(current_port) + profile = self.create_profile(profile_data, current_port) + self.generator.client.add_streams(profile, + ports=[current_port]) + + self.ports.append(current_port) + self.profiles[current_port] = profile + + timeout = self.generator.scenario_helper.scenario_cfg["runner"][ + "duration"] + test_data = { + "test_duration": timeout, + "test_precision": self.precision, + "tolerated_loss": self.tolerance_high, + "duration": self.duration, + "packet_size": self.pkt_size, + "flow": self.flow + } + + if self.max_rate > 100: + self.binary_search_with_optimized(self.generator, self.duration, + timeout, test_data) + else: + self.binary_search(self.generator, self.duration, + self.tolerance_high, test_data) + + def binary_search_with_optimized(self, traffic_generator, duration, + timeout, test_data): + # TODO Support FD.io Multiple Loss Ratio search (MLRsearch) + pass + + def binary_search(self, traffic_generator, duration, tolerance_value, + test_data): + theor_max_thruput = 0 + result_samples = {} + + for test_value in self.bounds_iterator(LOGGING): + stats = traffic_generator.send_traffic_on_tg(self.ports, + self.port_pg_id, + duration, + str( + test_value / self.max_rate / 2), + latency=self.enable_latency) + traffic_generator.client.reset(ports=self.ports) + traffic_generator.client.clear_stats(ports=self.ports) + traffic_generator.client.remove_all_streams(ports=self.ports) + for port, profile in self.profiles.items(): + traffic_generator.client.add_streams(profile, ports=[port]) + + loss_ratio = (float(traffic_generator.loss) / float( + traffic_generator.sent)) * 100 + + samples = traffic_generator.generate_samples(stats, self.ports, + self.port_pg_id, + self.enable_latency) + samples.update(test_data) + LOGGING.info("Collect TG KPIs %s %s %s", datetime.datetime.now(), + test_value, samples) + self.queue.put(samples) + + if float(loss_ratio) > float(tolerance_value): + LOGGING.debug("Failure... Decreasing upper bound") + self.current_upper = test_value + else: + LOGGING.debug("Success! Increasing lower bound") + self.current_lower = test_value + + rate_total = float(traffic_generator.sent) / float(duration) + bandwidth_total = float(rate_total) * ( + float(self.pkt_size) + 20) * 8 / (10 ** 9) + + success_samples = {'Result_' + key: value for key, value in + samples.items()} + success_samples["Result_{}".format('PDR')] = { + "rate_total_pps": float(rate_total), + "bandwidth_total_Gbps": float(bandwidth_total), + "packet_loss_ratio": float(loss_ratio), + "packets_lost": int(traffic_generator.loss), + } + self.queue.put(success_samples) + + # Store Actual throughput for result samples + for intf in traffic_generator.vnfd_helper.interfaces: + name = intf["name"] + result_samples[name] = { + "Result_Actual_throughput": float( + success_samples["Result_{}".format(name)][ + "rx_throughput_bps"]), + } + + for intf in traffic_generator.vnfd_helper.interfaces: + name = intf["name"] + if theor_max_thruput < samples[name]["tx_throughput_bps"]: + theor_max_thruput = samples[name]['tx_throughput_bps'] + self.queue.put({'theor_max_throughput': theor_max_thruput}) + + result_samples["Result_theor_max_throughput"] = theor_max_thruput + self.queue.put(result_samples) + return result_samples diff --git a/yardstick/network_services/vnf_generic/vnf/sample_vnf.py b/yardstick/network_services/vnf_generic/vnf/sample_vnf.py index 2a477bb8d..a369a3ae6 100644 --- a/yardstick/network_services/vnf_generic/vnf/sample_vnf.py +++ b/yardstick/network_services/vnf_generic/vnf/sample_vnf.py @@ -719,8 +719,8 @@ class SampleVNF(GenericVNF): scenarios: - type: NSPerf nodes: - tg__0: trafficgen_1.yardstick - vnf__0: vnf.yardstick + tg__0: trafficgen_0.yardstick + vnf__0: vnf_0.yardstick options: collectd: <options> # COLLECTD priority 3 diff --git a/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_ixia.py b/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_ixia.py index 5d64a8cba..80812876d 100644 --- a/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_ixia.py +++ b/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_ixia.py @@ -80,21 +80,17 @@ class IxiaBasicScenario(object): min_latency = stats['Store-Forward_Min_latency_ns'][port_num] max_latency = stats['Store-Forward_Max_latency_ns'][port_num] samples[port_name] = { - 'rx_throughput_kps': float(stats['Rx_Rate_Kbps'][port_num]), - 'tx_throughput_kps': float(stats['Tx_Rate_Kbps'][port_num]), - 'rx_throughput_mbps': float(stats['Rx_Rate_Mbps'][port_num]), - 'tx_throughput_mbps': float(stats['Tx_Rate_Mbps'][port_num]), 'RxThroughputBps': float(stats['Bytes_Rx'][port_num]) / duration, 'TxThroughputBps': float(stats['Bytes_Tx'][port_num]) / duration, - 'in_packets': int(stats['Valid_Frames_Rx'][port_num]), - 'out_packets': int(stats['Frames_Tx'][port_num]), - 'in_bytes': int(stats['Bytes_Rx'][port_num]), - 'out_bytes': int(stats['Bytes_Tx'][port_num]), + 'InPackets': int(stats['Valid_Frames_Rx'][port_num]), + 'OutPackets': int(stats['Frames_Tx'][port_num]), + 'InBytes': int(stats['Bytes_Rx'][port_num]), + 'OutBytes': int(stats['Bytes_Tx'][port_num]), 'RxThroughput': float(stats['Valid_Frames_Rx'][port_num]) / duration, 'TxThroughput': float(stats['Frames_Tx'][port_num]) / duration, - 'Store-Forward_Avg_latency_ns': utils.safe_cast(avg_latency, int, 0), - 'Store-Forward_Min_latency_ns': utils.safe_cast(min_latency, int, 0), - 'Store-Forward_Max_latency_ns': utils.safe_cast(max_latency, int, 0) + 'LatencyAvg': utils.safe_cast(avg_latency, int, 0), + 'LatencyMin': utils.safe_cast(min_latency, int, 0), + 'LatencyMax': utils.safe_cast(max_latency, int, 0) } except IndexError: pass @@ -524,22 +520,22 @@ class IxiaPppoeClientScenario(object): avg_latency_ns = sum( [int(flow['Store-Forward_Avg_latency_ns']) for flow in samples if flow['IP_Priority'] == priority]) / prio_flows_num - min_latency_ns = sum( + min_latency_ns = min( [int(flow['Store-Forward_Min_latency_ns']) for flow in samples - if flow['IP_Priority'] == priority]) / prio_flows_num - max_latency_ns = sum( + if flow['IP_Priority'] == priority]) + max_latency_ns = max( [int(flow['Store-Forward_Max_latency_ns']) for flow in samples - if flow['IP_Priority'] == priority]) / prio_flows_num + if flow['IP_Priority'] == priority]) tx_throughput = float(tx_frames) / duration rx_throughput = float(rx_frames) / duration results[priority] = { - 'in_packets': rx_frames, - 'out_packets': tx_frames, + 'InPackets': rx_frames, + 'OutPackets': tx_frames, 'RxThroughput': round(rx_throughput, 3), 'TxThroughput': round(tx_throughput, 3), - 'avg_latency_ns': utils.safe_cast(avg_latency_ns, int, 0), - 'min_latency_ns': utils.safe_cast(min_latency_ns, int, 0), - 'max_latency_ns': utils.safe_cast(max_latency_ns, int, 0) + 'LatencyAvg': utils.safe_cast(avg_latency_ns, int, 0), + 'LatencyMin': utils.safe_cast(min_latency_ns, int, 0), + 'LatencyMax': utils.safe_cast(max_latency_ns, int, 0) } return results @@ -600,38 +596,34 @@ class IxiaPppoeClientScenario(object): flows_stats, flow, 'Store-Forward_Avg_latency_ns')) for flow in port_flow_map[port_num]]) / len(port_flow_map[port_num]) min_latency = \ - sum([float(self.get_flow_id_data( + min([float(self.get_flow_id_data( flows_stats, flow, 'Store-Forward_Min_latency_ns')) - for flow in port_flow_map[port_num]]) / len(port_flow_map[port_num]) + for flow in port_flow_map[port_num]]) max_latency = \ - sum([float(self.get_flow_id_data( + max([float(self.get_flow_id_data( flows_stats, flow, 'Store-Forward_Max_latency_ns')) - for flow in port_flow_map[port_num]]) / len(port_flow_map[port_num]) + for flow in port_flow_map[port_num]]) samples[port_name] = { - 'rx_throughput_kps': float(ports_stats[port_num]['Rx_Rate_Kbps']), - 'tx_throughput_kps': float(ports_stats[port_num]['Tx_Rate_Kbps']), - 'rx_throughput_mbps': float(ports_stats[port_num]['Rx_Rate_Mbps']), - 'tx_throughput_mbps': float(ports_stats[port_num]['Tx_Rate_Mbps']), 'RxThroughputBps': float(ports_stats[port_num]['Bytes_Rx']) / duration, 'TxThroughputBps': float(ports_stats[port_num]['Bytes_Tx']) / duration, - 'in_packets': int(ports_stats[port_num]['Valid_Frames_Rx']), - 'out_packets': int(ports_stats[port_num]['Frames_Tx']), - 'in_bytes': int(ports_stats[port_num]['Bytes_Rx']), - 'out_bytes': int(ports_stats[port_num]['Bytes_Tx']), + 'InPackets': int(ports_stats[port_num]['Valid_Frames_Rx']), + 'OutPackets': int(ports_stats[port_num]['Frames_Tx']), + 'InBytes': int(ports_stats[port_num]['Bytes_Rx']), + 'OutBytes': int(ports_stats[port_num]['Bytes_Tx']), 'RxThroughput': float(ports_stats[port_num]['Valid_Frames_Rx']) / duration, 'TxThroughput': float(ports_stats[port_num]['Frames_Tx']) / duration, - 'Store-Forward_Avg_latency_ns': utils.safe_cast(avg_latency, int, 0), - 'Store-Forward_Min_latency_ns': utils.safe_cast(min_latency, int, 0), - 'Store-Forward_Max_latency_ns': utils.safe_cast(max_latency, int, 0) + 'LatencyAvg': utils.safe_cast(avg_latency, int, 0), + 'LatencyMin': utils.safe_cast(min_latency, int, 0), + 'LatencyMax': utils.safe_cast(max_latency, int, 0) } if port_subs_stats: samples[port_name].update( - {'sessions_up': int(port_subs_stats[0]['Sessions_Up']), - 'sessions_down': int(port_subs_stats[0]['Sessions_Down']), - 'sessions_not_started': int(port_subs_stats[0]['Sessions_Not_Started']), - 'sessions_total': int(port_subs_stats[0]['Sessions_Total'])} + {'SessionsUp': int(port_subs_stats[0]['Sessions_Up']), + 'SessionsDown': int(port_subs_stats[0]['Sessions_Down']), + 'SessionsNotStarted': int(port_subs_stats[0]['Sessions_Not_Started']), + 'SessionsTotal': int(port_subs_stats[0]['Sessions_Total'])} ) except IndexError: diff --git a/yardstick/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py b/yardstick/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py index ff8ce5796..cf9a26a76 100644 --- a/yardstick/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py +++ b/yardstick/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py @@ -159,7 +159,7 @@ TRAFFIC_PROFILE = { class TestNetworkServiceTestCase(unittest.TestCase): def setUp(self): - self.tg__1 = { + self.tg__0 = { 'name': 'trafficgen_1.yardstick', 'ip': '10.10.10.11', 'role': 'TrafficGen', @@ -185,7 +185,7 @@ class TestNetworkServiceTestCase(unittest.TestCase): }, } - self.vnf__1 = { + self.vnf__0 = { 'name': 'vnf.yardstick', 'ip': '10.10.10.12', 'host': '10.223.197.164', @@ -242,8 +242,8 @@ class TestNetworkServiceTestCase(unittest.TestCase): self.context_cfg = { 'nodes': { - 'tg__1': self.tg__1, - 'vnf__1': self.vnf__1, + 'tg__0': self.tg__0, + 'vnf__0': self.vnf__0, }, 'networks': { GenericVNF.UPLINK: { @@ -270,7 +270,7 @@ class TestNetworkServiceTestCase(unittest.TestCase): ], 'type': 'ELAN', 'id': GenericVNF.UPLINK, - 'name': 'tg__1 to vnf__1 link 1' + 'name': 'tg__0 to vnf__0 link 1' } self.vld1 = { @@ -288,7 +288,7 @@ class TestNetworkServiceTestCase(unittest.TestCase): ], 'type': 'ELAN', 'id': GenericVNF.DOWNLINK, - 'name': 'vnf__1 to tg__1 link 2' + 'name': 'vnf__0 to tg__0 link 2' } self.topology = { @@ -300,12 +300,12 @@ class TestNetworkServiceTestCase(unittest.TestCase): { 'member-vnf-index': '1', 'VNF model': 'tg_trex_tpl.yaml', - 'vnfd-id-ref': 'tg__1', + 'vnfd-id-ref': 'tg__0', }, { 'member-vnf-index': '2', 'VNF model': 'tg_trex_tpl.yaml', - 'vnfd-id-ref': 'vnf__1', + 'vnfd-id-ref': 'vnf__0', }, ], 'vld': [self.vld0, self.vld1], @@ -343,8 +343,8 @@ class TestNetworkServiceTestCase(unittest.TestCase): }, 'nodes': { 'tg__2': 'trafficgen_2.yardstick', - 'tg__1': 'trafficgen_1.yardstick', - 'vnf__1': 'vnf.yardstick', + 'tg__0': 'trafficgen_1.yardstick', + 'vnf__0': 'vnf.yardstick', }, } @@ -411,12 +411,12 @@ class TestNetworkServiceTestCase(unittest.TestCase): 'flow': { 'src_ip': [ { - 'tg__1': 'xe0', + 'tg__0': 'xe0', }, ], 'dst_ip': [ { - 'tg__1': 'xe1', + 'tg__0': 'xe1', }, ], 'public_ip': ['1.1.1.1'], @@ -446,9 +446,9 @@ class TestNetworkServiceTestCase(unittest.TestCase): self.assertIn('found in', exc_str) def test_load_vnf_models_invalid(self): - self.context_cfg["nodes"]['tg__1']['VNF model'] = \ + self.context_cfg["nodes"]['tg__0']['VNF model'] = \ self._get_file_abspath("tg_trex_tpl.yaml") - self.context_cfg["nodes"]['vnf__1']['VNF model'] = \ + self.context_cfg["nodes"]['vnf__0']['VNF model'] = \ self._get_file_abspath("tg_trex_tpl.yaml") vnf = mock.Mock(autospec=GenericVNF) @@ -469,13 +469,13 @@ class TestNetworkServiceTestCase(unittest.TestCase): nodes = self.context_cfg["nodes"] self.assertEqual('../../vnf_descriptors/tg_rfc2544_tpl.yaml', - nodes['tg__1']['VNF model']) + nodes['tg__0']['VNF model']) self.assertEqual('../../vnf_descriptors/vpe_vnf.yaml', - nodes['vnf__1']['VNF model']) + nodes['vnf__0']['VNF model']) def test_map_topology_to_infrastructure_insufficient_nodes(self): cfg = deepcopy(self.context_cfg) - del cfg['nodes']['vnf__1'] + del cfg['nodes']['vnf__0'] cfg_patch = mock.patch.object(self.s, 'context_cfg', cfg) with cfg_patch: @@ -489,10 +489,10 @@ class TestNetworkServiceTestCase(unittest.TestCase): cfg = deepcopy(self.s.context_cfg) # delete all, we don't know which will come first - del cfg['nodes']['vnf__1']['interfaces']['xe0']['local_mac'] - del cfg['nodes']['vnf__1']['interfaces']['xe1']['local_mac'] - del cfg['nodes']['tg__1']['interfaces']['xe0']['local_mac'] - del cfg['nodes']['tg__1']['interfaces']['xe1']['local_mac'] + del cfg['nodes']['vnf__0']['interfaces']['xe0']['local_mac'] + del cfg['nodes']['vnf__0']['interfaces']['xe1']['local_mac'] + del cfg['nodes']['tg__0']['interfaces']['xe0']['local_mac'] + del cfg['nodes']['tg__0']['interfaces']['xe1']['local_mac'] config_patch = mock.patch.object(self.s, 'context_cfg', cfg) with config_patch: @@ -507,7 +507,7 @@ class TestNetworkServiceTestCase(unittest.TestCase): ssh.from_node.return_value = ssh_mock # purge an important key from the data structure - for interface in self.tg__1['interfaces'].values(): + for interface in self.tg__0['interfaces'].values(): del interface['local_mac'] with self.assertRaises(exceptions.IncorrectConfig) as raised: @@ -516,7 +516,7 @@ class TestNetworkServiceTestCase(unittest.TestCase): self.assertIn('not found', str(raised.exception)) # restore local_mac - for index, interface in enumerate(self.tg__1['interfaces'].values()): + for index, interface in enumerate(self.tg__0['interfaces'].values()): interface['local_mac'] = '00:00:00:00:00:{:2x}'.format(index) # make a connection point ref with 3 points @@ -820,3 +820,54 @@ class TestNetworkServiceRFC2544TestCase(TestNetworkServiceTestCase): mock.Mock(return_value=TRAFFIC_PROFILE) with self.assertRaises(RuntimeError): self.s.setup() + +class TestNetworkServiceRFC3511TestCase(TestNetworkServiceTestCase): + + def setUp(self): + super(TestNetworkServiceRFC3511TestCase, self).setUp() + self.s = vnf_generic.NetworkServiceRFC3511(self.scenario_cfg, + self.context_cfg) + + def test_run(self): + tgen = mock.Mock(autospec=GenericTrafficGen) + tgen.traffic_finished = True + verified_dict = {"verified": True} + tgen.verify_traffic = lambda x: verified_dict + tgen.name = "tgen__1" + vnf = mock.Mock(autospec=GenericVNF) + vnf.runs_traffic = False + self.s.vnfs = [tgen, vnf] + self.s.traffic_profile = mock.Mock() + self.s._fill_traffic_profile = mock.Mock() + self.s.collector = mock.Mock(autospec=Collector) + self.s.collector.get_kpi = mock.Mock() + result = mock.Mock() + self.s.run(result) + self.s._fill_traffic_profile.assert_called_once() + result.push.assert_called_once() + + def test_setup(self): + with mock.patch("yardstick.ssh.SSH") as ssh: + ssh_mock = mock.Mock(autospec=ssh.SSH) + ssh_mock.execute = \ + mock.Mock(return_value=(0, SYS_CLASS_NET + IP_ADDR_SHOW, "")) + ssh.from_node.return_value = ssh_mock + + tgen = mock.Mock(autospec=GenericTrafficGen) + tgen.traffic_finished = True + verified_dict = {"verified": True} + tgen.verify_traffic = lambda x: verified_dict + tgen.terminate = mock.Mock(return_value=True) + tgen.name = "tgen__1" + tgen.run_traffic.return_value = 'tg_id' + vnf = mock.Mock(autospec=GenericVNF) + vnf.runs_traffic = False + vnf.terminate = mock.Mock(return_value=True) + self.s.vnfs = [tgen, vnf] + self.s.traffic_profile = mock.Mock() + self.s.collector = mock.Mock(autospec=Collector) + self.s.collector.get_kpi = \ + mock.Mock(return_value={tgen.name: verified_dict}) + self.s.map_topology_to_infrastructure = mock.Mock(return_value=0) + self.s.load_vnf_models = mock.Mock(return_value=self.s.vnfs) + self.s.setup() diff --git a/yardstick/tests/unit/benchmark/scenarios/networking/vpe_vnf_topology.yaml b/yardstick/tests/unit/benchmark/scenarios/networking/vpe_vnf_topology.yaml index 1ac6c1f89..aaf84bb5e 100644 --- a/yardstick/tests/unit/benchmark/scenarios/networking/vpe_vnf_topology.yaml +++ b/yardstick/tests/unit/benchmark/scenarios/networking/vpe_vnf_topology.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2016-2017 Intel Corporation +# Copyright (c) 2016-2019 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -20,31 +20,31 @@ nsd:nsd-catalog: description: scenario with VPE,L3fwd and VNF constituent-vnfd: - member-vnf-index: '1' - vnfd-id-ref: tg__1 - VNF model: ../../vnf_descriptors/tg_rfc2544_tpl.yaml #tg_vpe_upstream.yaml #VPE VNF + vnfd-id-ref: tg__0 + VNF model: ../../vnf_descriptors/tg_rfc2544_tpl.yaml #tg_trex_tpl.yaml #TREX - member-vnf-index: '2' - vnfd-id-ref: vnf__1 - VNF model: ../../vnf_descriptors/vpe_vnf.yaml #tg_l3fwd.yaml #tg_trex_tpl.yaml #TREX + vnfd-id-ref: vnf__0 + VNF model: ../../vnf_descriptors/vpe_vnf.yaml #VPE VNF vld: - id: uplink - name: tg__1 to vnf__1 link 1 + name: tg__0 to vnf__0 link 1 type: ELAN vnfd-connection-point-ref: - member-vnf-index-ref: '1' vnfd-connection-point-ref: xe0 - vnfd-id-ref: tg__1 #TREX + vnfd-id-ref: tg__0 - member-vnf-index-ref: '2' vnfd-connection-point-ref: xe0 - vnfd-id-ref: vnf__1 #VNF + vnfd-id-ref: vnf__0 - id: downlink - name: vnf__1 to tg__1 link 2 + name: vnf__0 to tg__0 link 2 type: ELAN vnfd-connection-point-ref: - member-vnf-index-ref: '2' vnfd-connection-point-ref: xe1 - vnfd-id-ref: vnf__1 #L3fwd + vnfd-id-ref: vnf__0 - member-vnf-index-ref: '1' vnfd-connection-point-ref: xe1 - vnfd-id-ref: tg__1 #VPE VNF + vnfd-id-ref: tg__0 diff --git a/yardstick/tests/unit/network_services/traffic_profile/test_ixia_rfc2544.py b/yardstick/tests/unit/network_services/traffic_profile/test_ixia_rfc2544.py index 426d6b21b..ddd1828ae 100644 --- a/yardstick/tests/unit/network_services/traffic_profile/test_ixia_rfc2544.py +++ b/yardstick/tests/unit/network_services/traffic_profile/test_ixia_rfc2544.py @@ -627,17 +627,17 @@ class TestIXIARFC2544Profile(unittest.TestCase): def test_get_drop_percentage_completed(self): samples = {'iface_name_1': - {'in_packets': 1000, 'out_packets': 1000, - 'in_bytes': 64000, 'out_bytes': 64000, - 'Store-Forward_Avg_latency_ns': 20, - 'Store-Forward_Min_latency_ns': 15, - 'Store-Forward_Max_latency_ns': 25}, + {'InPackets': 1000, 'OutPackets': 1000, + 'InBytes': 64000, 'OutBytes': 64000, + 'LatencyAvg': 20, + 'LatencyMin': 15, + 'LatencyMax': 25}, 'iface_name_2': - {'in_packets': 1005, 'out_packets': 1007, - 'in_bytes': 64320, 'out_bytes': 64448, - 'Store-Forward_Avg_latency_ns': 23, - 'Store-Forward_Min_latency_ns': 13, - 'Store-Forward_Max_latency_ns': 28} + {'InPackets': 1005, 'OutPackets': 1007, + 'InBytes': 64320, 'OutBytes': 64448, + 'LatencyAvg': 23, + 'LatencyMin': 13, + 'LatencyMax': 28} } rfc2544_profile = ixia_rfc2544.IXIARFC2544Profile(self.TRAFFIC_PROFILE) rfc2544_profile.rate = 100.0 @@ -649,25 +649,25 @@ class TestIXIARFC2544Profile(unittest.TestCase): self.assertEqual(66.9, samples['TxThroughput']) self.assertEqual(66.833, samples['RxThroughput']) self.assertEqual(0.099651, samples['DropPercentage']) - self.assertEqual(21.5, samples['latency_ns_avg']) - self.assertEqual(14.0, samples['latency_ns_min']) - self.assertEqual(26.5, samples['latency_ns_max']) + self.assertEqual(21.5, samples['LatencyAvg']) + self.assertEqual(13.0, samples['LatencyMin']) + self.assertEqual(28.0, samples['LatencyMax']) self.assertEqual(100.0, samples['Rate']) self.assertEqual('64B', samples['PktSize']) def test_get_drop_percentage_over_drop_percentage(self): samples = {'iface_name_1': - {'in_packets': 1000, 'out_packets': 1000, - 'in_bytes': 64000, 'out_bytes': 64000, - 'Store-Forward_Avg_latency_ns': 20, - 'Store-Forward_Min_latency_ns': 15, - 'Store-Forward_Max_latency_ns': 25}, + {'InPackets': 1000, 'OutPackets': 1000, + 'InBytes': 64000, 'OutBytes': 64000, + 'LatencyAvg': 20, + 'LatencyMin': 15, + 'LatencyMax': 25}, 'iface_name_2': - {'in_packets': 1005, 'out_packets': 1007, - 'in_bytes': 64320, 'out_bytes': 64448, - 'Store-Forward_Avg_latency_ns': 20, - 'Store-Forward_Min_latency_ns': 15, - 'Store-Forward_Max_latency_ns': 25} + {'InPackets': 1005, 'OutPackets': 1007, + 'InBytes': 64320, 'OutBytes': 64448, + 'LatencyAvg': 20, + 'LatencyMin': 15, + 'LatencyMax': 25} } rfc2544_profile = ixia_rfc2544.IXIARFC2544Profile(self.TRAFFIC_PROFILE) rfc2544_profile.rate = 1000 @@ -682,17 +682,17 @@ class TestIXIARFC2544Profile(unittest.TestCase): def test_get_drop_percentage_under_drop_percentage(self): samples = {'iface_name_1': - {'in_packets': 1000, 'out_packets': 1000, - 'in_bytes': 64000, 'out_bytes': 64000, - 'Store-Forward_Avg_latency_ns': 20, - 'Store-Forward_Min_latency_ns': 15, - 'Store-Forward_Max_latency_ns': 25}, + {'InPackets': 1000, 'OutPackets': 1000, + 'InBytes': 64000, 'OutBytes': 64000, + 'LatencyAvg': 20, + 'LatencyMin': 15, + 'LatencyMax': 25}, 'iface_name_2': - {'in_packets': 1005, 'out_packets': 1007, - 'in_bytes': 64320, 'out_bytes': 64448, - 'Store-Forward_Avg_latency_ns': 20, - 'Store-Forward_Min_latency_ns': 15, - 'Store-Forward_Max_latency_ns': 25} + {'InPackets': 1005, 'OutPackets': 1007, + 'InBytes': 64320, 'OutBytes': 64448, + 'LatencyAvg': 20, + 'LatencyMin': 15, + 'LatencyMax': 25} } rfc2544_profile = ixia_rfc2544.IXIARFC2544Profile(self.TRAFFIC_PROFILE) rfc2544_profile.rate = 1000 @@ -708,17 +708,17 @@ class TestIXIARFC2544Profile(unittest.TestCase): @mock.patch.object(ixia_rfc2544.LOG, 'info') def test_get_drop_percentage_not_flow(self, *args): samples = {'iface_name_1': - {'in_packets': 1000, 'out_packets': 0, - 'in_bytes': 64000, 'out_bytes': 0, - 'Store-Forward_Avg_latency_ns': 20, - 'Store-Forward_Min_latency_ns': 15, - 'Store-Forward_Max_latency_ns': 25}, + {'InPackets': 1000, 'OutPackets': 0, + 'InBytes': 64000, 'OutBytes': 0, + 'LatencyAvg': 20, + 'LatencyMin': 15, + 'LatencyMax': 25}, 'iface_name_2': - {'in_packets': 1005, 'out_packets': 0, - 'in_bytes': 64320, 'out_bytes': 0, - 'Store-Forward_Avg_latency_ns': 20, - 'Store-Forward_Min_latency_ns': 15, - 'Store-Forward_Max_latency_ns': 25} + {'InPackets': 1005, 'OutPackets': 0, + 'InBytes': 64320, 'OutBytes': 0, + 'LatencyAvg': 20, + 'LatencyMin': 15, + 'LatencyMax': 25} } rfc2544_profile = ixia_rfc2544.IXIARFC2544Profile(self.TRAFFIC_PROFILE) rfc2544_profile.rate = 1000 @@ -733,17 +733,17 @@ class TestIXIARFC2544Profile(unittest.TestCase): def test_get_drop_percentage_first_run(self): samples = {'iface_name_1': - {'in_packets': 1000, 'out_packets': 1000, - 'in_bytes': 64000, 'out_bytes': 64000, - 'Store-Forward_Avg_latency_ns': 20, - 'Store-Forward_Min_latency_ns': 15, - 'Store-Forward_Max_latency_ns': 25}, + {'InPackets': 1000, 'OutPackets': 1000, + 'InBytes': 64000, 'OutBytes': 64000, + 'LatencyAvg': 20, + 'LatencyMin': 15, + 'LatencyMax': 25}, 'iface_name_2': - {'in_packets': 1005, 'out_packets': 1007, - 'in_bytes': 64320, 'out_bytes': 64448, - 'Store-Forward_Avg_latency_ns': 20, - 'Store-Forward_Min_latency_ns': 15, - 'Store-Forward_Max_latency_ns': 25} + {'InPackets': 1005, 'OutPackets': 1007, + 'InBytes': 64320, 'OutBytes': 64448, + 'LatencyAvg': 20, + 'LatencyMin': 15, + 'LatencyMax': 25} } rfc2544_profile = ixia_rfc2544.IXIARFC2544Profile(self.TRAFFIC_PROFILE) rfc2544_profile._get_next_rate = mock.Mock(return_value=50.0) @@ -759,17 +759,17 @@ class TestIXIARFC2544Profile(unittest.TestCase): rfc2544_profile = ixia_rfc2544.IXIARFC2544Profile(self.TRAFFIC_PROFILE) rfc2544_profile._get_next_rate = mock.Mock(return_value=0.1) samples = {'iface_name_1': - {'in_packets': 1000, 'out_packets': 1000, - 'in_bytes': 64000, 'out_bytes': 64000, - 'Store-Forward_Avg_latency_ns': 20, - 'Store-Forward_Min_latency_ns': 15, - 'Store-Forward_Max_latency_ns': 25}, + {'InPackets': 1000, 'OutPackets': 1000, + 'InBytes': 64000, 'OutBytes': 64000, + 'LatencyAvg': 20, + 'LatencyMin': 15, + 'LatencyMax': 25}, 'iface_name_2': - {'in_packets': 1005, 'out_packets': 1007, - 'in_bytes': 64320, 'out_bytes': 64448, - 'Store-Forward_Avg_latency_ns': 20, - 'Store-Forward_Min_latency_ns': 15, - 'Store-Forward_Max_latency_ns': 25} + {'InPackets': 1005, 'OutPackets': 1007, + 'InBytes': 64320, 'OutBytes': 64448, + 'LatencyAvg': 20, + 'LatencyMin': 15, + 'LatencyMax': 25} } rfc2544_profile.rate = 0.19 completed, _ = rfc2544_profile.get_drop_percentage( @@ -777,17 +777,17 @@ class TestIXIARFC2544Profile(unittest.TestCase): self.assertTrue(completed) samples = {'iface_name_1': - {'in_packets': 1000, 'out_packets': 1000, - 'in_bytes': 64000, 'out_bytes': 64000, - 'Store-Forward_Avg_latency_ns': 20, - 'Store-Forward_Min_latency_ns': 15, - 'Store-Forward_Max_latency_ns': 25}, + {'InPackets': 1000, 'OutPackets': 1000, + 'InBytes': 64000, 'OutBytes': 64000, + 'LatencyAvg': 20, + 'LatencyMin': 15, + 'LatencyMax': 25}, 'iface_name_2': - {'in_packets': 1005, 'out_packets': 1007, - 'in_bytes': 64320, 'out_bytes': 64448, - 'Store-Forward_Avg_latency_ns': 20, - 'Store-Forward_Min_latency_ns': 15, - 'Store-Forward_Max_latency_ns': 25} + {'InPackets': 1005, 'OutPackets': 1007, + 'InBytes': 64320, 'OutBytes': 64448, + 'LatencyAvg': 20, + 'LatencyMin': 15, + 'LatencyMax': 25} } rfc2544_profile.rate = 0.5 completed, _ = rfc2544_profile.get_drop_percentage( @@ -852,8 +852,8 @@ class TestIXIARFC2544PppoeScenarioProfile(unittest.TestCase): input_stats = { '0': { - 'in_packets': 50, - 'out_packets': 100, + 'InPackets': 50, + 'OutPackets': 100, 'Store-Forward_Avg_latency_ns': 10, 'Store-Forward_Min_latency_ns': 10, 'Store-Forward_Max_latency_ns': 10}} @@ -865,8 +865,8 @@ class TestIXIARFC2544PppoeScenarioProfile(unittest.TestCase): def test__get_prio_flows_drop_percentage_traffic_not_flowing(self): input_stats = { '0': { - 'in_packets': 0, - 'out_packets': 0, + 'InPackets': 0, + 'OutPackets': 0, 'Store-Forward_Avg_latency_ns': 0, 'Store-Forward_Min_latency_ns': 0, 'Store-Forward_Max_latency_ns': 0}} @@ -878,24 +878,24 @@ class TestIXIARFC2544PppoeScenarioProfile(unittest.TestCase): def test__get_summary_pppoe_subs_counters(self): input_stats = { 'xe0': { - 'out_packets': 100, - 'sessions_up': 4, - 'sessions_down': 0, - 'sessions_not_started': 0, - 'sessions_total': 4}, + 'OutPackets': 100, + 'SessionsUp': 4, + 'SessionsDown': 0, + 'SessionsNotStarted': 0, + 'SessionsTotal': 4}, 'xe1': { - 'out_packets': 100, - 'sessions_up': 4, - 'sessions_down': 0, - 'sessions_not_started': 0, - 'sessions_total': 4} + 'OutPackets': 100, + 'SessionsUp': 4, + 'SessionsDown': 0, + 'SessionsNotStarted': 0, + 'SessionsTotal': 4} } expected_stats = { - 'sessions_up': 8, - 'sessions_down': 0, - 'sessions_not_started': 0, - 'sessions_total': 8 + 'SessionsUp': 8, + 'SessionsDown': 0, + 'SessionsNotStarted': 0, + 'SessionsTotal': 8 } res = self.ixia_tp._get_summary_pppoe_subs_counters(input_stats) @@ -910,23 +910,23 @@ class TestIXIARFC2544PppoeScenarioProfile(unittest.TestCase): samples = { 'priority_stats': { '0': { - 'in_packets': 100, - 'out_packets': 100, - 'in_bytes': 6400, - 'out_bytes': 6400, - 'Store-Forward_Avg_latency_ns': 10, - 'Store-Forward_Min_latency_ns': 10, - 'Store-Forward_Max_latency_ns': 10}}, + 'InPackets': 100, + 'OutPackets': 100, + 'InBytes': 6400, + 'OutBytes': 6400, + 'LatencyAvg': 10, + 'LatencyMin': 10, + 'LatencyMax': 10}}, 'xe0': { - 'in_packets': 100, - 'out_packets': 100, - 'in_bytes': 6400, - 'out_bytes': 6400, - 'Store-Forward_Avg_latency_ns': 10, - 'Store-Forward_Min_latency_ns': 10, - 'Store-Forward_Max_latency_ns': 10}} - - mock_get_pppoe_subs.return_value = {'sessions_up': 1} + 'InPackets': 100, + 'OutPackets': 100, + 'InBytes': 6400, + 'OutBytes': 6400, + 'LatencyAvg': 10, + 'LatencyMin': 10, + 'LatencyMax': 10}} + + mock_get_pppoe_subs.return_value = {'SessionsUp': 1} mock_sum_prio_drop_rate.return_value = {'0': {'DropPercentage': 0.0}} self.ixia_tp._get_framesize = mock.Mock(return_value='64B') @@ -934,8 +934,8 @@ class TestIXIARFC2544PppoeScenarioProfile(unittest.TestCase): samples, tol_min=0.0, tolerance=0.0001, precision=0, resolution=0.1, first_run=True) self.assertIsNotNone(res.get('DropPercentage')) - self.assertIsNotNone(res.get('priority')) - self.assertIsNotNone(res.get('sessions_up')) + self.assertIsNotNone(res.get('Priority')) + self.assertIsNotNone(res.get('SessionsUp')) self.assertEqual(res['DropPercentage'], 0.0) self.assertEqual(res['Rate'], 100.0) self.assertEqual(res['PktSize'], '64B') @@ -952,31 +952,31 @@ class TestIXIARFC2544PppoeScenarioProfile(unittest.TestCase): samples = { 'priority_stats': { '0': { - 'in_packets': 90, - 'out_packets': 100, - 'in_bytes': 5760, - 'out_bytes': 6400, - 'Store-Forward_Avg_latency_ns': 10, - 'Store-Forward_Min_latency_ns': 10, - 'Store-Forward_Max_latency_ns': 10}}, + 'InPackets': 90, + 'OutPackets': 100, + 'InBytes': 5760, + 'OutBytes': 6400, + 'LatencyAvg': 10, + 'LatencyMin': 10, + 'LatencyMax': 10}}, 'xe0': { - 'in_packets': 90, - 'out_packets': 100, - 'in_bytes': 5760, - 'out_bytes': 6400, - 'Store-Forward_Avg_latency_ns': 10, - 'Store-Forward_Min_latency_ns': 10, - 'Store-Forward_Max_latency_ns': 10}} - - mock_get_pppoe_subs.return_value = {'sessions_up': 1} + 'InPackets': 90, + 'OutPackets': 100, + 'InBytes': 5760, + 'OutBytes': 6400, + 'LatencyAvg': 10, + 'LatencyMin': 10, + 'LatencyMax': 10}} + + mock_get_pppoe_subs.return_value = {'SessionsUp': 1} mock_sum_prio_drop_rate.return_value = {'0': {'DropPercentage': 0.0}} status, res = self.ixia_tp.get_drop_percentage( samples, tol_min=0.0, tolerance=0.0001, precision=0, resolution=0.1, first_run=True) self.assertIsNotNone(res.get('DropPercentage')) - self.assertIsNotNone(res.get('priority')) - self.assertIsNotNone(res.get('sessions_up')) + self.assertIsNotNone(res.get('Priority')) + self.assertIsNotNone(res.get('SessionsUp')) self.assertEqual(res['DropPercentage'], 10.0) self.assertFalse(status) mock_sum_prio_drop_rate.assert_called_once() @@ -991,24 +991,24 @@ class TestIXIARFC2544PppoeScenarioProfile(unittest.TestCase): samples = { 'priority_stats': { '0': { - 'in_packets': 100, - 'out_packets': 100, - 'in_bytes': 6400, - 'out_bytes': 6400, - 'Store-Forward_Avg_latency_ns': 10, - 'Store-Forward_Min_latency_ns': 10, - 'Store-Forward_Max_latency_ns': 10}}, + 'InPackets': 100, + 'OutPackets': 100, + 'InBytes': 6400, + 'OutBytes': 6400, + 'LatencyAvg': 10, + 'LatencyMin': 10, + 'LatencyMax': 10}}, 'xe0': { - 'in_packets': 90, - 'out_packets': 100, - 'in_bytes': 5760, - 'out_bytes': 6400, - 'Store-Forward_Avg_latency_ns': 10, - 'Store-Forward_Min_latency_ns': 10, - 'Store-Forward_Max_latency_ns': 10 + 'InPackets': 90, + 'OutPackets': 100, + 'InBytes': 5760, + 'OutBytes': 6400, + 'LatencyAvg': 10, + 'LatencyMin': 10, + 'LatencyMax': 10 }} - mock_get_pppoe_subs.return_value = {'sessions_up': 1} + mock_get_pppoe_subs.return_value = {'SessionsUp': 1} mock_sum_prio_drop_rate.return_value = {'0': {'DropPercentage': 0.0}} tc_rfc2544_opts = {'priority': '0', @@ -1017,8 +1017,8 @@ class TestIXIARFC2544PppoeScenarioProfile(unittest.TestCase): samples, tol_min=15.0000, tolerance=15.0001, precision=0, resolution=0.1, first_run=True, tc_rfc2544_opts=tc_rfc2544_opts) self.assertIsNotNone(res.get('DropPercentage')) - self.assertIsNotNone(res.get('priority')) - self.assertIsNotNone(res.get('sessions_up')) + self.assertIsNotNone(res.get('Priority')) + self.assertIsNotNone(res.get('SessionsUp')) self.assertTrue(status) mock_sum_prio_drop_rate.assert_called_once() mock_get_pppoe_subs.assert_called_once() diff --git a/yardstick/tests/unit/network_services/traffic_profile/test_rfc2544.py b/yardstick/tests/unit/network_services/traffic_profile/test_rfc2544.py index 6d3558c7e..febcfe5da 100644 --- a/yardstick/tests/unit/network_services/traffic_profile/test_rfc2544.py +++ b/yardstick/tests/unit/network_services/traffic_profile/test_rfc2544.py @@ -255,31 +255,23 @@ class TestRFC2544Profile(base.BaseUnitTestCase): mock_get_framesize.return_value = '64B' samples = [ - {'xe1': {'tx_throughput_fps': 110, - 'rx_throughput_fps': 101, - 'out_packets': 2100, + {'xe1': {'out_packets': 2100, 'in_packets': 2010, 'out_bytes': 134400, 'in_bytes': 128640, 'timestamp': datetime.datetime(2000, 1, 1, 1, 1, 1, 1)}, - 'xe2': {'tx_throughput_fps': 210, - 'rx_throughput_fps': 201, - 'out_packets': 4100, + 'xe2': {'out_packets': 4100, 'in_packets': 4010, 'out_bytes': 262400, 'in_bytes': 256640, 'timestamp': datetime.datetime(2000, 1, 1, 1, 1, 1, 1)}}, - {'xe1': {'tx_throughput_fps': 156, - 'rx_throughput_fps': 108, - 'out_packets': 2110, + {'xe1': {'out_packets': 2110, 'in_packets': 2040, 'out_bytes': 135040, 'in_bytes': 130560, 'latency': 'Latency1', 'timestamp': datetime.datetime(2000, 1, 1, 1, 1, 1, 31)}, - 'xe2': {'tx_throughput_fps': 253, - 'rx_throughput_fps': 215, - 'out_packets': 4150, + 'xe2': {'out_packets': 4150, 'in_packets': 4010, 'out_bytes': 265600, 'in_bytes': 256640, @@ -288,15 +280,20 @@ class TestRFC2544Profile(base.BaseUnitTestCase): ] completed, output = rfc2544_profile.get_drop_percentage( samples, 0, 0, False, 0.1) - expected = {'DropPercentage': 50.0, - 'Latency': {'xe1': 'Latency1', 'xe2': 'Latency2'}, + expected = {'xe1': {'OutPackets': 10, + 'InPackets': 30, + 'OutBytes': 640, + 'InBytes': 1920}, + 'xe2': {'OutPackets': 50, + 'InPackets': 0, + 'OutBytes': 3200, + 'InBytes': 0}, + 'DropPercentage': 50.0, 'RxThroughput': 1000000.0, 'TxThroughput': 2000000.0, 'RxThroughputBps': 64000000.0, 'TxThroughputBps': 128000000.0, - 'CurrentDropPercentage': 50.0, 'Rate': 100.0, - 'Throughput': 1000000.0, 'Iteration': 1, 'PktSize': '64B', 'Status': 'Failure'} diff --git a/yardstick/tests/unit/network_services/traffic_profile/test_vpp_rfc2544.py b/yardstick/tests/unit/network_services/traffic_profile/test_vpp_rfc2544.py new file mode 100644 index 000000000..4e5a0f708 --- /dev/null +++ b/yardstick/tests/unit/network_services/traffic_profile/test_vpp_rfc2544.py @@ -0,0 +1,819 @@ +# Copyright (c) 2019 Viosoft Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import mock +from trex_stl_lib import trex_stl_client +from trex_stl_lib import trex_stl_packet_builder_scapy +from trex_stl_lib import trex_stl_streams + +from yardstick.common import constants +from yardstick.network_services.traffic_profile import base as tp_base +from yardstick.network_services.traffic_profile import rfc2544, vpp_rfc2544 +from yardstick.tests.unit import base + + +class TestVppRFC2544Profile(base.BaseUnitTestCase): + TRAFFIC_PROFILE = { + "schema": "isb:traffic_profile:0.1", + "name": "fixed", + "description": "Fixed traffic profile to run UDP traffic", + "traffic_profile": { + "traffic_type": "FixedTraffic", + "duration": 30, + "enable_latency": True, + "frame_rate": 100, + "intermediate_phases": 2, + "lower_bound": 1.0, + "step_interval": 0.5, + "test_precision": 0.1, + "upper_bound": 100.0}} + + TRAFFIC_PROFILE_MAX_RATE = { + "schema": "isb:traffic_profile:0.1", + "name": "fixed", + "description": "Fixed traffic profile to run UDP traffic", + "traffic_profile": { + "traffic_type": "FixedTraffic", + "duration": 30, + "enable_latency": True, + "frame_rate": 10000, + "intermediate_phases": 2, + "lower_bound": 1.0, + "step_interval": 0.5, + "test_precision": 0.1, + "upper_bound": 100.0}} + + PROFILE = { + "description": "Traffic profile to run RFC2544 latency", + "downlink_0": { + "ipv4": { + "id": 2, + "outer_l2": { + "framesize": { + "1024B": "0", + "1280B": "0", + "128B": "0", + "1400B": "0", + "1500B": "0", + "1518B": "0", + "256B": "0", + "373b": "0", + "512B": "0", + "570B": "0", + "64B": "100" + } + }, + "outer_l3v4": { + "count": "1", + "dstip4": "10.0.0.0-10.0.0.100", + "proto": 61, + "srcip4": "20.0.0.0-20.0.0.100" + } + } + }, + "name": "rfc2544", + "schema": "nsb:traffic_profile:0.1", + "traffic_profile": { + "duration": 30, + "enable_latency": True, + "frame_rate": 100, + "intermediate_phases": 2, + "lower_bound": 1.0, + "step_interval": 0.5, + "test_precision": 0.1, + "traffic_type": "VppRFC2544Profile", + "upper_bound": 100.0 + }, + "uplink": { + "ipv4": { + "id": 1, + "outer_l2": { + "framesize": { + "1024B": "0", + "1280B": "0", + "128B": "0", + "1400B": "0", + "1500B": "0", + "1518B": "0", + "256B": "0", + "373B": "0", + "512B": "0", + "570B": "0", + "64B": "100" + } + }, + "outer_l3v4": { + "count": "10", + "dstip4": "20.0.0.0-20.0.0.100", + "proto": 61, + "srcip4": "10.0.0.0-10.0.0.100" + } + } + } + } + + def test___init__(self): + vpp_rfc2544_profile = vpp_rfc2544.VppRFC2544Profile( + self.TRAFFIC_PROFILE) + self.assertEqual(vpp_rfc2544_profile.max_rate, + vpp_rfc2544_profile.rate) + self.assertEqual(0, vpp_rfc2544_profile.min_rate) + self.assertEqual(30, vpp_rfc2544_profile.duration) + self.assertEqual(0.1, vpp_rfc2544_profile.precision) + self.assertEqual(1.0, vpp_rfc2544_profile.lower_bound) + self.assertEqual(100.0, vpp_rfc2544_profile.upper_bound) + self.assertEqual(0.5, vpp_rfc2544_profile.step_interval) + self.assertEqual(True, vpp_rfc2544_profile.enable_latency) + + def test_init_traffic_params(self): + vpp_rfc2544_profile = vpp_rfc2544.VppRFC2544Profile( + self.TRAFFIC_PROFILE) + mock_generator = mock.MagicMock() + mock_generator.rfc2544_helper.latency = True + mock_generator.rfc2544_helper.tolerance_low = 0.0 + mock_generator.rfc2544_helper.tolerance_high = 0.005 + mock_generator.scenario_helper.all_options = { + "vpp_config": { + "max_rate": 14880000 + } + } + vpp_rfc2544_profile.init_traffic_params(mock_generator) + self.assertEqual(0.0, vpp_rfc2544_profile.tolerance_low) + self.assertEqual(0.005, vpp_rfc2544_profile.tolerance_high) + self.assertEqual(14880000, vpp_rfc2544_profile.max_rate) + self.assertEqual(True, vpp_rfc2544_profile.enable_latency) + + def test_calculate_frame_size(self): + imix = {'40B': 7, '576B': 4, '1500B': 1} + vpp_rfc2544_profile = vpp_rfc2544.VppRFC2544Profile( + self.TRAFFIC_PROFILE) + self.assertEqual((4084 / 12, 12), + vpp_rfc2544_profile.calculate_frame_size(imix)) + + def test_calculate_frame_size_empty(self): + vpp_rfc2544_profile = vpp_rfc2544.VppRFC2544Profile( + self.TRAFFIC_PROFILE) + self.assertEqual((64, 100), + vpp_rfc2544_profile.calculate_frame_size(None)) + + def test_calculate_frame_size_error(self): + imix = {'40B': -7, '576B': 4, '1500B': 1} + vpp_rfc2544_profile = vpp_rfc2544.VppRFC2544Profile( + self.TRAFFIC_PROFILE) + self.assertEqual((64, 100), + vpp_rfc2544_profile.calculate_frame_size(imix)) + + def test__gen_payload(self): + vpp_rfc2544_profile = vpp_rfc2544.VppRFC2544Profile( + self.TRAFFIC_PROFILE) + self.assertIsNotNone(vpp_rfc2544_profile._gen_payload(4)) + + def test_register_generator(self): + vpp_rfc2544_profile = vpp_rfc2544.VppRFC2544Profile( + self.TRAFFIC_PROFILE) + mock_generator = mock.MagicMock() + mock_generator.rfc2544_helper.latency = True + mock_generator.rfc2544_helper.tolerance_low = 0.0 + mock_generator.rfc2544_helper.tolerance_high = 0.005 + mock_generator.scenario_helper.all_options = { + "vpp_config": { + "max_rate": 14880000 + } + } + vpp_rfc2544_profile.register_generator(mock_generator) + self.assertEqual(0.0, vpp_rfc2544_profile.tolerance_low) + self.assertEqual(0.005, vpp_rfc2544_profile.tolerance_high) + self.assertEqual(14880000, vpp_rfc2544_profile.max_rate) + self.assertEqual(True, vpp_rfc2544_profile.enable_latency) + + def test_stop_traffic(self): + vpp_rfc2544_profile = vpp_rfc2544.VppRFC2544Profile( + self.TRAFFIC_PROFILE) + mock_generator = mock.Mock() + vpp_rfc2544_profile.stop_traffic(traffic_generator=mock_generator) + mock_generator.client.stop.assert_called_once() + mock_generator.client.reset.assert_called_once() + mock_generator.client.remove_all_streams.assert_called_once() + + def test_execute_traffic(self): + vpp_rfc2544_profile = vpp_rfc2544.VppRFC2544Profile( + self.TRAFFIC_PROFILE) + vpp_rfc2544_profile.init_queue(mock.MagicMock()) + vpp_rfc2544_profile.params = { + 'downlink_0': 'profile1', + 'uplink_0': 'profile2'} + mock_generator = mock.MagicMock() + mock_generator.networks = { + 'downlink_0': ['xe0', 'xe1'], + 'uplink_0': ['xe2', 'xe3'], + 'uplink_1': ['xe2', 'xe3']} + mock_generator.port_num.side_effect = [10, 20, 30, 40] + mock_generator.rfc2544_helper.correlated_traffic = False + + with mock.patch.object(vpp_rfc2544_profile, 'create_profile') as \ + mock_create_profile: + vpp_rfc2544_profile.execute_traffic( + traffic_generator=mock_generator) + mock_create_profile.assert_has_calls([ + mock.call('profile1', 10), + mock.call('profile1', 20), + mock.call('profile2', 30), + mock.call('profile2', 40)]) + mock_generator.client.add_streams.assert_has_calls([ + mock.call(mock.ANY, ports=[10]), + mock.call(mock.ANY, ports=[20]), + mock.call(mock.ANY, ports=[30]), + mock.call(mock.ANY, ports=[40])]) + + def test_execute_traffic_correlated_traffic(self): + vpp_rfc2544_profile = vpp_rfc2544.VppRFC2544Profile( + self.TRAFFIC_PROFILE) + vpp_rfc2544_profile.init_queue(mock.MagicMock()) + vpp_rfc2544_profile.params = { + 'downlink_0': 'profile1', + 'uplink_0': 'profile2'} + mock_generator = mock.MagicMock() + mock_generator.networks = { + 'downlink_0': ['xe0', 'xe1'], + 'uplink_0': ['xe2', 'xe3']} + mock_generator.port_num.side_effect = [10, 20, 30, 40] + mock_generator.rfc2544_helper.correlated_traffic = True + + with mock.patch.object(vpp_rfc2544_profile, 'create_profile') as \ + mock_create_profile: + vpp_rfc2544_profile.execute_traffic( + traffic_generator=mock_generator) + mock_create_profile.assert_has_calls([ + mock.call('profile2', 10), + mock.call('profile2', 20)]) + mock_generator.client.add_streams.assert_has_calls([ + mock.call(mock.ANY, ports=[10]), + mock.call(mock.ANY, ports=[20]), + mock.call(mock.ANY, ports=[10]), + mock.call(mock.ANY, ports=[20]), + mock.call(mock.ANY, ports=[10]), + mock.call(mock.ANY, ports=[20]), + mock.call(mock.ANY, ports=[10]), + mock.call(mock.ANY, ports=[20]), + mock.call(mock.ANY, ports=[10]), + mock.call(mock.ANY, ports=[20]), + mock.call(mock.ANY, ports=[10]), + mock.call(mock.ANY, ports=[20]), + mock.call(mock.ANY, ports=[10]), + mock.call(mock.ANY, ports=[20]), + mock.call(mock.ANY, ports=[10]), + mock.call(mock.ANY, ports=[20]), + mock.call(mock.ANY, ports=[10]), + mock.call(mock.ANY, ports=[20]), + mock.call(mock.ANY, ports=[10]), + mock.call(mock.ANY, ports=[20]), + mock.call(mock.ANY, ports=[10]), + mock.call(mock.ANY, ports=[20]), + mock.call(mock.ANY, ports=[10]), + mock.call(mock.ANY, ports=[20])]) + + def test_execute_traffic_max_rate(self): + vpp_rfc2544_profile = vpp_rfc2544.VppRFC2544Profile( + self.TRAFFIC_PROFILE_MAX_RATE) + vpp_rfc2544_profile.init_queue(mock.MagicMock()) + vpp_rfc2544_profile.params = { + 'downlink_0': 'profile1', + 'uplink_0': 'profile2'} + mock_generator = mock.MagicMock() + mock_generator.networks = { + 'downlink_0': ['xe0', 'xe1'], + 'uplink_0': ['xe2', 'xe3']} + mock_generator.port_num.side_effect = [10, 20, 30, 40] + mock_generator.rfc2544_helper.correlated_traffic = False + + with mock.patch.object(vpp_rfc2544_profile, 'create_profile') as \ + mock_create_profile: + vpp_rfc2544_profile.execute_traffic( + traffic_generator=mock_generator) + mock_create_profile.assert_has_calls([ + mock.call('profile1', 10), + mock.call('profile1', 20), + mock.call('profile2', 30), + mock.call('profile2', 40)]) + mock_generator.client.add_streams.assert_has_calls([ + mock.call(mock.ANY, ports=[10]), + mock.call(mock.ANY, ports=[20]), + mock.call(mock.ANY, ports=[30]), + mock.call(mock.ANY, ports=[40])]) + + @mock.patch.object(trex_stl_streams, 'STLProfile') + def test_create_profile(self, mock_stl_profile): + vpp_rfc2544_profile = vpp_rfc2544.VppRFC2544Profile( + self.TRAFFIC_PROFILE) + port = mock.ANY + profile_data = {'packetid_1': {'outer_l2': {'framesize': 'imix_info'}}} + with mock.patch.object(vpp_rfc2544_profile, 'calculate_frame_size') as \ + mock_calculate_frame_size, \ + mock.patch.object(vpp_rfc2544_profile, '_create_imix_data') as \ + mock_create_imix, \ + mock.patch.object(vpp_rfc2544_profile, '_create_vm') as \ + mock_create_vm, \ + mock.patch.object(vpp_rfc2544_profile, + '_create_single_stream') as \ + mock_create_single_stream: + mock_calculate_frame_size.return_value = 64, 100 + mock_create_imix.return_value = 'imix_data' + mock_create_single_stream.return_value = ['stream1'] + vpp_rfc2544_profile.create_profile(profile_data, port) + + mock_create_imix.assert_called_once_with('imix_info') + mock_create_vm.assert_called_once_with( + {'outer_l2': {'framesize': 'imix_info'}}) + mock_create_single_stream.assert_called_once_with(port, 'imix_data', + 100) + mock_stl_profile.assert_called_once_with(['stream1']) + + @mock.patch.object(trex_stl_streams, 'STLProfile') + def test_create_profile_max_rate(self, mock_stl_profile): + vpp_rfc2544_profile = vpp_rfc2544.VppRFC2544Profile( + self.TRAFFIC_PROFILE_MAX_RATE) + port = mock.ANY + profile_data = {'packetid_1': {'outer_l2': {'framesize': 'imix_info'}}} + with mock.patch.object(vpp_rfc2544_profile, 'calculate_frame_size') as \ + mock_calculate_frame_size, \ + mock.patch.object(vpp_rfc2544_profile, '_create_imix_data') as \ + mock_create_imix, \ + mock.patch.object(vpp_rfc2544_profile, '_create_vm') as \ + mock_create_vm, \ + mock.patch.object(vpp_rfc2544_profile, + '_create_single_stream') as \ + mock_create_single_stream: + mock_calculate_frame_size.return_value = 64, 100 + mock_create_imix.return_value = 'imix_data' + mock_create_single_stream.return_value = ['stream1'] + vpp_rfc2544_profile.create_profile(profile_data, port) + + mock_create_imix.assert_called_once_with('imix_info', 'mode_DIP') + mock_create_vm.assert_called_once_with( + {'outer_l2': {'framesize': 'imix_info'}}) + mock_create_single_stream.assert_called_once_with(port, 'imix_data', + 100) + mock_stl_profile.assert_called_once_with(['stream1']) + + def test__create_imix_data_mode_DIP(self): + rfc2544_profile = vpp_rfc2544.VppRFC2544Profile(self.TRAFFIC_PROFILE) + data = {'64B': 50, '128B': 50} + self.assertEqual( + {'64': 50.0, '128': 50.0}, + rfc2544_profile._create_imix_data( + data, weight_mode=constants.DISTRIBUTION_IN_PACKETS)) + data = {'64B': 1, '128b': 3} + self.assertEqual( + {'64': 25.0, '128': 75.0}, + rfc2544_profile._create_imix_data( + data, weight_mode=constants.DISTRIBUTION_IN_PACKETS)) + data = {} + self.assertEqual( + {}, + rfc2544_profile._create_imix_data( + data, weight_mode=constants.DISTRIBUTION_IN_PACKETS)) + + def test__create_imix_data_mode_DIB(self): + rfc2544_profile = vpp_rfc2544.VppRFC2544Profile(self.TRAFFIC_PROFILE) + data = {'64B': 25, '128B': 25, '512B': 25, '1518B': 25} + byte_total = 64 * 25 + 128 * 25 + 512 * 25 + 1518 * 25 + self.assertEqual( + {'64': 64 * 25.0 * 100 / byte_total, + '128': 128 * 25.0 * 100 / byte_total, + '512': 512 * 25.0 * 100 / byte_total, + '1518': 1518 * 25.0 * 100 / byte_total}, + rfc2544_profile._create_imix_data( + data, weight_mode=constants.DISTRIBUTION_IN_BYTES)) + data = {} + self.assertEqual( + {}, + rfc2544_profile._create_imix_data( + data, weight_mode=constants.DISTRIBUTION_IN_BYTES)) + data = {'64B': 100} + self.assertEqual( + {'64': 100.0}, + rfc2544_profile._create_imix_data( + data, weight_mode=constants.DISTRIBUTION_IN_BYTES)) + + def test__create_vm(self): + packet = {'outer_l2': 'l2_definition'} + vpp_rfc2544_profile = vpp_rfc2544.VppRFC2544Profile( + self.TRAFFIC_PROFILE) + with mock.patch.object(vpp_rfc2544_profile, '_set_outer_l2_fields') as \ + mock_l2_fileds: + vpp_rfc2544_profile._create_vm(packet) + mock_l2_fileds.assert_called_once_with('l2_definition') + + @mock.patch.object(trex_stl_packet_builder_scapy, 'STLPktBuilder', + return_value='packet') + def test__create_single_packet(self, mock_pktbuilder): + size = 128 + vpp_rfc2544_profile = vpp_rfc2544.VppRFC2544Profile( + self.TRAFFIC_PROFILE) + vpp_rfc2544_profile.ether_packet = mock.MagicMock() + vpp_rfc2544_profile.ip_packet = mock.MagicMock() + vpp_rfc2544_profile.udp_packet = mock.MagicMock() + vpp_rfc2544_profile.trex_vm = 'trex_vm' + # base_pkt = ( + # vpp_rfc2544_profile.ether_packet / vpp_rfc2544_profile.ip_packet / + # vpp_rfc2544_profile.udp_packet) + # pad = (size - len(base_pkt)) * 'x' + output = vpp_rfc2544_profile._create_single_packet(size=size) + self.assertEqual(mock_pktbuilder.call_count, 2) + # mock_pktbuilder.assert_called_once_with(pkt=base_pkt / pad, + # vm='trex_vm') + self.assertEqual(output, ('packet', 'packet')) + + def test__set_outer_l3v4_fields(self): + vpp_rfc2544_profile = vpp_rfc2544.VppRFC2544Profile( + self.TRAFFIC_PROFILE) + outer_l3v4 = self.PROFILE[ + tp_base.TrafficProfile.UPLINK]['ipv4']['outer_l3v4'] + outer_l3v4['proto'] = 'tcp' + self.assertIsNone( + vpp_rfc2544_profile._set_outer_l3v4_fields(outer_l3v4)) + + @mock.patch.object(trex_stl_streams, 'STLFlowLatencyStats') + @mock.patch.object(trex_stl_streams, 'STLTXCont') + @mock.patch.object(trex_stl_client, 'STLStream') + def test__create_single_stream(self, mock_stream, mock_txcont, + mock_latency): + imix_data = {'64': 25, '512': 75} + mock_stream.side_effect = ['stream1', 'stream2', 'stream3', 'stream4'] + mock_txcont.side_effect = ['txcont1', 'txcont2', 'txcont3', 'txcont4'] + mock_latency.side_effect = ['latency1', 'latency2'] + vpp_rfc2544_profile = vpp_rfc2544.VppRFC2544Profile( + self.TRAFFIC_PROFILE) + vpp_rfc2544_profile.port_pg_id = rfc2544.PortPgIDMap() + vpp_rfc2544_profile.port_pg_id.add_port(10) + with mock.patch.object(vpp_rfc2544_profile, '_create_single_packet') as \ + mock_create_single_packet: + mock_create_single_packet.return_value = 64, 100 + output = vpp_rfc2544_profile._create_single_stream(10, imix_data, + 100, 0.0) + self.assertEqual(['stream1', 'stream2', 'stream3', 'stream4'], output) + mock_latency.assert_has_calls([ + mock.call(pg_id=1), mock.call(pg_id=2)]) + mock_txcont.assert_has_calls([ + mock.call(percentage=25 * 100 / 100), + mock.call(percentage=75 * 100 / 100)], any_order=True) + + @mock.patch.object(trex_stl_streams, 'STLFlowLatencyStats') + @mock.patch.object(trex_stl_streams, 'STLTXCont') + @mock.patch.object(trex_stl_client, 'STLStream') + def test__create_single_stream_max_rate(self, mock_stream, mock_txcont, + mock_latency): + imix_data = {'64': 25, '512': 75} + mock_stream.side_effect = ['stream1', 'stream2', 'stream3', 'stream4'] + mock_txcont.side_effect = ['txcont1', 'txcont2', 'txcont3', 'txcont4'] + mock_latency.side_effect = ['latency1', 'latency2'] + vpp_rfc2544_profile = vpp_rfc2544.VppRFC2544Profile( + self.TRAFFIC_PROFILE_MAX_RATE) + vpp_rfc2544_profile.port_pg_id = rfc2544.PortPgIDMap() + vpp_rfc2544_profile.port_pg_id.add_port(1) + with mock.patch.object(vpp_rfc2544_profile, '_create_single_packet') as \ + mock_create_single_packet: + mock_create_single_packet.return_value = 64, 100 + output = vpp_rfc2544_profile._create_single_stream(1, imix_data, + 100, 0.0) + self.assertEqual(['stream1', 'stream2', 'stream3', 'stream4'], output) + mock_latency.assert_has_calls([ + mock.call(pg_id=1), mock.call(pg_id=2)]) + mock_txcont.assert_has_calls([ + mock.call(pps=int(25 * 100 / 100)), + mock.call(pps=int(75 * 100 / 100))], any_order=True) + + @mock.patch.object(trex_stl_streams, 'STLFlowLatencyStats') + @mock.patch.object(trex_stl_streams, 'STLTXCont') + @mock.patch.object(trex_stl_client, 'STLStream') + def test__create_single_stream_mlr_search(self, mock_stream, mock_txcont, + mock_latency): + imix_data = {'64': 25, '512': 75} + mock_stream.side_effect = ['stream1', 'stream2', 'stream3', 'stream4'] + mock_txcont.side_effect = ['txcont1', 'txcont2', 'txcont3', 'txcont4'] + mock_latency.side_effect = ['latency1', 'latency2'] + vpp_rfc2544_profile = vpp_rfc2544.VppRFC2544Profile( + self.TRAFFIC_PROFILE) + vpp_rfc2544_profile.max_rate = 14880000 + vpp_rfc2544_profile.port_pg_id = rfc2544.PortPgIDMap() + vpp_rfc2544_profile.port_pg_id.add_port(10) + with mock.patch.object(vpp_rfc2544_profile, '_create_single_packet') as \ + mock_create_single_packet: + mock_create_single_packet.return_value = 64, 100 + output = vpp_rfc2544_profile._create_single_stream(10, imix_data, + 100, 0.0) + self.assertEqual(['stream1', 'stream2', 'stream3', 'stream4'], output) + mock_latency.assert_has_calls([ + mock.call(pg_id=1), mock.call(pg_id=2)]) + mock_txcont.assert_has_calls([ + mock.call(pps=25 * 100 / 100), + mock.call(pps=75 * 100 / 100)], any_order=True) + + def test_binary_search_with_optimized(self): + vpp_rfc2544_profile = vpp_rfc2544.VppRFC2544Profile( + self.TRAFFIC_PROFILE) + mock_generator = mock.MagicMock() + self.assertIsNone( + vpp_rfc2544_profile.binary_search_with_optimized(mock_generator, + 30, 720, '')) + + def test_binary_search(self): + vpp_rfc2544_profile = vpp_rfc2544.VppRFC2544Profile( + self.TRAFFIC_PROFILE) + vpp_rfc2544_profile.pkt_size = 64 + vpp_rfc2544_profile.init_queue(mock.MagicMock()) + mock_generator = mock.MagicMock() + mock_generator.vnfd_helper.interfaces = [ + {"name": "xe0"}, {"name": "xe1"} + ] + stats = { + "0": { + "ibytes": 55549120, + "ierrors": 0, + "ipackets": 867955, + "obytes": 55549696, + "oerrors": 0, + "opackets": 867964, + "rx_bps": 104339032.0, + "rx_bps_L1": 136944984.0, + "rx_pps": 203787.2, + "rx_util": 1.36944984, + "tx_bps": 134126008.0, + "tx_bps_L1": 176040392.0, + "tx_pps": 261964.9, + "tx_util": 1.7604039200000001 + }, + "1": { + "ibytes": 55549696, + "ierrors": 0, + "ipackets": 867964, + "obytes": 55549120, + "oerrors": 0, + "opackets": 867955, + "rx_bps": 134119648.0, + "rx_bps_L1": 176032032.0, + "rx_pps": 261952.4, + "rx_util": 1.76032032, + "tx_bps": 104338192.0, + "tx_bps_L1": 136943872.0, + "tx_pps": 203785.5, + "tx_util": 1.36943872 + }, + "flow_stats": { + "1": { + "rx_bps": { + "0": 0, + "1": 0, + "total": 0 + }, + "rx_bps_l1": { + "0": 0.0, + "1": 0.0, + "total": 0.0 + }, + "rx_bytes": { + "0": 6400, + "1": 0, + "total": 6400 + }, + "rx_pkts": { + "0": 100, + "1": 0, + "total": 100 + }, + "rx_pps": { + "0": 0, + "1": 0, + "total": 0 + }, + "tx_bps": { + "0": 0, + "1": 0, + "total": 0 + }, + "tx_bps_l1": { + "0": 0.0, + "1": 0.0, + "total": 0.0 + }, + "tx_bytes": { + "0": 0, + "1": 6400, + "total": 6400 + }, + "tx_pkts": { + "0": 0, + "1": 100, + "total": 100 + }, + "tx_pps": { + "0": 0, + "1": 0, + "total": 0 + } + }, + "2": { + "rx_bps": { + "0": 0, + "1": 0, + "total": 0 + }, + "rx_bps_l1": { + "0": 0.0, + "1": 0.0, + "total": 0.0 + }, + "rx_bytes": { + "0": 0, + "1": 6464, + "total": 6464 + }, + "rx_pkts": { + "0": 0, + "1": 101, + "total": 101 + }, + "rx_pps": { + "0": 0, + "1": 0, + "total": 0 + }, + "tx_bps": { + "0": 0, + "1": 0, + "total": 0 + }, + "tx_bps_l1": { + "0": 0.0, + "1": 0.0, + "total": 0.0 + }, + "tx_bytes": { + "0": 6464, + "1": 0, + "total": 6464 + }, + "tx_pkts": { + "0": 101, + "1": 0, + "total": 101 + }, + "tx_pps": { + "0": 0, + "1": 0, + "total": 0 + } + }, + "global": { + "rx_err": { + "0": 0, + "1": 0 + }, + "tx_err": { + "0": 0, + "1": 0 + } + } + }, + "global": { + "bw_per_core": 45.6, + "cpu_util": 0.1494, + "queue_full": 0, + "rx_bps": 238458672.0, + "rx_cpu_util": 4.751e-05, + "rx_drop_bps": 0.0, + "rx_pps": 465739.6, + "tx_bps": 238464208.0, + "tx_pps": 465750.4 + }, + "latency": { + "1": { + "err_cntrs": { + "dropped": 0, + "dup": 0, + "out_of_order": 0, + "seq_too_high": 0, + "seq_too_low": 0 + }, + "latency": { + "average": 63.375, + "histogram": { + "20": 1, + "30": 18, + "40": 12, + "50": 10, + "60": 12, + "70": 11, + "80": 6, + "90": 10, + "100": 20 + }, + "jitter": 23, + "last_max": 122, + "total_max": 123, + "total_min": 20 + } + }, + "2": { + "err_cntrs": { + "dropped": 0, + "dup": 0, + "out_of_order": 0, + "seq_too_high": 0, + "seq_too_low": 0 + }, + "latency": { + "average": 74, + "histogram": { + "60": 20, + "70": 10, + "80": 3, + "90": 4, + "100": 64 + }, + "jitter": 6, + "last_max": 83, + "total_max": 135, + "total_min": 60 + } + }, + "global": { + "bad_hdr": 0, + "old_flow": 0 + } + }, + "total": { + "ibytes": 111098816, + "ierrors": 0, + "ipackets": 1735919, + "obytes": 111098816, + "oerrors": 0, + "opackets": 1735919, + "rx_bps": 238458680.0, + "rx_bps_L1": 312977016.0, + "rx_pps": 465739.6, + "rx_util": 3.1297701599999996, + "tx_bps": 238464200.0, + "tx_bps_L1": 312984264.0, + "tx_pps": 465750.4, + "tx_util": 3.12984264 + } + } + samples = { + "xe0": { + "in_packets": 867955, + "latency": { + "2": { + "avg_latency": 74.0, + "max_latency": 135.0, + "min_latency": 60.0 + } + }, + "out_packets": 867964, + "rx_throughput_bps": 104339032.0, + "rx_throughput_fps": 203787.2, + "tx_throughput_bps": 134126008.0, + "tx_throughput_fps": 261964.9 + }, + "xe1": { + "in_packets": 867964, + "latency": { + "1": { + "avg_latency": 63.375, + "max_latency": 123.0, + "min_latency": 20.0 + } + }, + "out_packets": 867955, + "rx_throughput_bps": 134119648.0, + "rx_throughput_fps": 261952.4, + "tx_throughput_bps": 104338192.0, + "tx_throughput_fps": 203785.5 + } + } + + mock_generator.loss = 0 + mock_generator.sent = 2169700 + mock_generator.send_traffic_on_tg = mock.Mock(return_value=stats) + mock_generator.generate_samples = mock.Mock(return_value=samples) + + result_samples = vpp_rfc2544_profile.binary_search( + traffic_generator=mock_generator, duration=30, + tolerance_value=0.005, + test_data={}) + + expected = {'Result_theor_max_throughput': 134126008.0, + 'xe0': {'Result_Actual_throughput': 104339032.0}, + 'xe1': {'Result_Actual_throughput': 134119648.0}} + self.assertEqual(expected, result_samples) diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/tc_baremetal_rfc2544_ipv4_1flow_64B.yaml b/yardstick/tests/unit/network_services/vnf_generic/vnf/tc_baremetal_rfc2544_ipv4_1flow_64B.yaml index fb1be35c1..09c22ad9e 100644 --- a/yardstick/tests/unit/network_services/vnf_generic/vnf/tc_baremetal_rfc2544_ipv4_1flow_64B.yaml +++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/tc_baremetal_rfc2544_ipv4_1flow_64B.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2016-2017 Intel Corporation +# Copyright (c) 2016-2019 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -19,8 +19,8 @@ scenarios: traffic_profile: "../../traffic_profiles/ipv4_throughput_vpe.yaml" topology: vpe_vnf_topology.yaml nodes: - tg__1: trafficgen_1.yardstick - vnf__1: vnf.yardstick + tg__0: trafficgen_0.yardstick + vnf__0: vnf_0.yardstick tc_options: rfc2544: allowed_drop_rate: 0.8 - 1 diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py index 51a379cee..c3f3e5f67 100644 --- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py +++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py @@ -556,37 +556,29 @@ class TestIxiaBasicScenario(unittest.TestCase): def test_generate_samples(self, mock_get_stats): expected_samples = {'xe0': { - 'in_packets': 150, - 'out_packets': 150, - 'in_bytes': 9600, - 'out_bytes': 9600, - 'rx_throughput_mbps': 0.0, - 'rx_throughput_kps': 0.0, + 'InPackets': 150, + 'OutPackets': 150, + 'InBytes': 9600, + 'OutBytes': 9600, 'RxThroughput': 5.0, 'TxThroughput': 5.0, 'RxThroughputBps': 320.0, 'TxThroughputBps': 320.0, - 'tx_throughput_mbps': 0.0, - 'tx_throughput_kps': 0.0, - 'Store-Forward_Max_latency_ns': 100, - 'Store-Forward_Min_latency_ns': 100, - 'Store-Forward_Avg_latency_ns': 100}, + 'LatencyMax': 100, + 'LatencyMin': 100, + 'LatencyAvg': 100}, 'xe1': { - 'in_packets': 150, - 'out_packets': 150, - 'in_bytes': 9600, - 'out_bytes': 9600, - 'rx_throughput_mbps': 0.0, - 'rx_throughput_kps': 0.0, + 'InPackets': 150, + 'OutPackets': 150, + 'InBytes': 9600, + 'OutBytes': 9600, 'RxThroughput': 5.0, 'TxThroughput': 5.0, 'RxThroughputBps': 320.0, 'TxThroughputBps': 320.0, - 'tx_throughput_mbps': 0.0, - 'tx_throughput_kps': 0.0, - 'Store-Forward_Max_latency_ns': 200, - 'Store-Forward_Min_latency_ns': 200, - 'Store-Forward_Avg_latency_ns': 200}} + 'LatencyMax': 200, + 'LatencyMin': 200, + 'LatencyAvg': 200}} res_helper = mock.Mock() res_helper.vnfd_helper.find_interface_by_port.side_effect = \ @@ -1211,58 +1203,50 @@ class TestIxiaPppoeClientScenario(unittest.TestCase): prio_flows_stats = { '0': { - 'in_packets': 6000, - 'out_packets': 6000, + 'InPackets': 6000, + 'OutPackets': 6000, 'RxThroughput': 200.0, 'TxThroughput': 200.0, - 'avg_latency_ns': 2, - 'max_latency_ns': 2, - 'min_latency_ns': 2 + 'LatencyAvg': 2, + 'LatencyMax': 2, + 'LatencyMin': 2 } } expected_result = {'priority_stats': { '0': {'RxThroughput': 200.0, 'TxThroughput': 200.0, - 'avg_latency_ns': 2, - 'max_latency_ns': 2, - 'min_latency_ns': 2, - 'in_packets': 6000, - 'out_packets': 6000}}, + 'LatencyAvg': 2, + 'LatencyMax': 2, + 'LatencyMin': 2, + 'InPackets': 6000, + 'OutPackets': 6000}}, 'xe0': {'RxThroughput': 100.0, - 'Store-Forward_Avg_latency_ns': 2, - 'Store-Forward_Max_latency_ns': 2, - 'Store-Forward_Min_latency_ns': 2, + 'LatencyAvg': 2, + 'LatencyMax': 2, + 'LatencyMin': 2, 'TxThroughput': 100.0, - 'in_packets': 3000, - 'out_packets': 3000, - 'in_bytes': 192000, - 'out_bytes': 192000, + 'InPackets': 3000, + 'OutPackets': 3000, + 'InBytes': 192000, + 'OutBytes': 192000, 'RxThroughputBps': 6400.0, 'TxThroughputBps': 6400.0, - 'rx_throughput_kps': 0.0, - 'rx_throughput_mbps': 0.0, - 'sessions_down': 0, - 'sessions_not_started': 0, - 'sessions_total': 1, - 'sessions_up': 1, - 'tx_throughput_kps': 0.0, - 'tx_throughput_mbps': 0.0}, + 'SessionsDown': 0, + 'SessionsNotStarted': 0, + 'SessionsTotal': 1, + 'SessionsUp': 1}, 'xe1': {'RxThroughput': 100.0, - 'Store-Forward_Avg_latency_ns': 2, - 'Store-Forward_Max_latency_ns': 2, - 'Store-Forward_Min_latency_ns': 2, + 'LatencyAvg': 2, + 'LatencyMax': 2, + 'LatencyMin': 2, 'TxThroughput': 100.0, - 'in_packets': 3000, - 'out_packets': 3000, - 'in_bytes': 192000, - 'out_bytes': 192000, + 'InPackets': 3000, + 'OutPackets': 3000, + 'InBytes': 192000, + 'OutBytes': 192000, 'RxThroughputBps': 6400.0, - 'TxThroughputBps': 6400.0, - 'rx_throughput_kps': 0.0, - 'rx_throughput_mbps': 0.0, - 'tx_throughput_kps': 0.0, - 'tx_throughput_mbps': 0.0}} + 'TxThroughputBps': 6400.0}} mock_get_stats.return_value = ixia_stats mock_prio_flow_statistics.return_value = prio_flows_stats |