From f7e477133cfc87134bb860aaaf39d932bbae1907 Mon Sep 17 00:00:00 2001 From: DanielMartinBuckley Date: Wed, 7 Mar 2018 18:09:12 +0000 Subject: Do NOT hardcode interface speed for PROX tests JIRA: YARDSTICK-1035 Do not hardcode NIC/interface speed in PROX test. Test assumes NIC used is 10Gbps. This is incorrect. It could support 1Gbps, 10Gbps, 25Gbps, 40Gbps or something else. This is used to calculate pps (Packets Per Second) In Baremetal the NIC speed could be extracted. however when run on a virtual machine this is not possible. Solution: Add in options section of test file. eg. Options: interface_speed_gbps: 10 Where 10 refers to a 10Gbps. In a setup where multiple interfaces are used. This will refer to the speed of the slowest connection. Change-Id: I89ab16479a2cdd1d79e52cbcc5a972762c60d057 Signed-off-by: Daniel Martin Buckley --- yardstick/network_services/constants.py | 2 ++ .../traffic_profile/prox_binsearch.py | 7 +++- .../vnf_generic/vnf/prox_helpers.py | 38 +++++++++++++--------- .../network_services/vnf_generic/vnf/prox_vnf.py | 4 +-- .../network_services/vnf_generic/vnf/sample_vnf.py | 18 +++++----- .../vnf_generic/vnf/vnf_ssh_helper.py | 4 +-- 6 files changed, 43 insertions(+), 30 deletions(-) (limited to 'yardstick') diff --git a/yardstick/network_services/constants.py b/yardstick/network_services/constants.py index 79951e353..0064b4fc5 100644 --- a/yardstick/network_services/constants.py +++ b/yardstick/network_services/constants.py @@ -15,3 +15,5 @@ REMOTE_TMP = "/tmp" DEFAULT_VNF_TIMEOUT = 3600 PROCESS_JOIN_TIMEOUT = 3 +ONE_GIGABIT_IN_BITS = 1000000000 +NIC_GBPS_DEFAULT = 10 diff --git a/yardstick/network_services/traffic_profile/prox_binsearch.py b/yardstick/network_services/traffic_profile/prox_binsearch.py index 5700f98e5..c3277fb12 100644 --- a/yardstick/network_services/traffic_profile/prox_binsearch.py +++ b/yardstick/network_services/traffic_profile/prox_binsearch.py @@ -20,6 +20,7 @@ import datetime import time from yardstick.network_services.traffic_profile.prox_profile import ProxProfile +from yardstick.network_services import constants LOG = logging.getLogger(__name__) @@ -99,9 +100,13 @@ class ProxBinSearchProfile(ProxProfile): # throughput and packet loss from the most recent successful test successful_pkt_loss = 0.0 + line_speed = traffic_gen.scenario_helper.all_options.get( + "interface_speed_gbps", constants.NIC_GBPS_DEFAULT) * constants.ONE_GIGABIT_IN_BITS for test_value in self.bounds_iterator(LOG): result, port_samples = self._profile_helper.run_test(pkt_size, duration, - test_value, self.tolerated_loss) + test_value, + self.tolerated_loss, + line_speed) self.curr_time = time.time() diff_time = self.curr_time - self.prev_time self.prev_time = self.curr_time diff --git a/yardstick/network_services/vnf_generic/vnf/prox_helpers.py b/yardstick/network_services/vnf_generic/vnf/prox_helpers.py index 29f9c7bba..e42431f94 100644 --- a/yardstick/network_services/vnf_generic/vnf/prox_helpers.py +++ b/yardstick/network_services/vnf_generic/vnf/prox_helpers.py @@ -35,6 +35,7 @@ from yardstick.common.utils import SocketTopology, join_non_strings, try_int from yardstick.network_services.helpers.iniparser import ConfigParser from yardstick.network_services.vnf_generic.vnf.sample_vnf import ClientResourceHelper from yardstick.network_services.vnf_generic.vnf.sample_vnf import DpdkVnfSetupEnvHelper +from yardstick.network_services import constants PROX_PORT = 8474 @@ -44,7 +45,6 @@ SECTION_CONTENTS = 1 LOG = logging.getLogger(__name__) LOG.setLevel(logging.DEBUG) -TEN_GIGABIT = 1e10 BITS_PER_BYTE = 8 RETRY_SECONDS = 60 RETRY_INTERVAL = 1 @@ -466,13 +466,14 @@ class ProxSocketHelper(object): core_data['current'] = core_data[key1] + core_data[key2] self.set_speed(core_data['cores'], core_data['current']) - def set_pps(self, cores, pps, pkt_size): + def set_pps(self, cores, pps, pkt_size, + line_speed=(constants.ONE_GIGABIT_IN_BITS * constants.NIC_GBPS_DEFAULT)): """ set packets per second for specific cores on the remote instance """ msg = "Set packets per sec for core(s) %s to %g%% of line rate (packet size: %d)" LOG.debug(msg, cores, pps, pkt_size) # speed in percent of line-rate - speed = float(pps) * (pkt_size + 20) / TEN_GIGABIT / BITS_PER_BYTE + speed = float(pps) * (pkt_size + 20) / line_speed / BITS_PER_BYTE self._run_template_over_cores("speed {} 0 {}\n", cores, speed) def lat_stats(self, cores, task=0): @@ -967,12 +968,13 @@ class ProxResourceHelper(ClientResourceHelper): class ProxDataHelper(object): - def __init__(self, vnfd_helper, sut, pkt_size, value, tolerated_loss): + def __init__(self, vnfd_helper, sut, pkt_size, value, tolerated_loss, line_speed): super(ProxDataHelper, self).__init__() self.vnfd_helper = vnfd_helper self.sut = sut self.pkt_size = pkt_size self.value = value + self.line_speed = line_speed self.tolerated_loss = tolerated_loss self.port_count = len(self.vnfd_helper.port_pairs.all_ports) self.tsc_hz = None @@ -1058,9 +1060,7 @@ class ProxDataHelper(object): self.tsc_hz = float(self.sut.hz()) def line_rate_to_pps(self): - # NOTE: to fix, don't hardcode 10Gb/s - return self.port_count * TEN_GIGABIT / BITS_PER_BYTE / (self.pkt_size + 20) - + return self.port_count * self.line_speed / BITS_PER_BYTE / (self.pkt_size + 20) class ProxProfileHelper(object): @@ -1139,8 +1139,10 @@ class ProxProfileHelper(object): return cores - def run_test(self, pkt_size, duration, value, tolerated_loss=0.0): - data_helper = ProxDataHelper(self.vnfd_helper, self.sut, pkt_size, value, tolerated_loss) + def run_test(self, pkt_size, duration, value, tolerated_loss=0.0, + line_speed=(constants.ONE_GIGABIT_IN_BITS * constants.NIC_GBPS_DEFAULT)): + data_helper = ProxDataHelper(self.vnfd_helper, self.sut, pkt_size, + value, tolerated_loss, line_speed) with data_helper, self.traffic_context(pkt_size, value): with data_helper.measure_tot_stats(): @@ -1396,8 +1398,10 @@ class ProxBngProfileHelper(ProxProfileHelper): time.sleep(3) self.sut.stop(self.all_rx_cores) - def run_test(self, pkt_size, duration, value, tolerated_loss=0.0): - data_helper = ProxDataHelper(self.vnfd_helper, self.sut, pkt_size, value, tolerated_loss) + def run_test(self, pkt_size, duration, value, tolerated_loss=0.0, + line_speed=(constants.ONE_GIGABIT_IN_BITS * constants.NIC_GBPS_DEFAULT)): + data_helper = ProxDataHelper(self.vnfd_helper, self.sut, pkt_size, + value, tolerated_loss, line_speed) with data_helper, self.traffic_context(pkt_size, value): with data_helper.measure_tot_stats(): @@ -1583,8 +1587,10 @@ class ProxVpeProfileHelper(ProxProfileHelper): time.sleep(3) self.sut.stop(self.all_rx_cores) - def run_test(self, pkt_size, duration, value, tolerated_loss=0.0): - data_helper = ProxDataHelper(self.vnfd_helper, self.sut, pkt_size, value, tolerated_loss) + def run_test(self, pkt_size, duration, value, tolerated_loss=0.0, + line_speed=(constants.ONE_GIGABIT_IN_BITS * constants.NIC_GBPS_DEFAULT)): + data_helper = ProxDataHelper(self.vnfd_helper, self.sut, pkt_size, + value, tolerated_loss, line_speed) with data_helper, self.traffic_context(pkt_size, value): with data_helper.measure_tot_stats(): @@ -1772,8 +1778,10 @@ class ProxlwAFTRProfileHelper(ProxProfileHelper): time.sleep(3) self.sut.stop(self.all_rx_cores) - def run_test(self, pkt_size, duration, value, tolerated_loss=0.0): - data_helper = ProxDataHelper(self.vnfd_helper, self.sut, pkt_size, value, tolerated_loss) + def run_test(self, pkt_size, duration, value, tolerated_loss=0.0, + line_speed=(constants.ONE_GIGABIT_IN_BITS * constants.NIC_GBPS_DEFAULT)): + data_helper = ProxDataHelper(self.vnfd_helper, self.sut, pkt_size, + value, tolerated_loss, line_speed) with data_helper, self.traffic_context(pkt_size, value): with data_helper.measure_tot_stats(): diff --git a/yardstick/network_services/vnf_generic/vnf/prox_vnf.py b/yardstick/network_services/vnf_generic/vnf/prox_vnf.py index 2cdb3f904..285e08659 100644 --- a/yardstick/network_services/vnf_generic/vnf/prox_vnf.py +++ b/yardstick/network_services/vnf_generic/vnf/prox_vnf.py @@ -22,7 +22,7 @@ from yardstick.common.process import check_if_process_failed from yardstick.network_services.vnf_generic.vnf.prox_helpers import ProxDpdkVnfSetupEnvHelper from yardstick.network_services.vnf_generic.vnf.prox_helpers import ProxResourceHelper from yardstick.network_services.vnf_generic.vnf.sample_vnf import SampleVNF -from yardstick.network_services.constants import PROCESS_JOIN_TIMEOUT +from yardstick.network_services import constants LOG = logging.getLogger(__name__) @@ -136,5 +136,5 @@ class ProxApproxVnf(SampleVNF): self._tear_down() if self._vnf_process is not None: LOG.debug("joining before terminate %s", self._vnf_process.name) - self._vnf_process.join(PROCESS_JOIN_TIMEOUT) + self._vnf_process.join(constants.PROCESS_JOIN_TIMEOUT) self._vnf_process.terminate() diff --git a/yardstick/network_services/vnf_generic/vnf/sample_vnf.py b/yardstick/network_services/vnf_generic/vnf/sample_vnf.py index ad78774f0..c19a8d414 100644 --- a/yardstick/network_services/vnf_generic/vnf/sample_vnf.py +++ b/yardstick/network_services/vnf_generic/vnf/sample_vnf.py @@ -32,9 +32,7 @@ from yardstick.benchmark.contexts.base import Context from yardstick.common import exceptions as y_exceptions from yardstick.common.process import check_if_process_failed from yardstick.common import utils -from yardstick.network_services.constants import DEFAULT_VNF_TIMEOUT -from yardstick.network_services.constants import PROCESS_JOIN_TIMEOUT -from yardstick.network_services.constants import REMOTE_TMP +from yardstick.network_services import constants from yardstick.network_services.helpers.dpdkbindnic_helper import DpdkBindHelper, DpdkNode from yardstick.network_services.helpers.samplevnf_helper import MultiPortConfig from yardstick.network_services.helpers.samplevnf_helper import PortPairs @@ -51,8 +49,8 @@ LOG = logging.getLogger(__name__) class SetupEnvHelper(object): - CFG_CONFIG = os.path.join(REMOTE_TMP, "sample_config") - CFG_SCRIPT = os.path.join(REMOTE_TMP, "sample_script") + CFG_CONFIG = os.path.join(constants.REMOTE_TMP, "sample_config") + CFG_SCRIPT = os.path.join(constants.REMOTE_TMP, "sample_script") DEFAULT_CONFIG_TPL_CFG = "sample.cfg" PIPELINE_COMMAND = '' VNF_TYPE = "SAMPLE" @@ -610,8 +608,8 @@ class ScenarioHelper(object): @property def timeout(self): test_duration = self.scenario_cfg.get('runner', {}).get('duration', - self.options.get('timeout', DEFAULT_VNF_TIMEOUT)) - test_timeout = self.options.get('timeout', DEFAULT_VNF_TIMEOUT) + self.options.get('timeout', constants.DEFAULT_VNF_TIMEOUT)) + test_timeout = self.options.get('timeout', constants.DEFAULT_VNF_TIMEOUT) return test_duration if test_duration > test_timeout else test_timeout class SampleVNF(GenericVNF): @@ -796,7 +794,7 @@ class SampleVNF(GenericVNF): if self._vnf_process is not None: # be proper and join first before we kill LOG.debug("joining before terminate %s", self._vnf_process.name) - self._vnf_process.join(PROCESS_JOIN_TIMEOUT) + self._vnf_process.join(constants.PROCESS_JOIN_TIMEOUT) self._vnf_process.terminate() # no terminate children here because we share processes with tg @@ -940,12 +938,12 @@ class SampleVNFTrafficGen(GenericTrafficGen): if self._traffic_process is not None: # be proper and try to join before terminating LOG.debug("joining before terminate %s", self._traffic_process.name) - self._traffic_process.join(PROCESS_JOIN_TIMEOUT) + self._traffic_process.join(constants.PROCESS_JOIN_TIMEOUT) self._traffic_process.terminate() if self._tg_process is not None: # be proper and try to join before terminating LOG.debug("joining before terminate %s", self._tg_process.name) - self._tg_process.join(PROCESS_JOIN_TIMEOUT) + self._tg_process.join(constants.PROCESS_JOIN_TIMEOUT) self._tg_process.terminate() # no terminate children here because we share processes with vnf diff --git a/yardstick/network_services/vnf_generic/vnf/vnf_ssh_helper.py b/yardstick/network_services/vnf_generic/vnf/vnf_ssh_helper.py index 8e02cf3ac..de6fd9329 100644 --- a/yardstick/network_services/vnf_generic/vnf/vnf_ssh_helper.py +++ b/yardstick/network_services/vnf_generic/vnf/vnf_ssh_helper.py @@ -17,7 +17,7 @@ import os from six.moves import StringIO -from yardstick.network_services.constants import REMOTE_TMP +from yardstick.network_services import constants from yardstick.ssh import AutoConnectSSH LOG = logging.getLogger(__name__) @@ -46,7 +46,7 @@ class VnfSshHelper(AutoConnectSSH): return self.get_class()(self.node, self.bin_path) def upload_config_file(self, prefix, content): - cfg_file = os.path.join(REMOTE_TMP, prefix) + cfg_file = os.path.join(constants.REMOTE_TMP, prefix) LOG.debug(content) file_obj = StringIO(content) self.put_file_obj(file_obj, cfg_file) -- cgit 1.2.3-korg