X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=yardstick%2Fnetwork_services%2Fvnf_generic%2Fvnf%2Fudp_replay.py;h=3f9994486fd542f48a7e908db1fd708736202deb;hb=d05cb96c045a9a65d7db424300677f36f3d4f7b4;hp=6e206f2b27939bce187afc70688bab17166e9d07;hpb=a9be662eab5ee7a1a5db1905bd7877974422e780;p=yardstick.git diff --git a/yardstick/network_services/vnf_generic/vnf/udp_replay.py b/yardstick/network_services/vnf_generic/vnf/udp_replay.py index 6e206f2b2..3f9994486 100644 --- a/yardstick/network_services/vnf_generic/vnf/udp_replay.py +++ b/yardstick/network_services/vnf_generic/vnf/udp_replay.py @@ -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. @@ -15,52 +15,87 @@ from __future__ import absolute_import import logging +from yardstick.common.process import check_if_process_failed from yardstick.network_services.vnf_generic.vnf.sample_vnf import SampleVNF +from yardstick.network_services.vnf_generic.vnf.sample_vnf import DpdkVnfSetupEnvHelper +from yardstick.network_services.vnf_generic.vnf.sample_vnf import ClientResourceHelper +from yardstick.benchmark.contexts import base as ctx_base LOG = logging.getLogger(__name__) # UDP_Replay should work the same on all systems, we can provide the binary + +# we can't match the prompt regexp due to extra noise +# yardstick.ssh ssh.py:302 DEBUG stdout: UDP_Replay: lcore 0 has nothing to do +# eplUDP_Replay: -- lcoreid=1 portid=0 rxqueueid=0 +# ay> +# +# try decreasing log level to RTE_LOG_NOTICE (5) REPLAY_PIPELINE_COMMAND = ( - """sudo {tool_path} -c {cpu_mask_hex} -n 4 -w {whitelist} -- """ - """{hw_csum} -p {ports_len_hex} --config='{config}'""" + """sudo {tool_path} --log-level=5 -c {cpu_mask_hex} -n 4 -w {whitelist} -- """ + """{hw_csum} -p {port_mask_hex} --config='{config}'""" ) -# {tool_path} -p {ports_len_hex} -f {cfg_file} -s {script}' +# {tool_path} -p {port_mask_hex} -f {cfg_file} -s {script}' + + +class UdpReplaySetupEnvHelper(DpdkVnfSetupEnvHelper): + + APP_NAME = "UDP_Replay" + + +class UdpReplayResourceHelper(ClientResourceHelper): + pass class UdpReplayApproxVnf(SampleVNF): APP_NAME = "UDP_Replay" APP_WORD = "UDP_Replay" - PIPELINE_COMMAND = REPLAY_PIPELINE_COMMAND - VNF_PROMPT = 'Replay>' + # buffering issue? + VNF_PROMPT = 'eplay>' - CSUM_MAP = { - 'baremetal': '', - 'sriov': '', - } + VNF_TYPE = 'UdpReplay' - def scale(self, flavor=""): - """ scale vnfbased on flavor input """ - raise NotImplementedError + HW_OFFLOADING_NFVI_TYPES = {'baremetal', 'sriov'} - def _build_config(self): - pass + PIPELINE_COMMAND = REPLAY_PIPELINE_COMMAND + + def __init__(self, name, vnfd, setup_env_helper_type=None, resource_helper_type=None): + if resource_helper_type is None: + resource_helper_type = UdpReplayResourceHelper - def _deploy(self): - self.generate_port_pairs() - super(UdpReplayApproxVnf, self)._deploy() + if setup_env_helper_type is None: + setup_env_helper_type = UdpReplaySetupEnvHelper + + super(UdpReplayApproxVnf, self).__init__(name, vnfd, setup_env_helper_type, + resource_helper_type) def _build_pipeline_kwargs(self): - tool_path = self.ssh_helper.provision_tool(self.APP_NAME) - ports_mask = 2 ** len(self.all_ports) - 1 - ports_mask_hex = hex(ports_mask) - cpu_mask_hex = hex(ports_mask * 2) - hw_csum = self.CSUM_MAP.get(self.nfvi_type, "--no-hw-csum") - config_value = "".join(str((port, 0, port + 1)) for port in self.all_ports) - - whitelist = " -w ".join(self.bound_pci) + ports = self.vnfd_helper.port_pairs.all_ports + number_of_ports = len(ports) + + tool_path = self.ssh_helper.provision_tool(tool_file=self.APP_NAME) + port_nums = self.vnfd_helper.port_nums(ports) + ports_mask_hex = hex(sum(2 ** num for num in port_nums)) + # one core extra for master + cpu_mask_hex = hex(2 ** (number_of_ports + 1) - 1) + nfvi_context = ctx_base.Context.get_context_from_server( + self.scenario_helper.nodes[self.name]) + hw_csum = "" + if (not self.scenario_helper.options.get('hw_csum', False) or + nfvi_context.attrs.get('nfvi_type') not in self.HW_OFFLOADING_NFVI_TYPES): + hw_csum = '--no-hw-csum' + + # tuples of (FLD_PORT, FLD_QUEUE, FLD_LCORE) + # [--config (port,queue,lcore)[,(port,queue,lcore]]" + # start with lcore = 1 since we use lcore=0 for master + config_value = ",".join( + str((self.vnfd_helper.port_num(port), 0, core)).replace(" ", "") for core, port in + enumerate(self.vnfd_helper.port_pairs.all_ports, 1)) + + whitelist = " -w ".join(self.setup_helper.bound_pci) self.pipeline_kwargs = { - 'ports_len_hex': ports_mask_hex, + 'port_mask_hex': ports_mask_hex, 'tool_path': tool_path, 'hw_csum': hw_csum, 'whitelist': whitelist, @@ -68,18 +103,31 @@ class UdpReplayApproxVnf(SampleVNF): 'config': config_value, } + def _build_config(self): + self._build_pipeline_kwargs() + return self.PIPELINE_COMMAND.format(**self.pipeline_kwargs) + def collect_kpi(self): def get_sum(offset): return sum(int(i) for i in split_stats[offset::5]) + # we can't get KPIs if the VNF is down + check_if_process_failed(self._vnf_process) + + number_of_ports = len(self.vnfd_helper.port_pairs.all_ports) stats = self.get_stats() stats_words = stats.split() - split_stats = stats_words[stats_words.index('0'):][:len(self.all_ports) * 5] + split_stats = stats_words[stats_words.index('0'):][:number_of_ports * 5] + + physical_node = ctx_base.Context.get_physical_node_from_server( + self.scenario_helper.nodes[self.name]) + result = { + "physical_node": physical_node, "packets_in": get_sum(1), "packets_fwd": get_sum(2), "packets_dropped": get_sum(3) + get_sum(4), - "collect_stats": {}, + 'collect_stats': self.resource_helper.collect_kpi(), } LOG.debug("UDP Replay collect KPIs %s", result)