Do NOT hardcode interface speed for PROX tests 47/53247/19
authorDanielMartinBuckley <daniel.m.buckley@intel.com>
Wed, 7 Mar 2018 18:09:12 +0000 (18:09 +0000)
committerDanielMartinBuckley <daniel.m.buckley@intel.com>
Fri, 9 Mar 2018 14:04:03 +0000 (14:04 +0000)
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 <daniel.m.buckley@intel.com>
docs/testing/developer/devguide/devguide_nsb_prox.rst
samples/vnf_samples/nsut/prox/tc_prox_baremetal_l2fwd-2.yaml
samples/vnf_samples/nsut/prox/tc_prox_baremetal_l2fwd-4.yaml
tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py
yardstick/network_services/constants.py
yardstick/network_services/traffic_profile/prox_binsearch.py
yardstick/network_services/vnf_generic/vnf/prox_helpers.py
yardstick/network_services/vnf_generic/vnf/prox_vnf.py
yardstick/network_services/vnf_generic/vnf/sample_vnf.py
yardstick/network_services/vnf_generic/vnf/vnf_ssh_helper.py

index fc533b2..2262841 100755 (executable)
@@ -251,9 +251,11 @@ Now let's examine the components of the file in detail
    In this case it is ``handle_l2fwd-2.cfg``
 
    A number of additional parameters can be added. This example
-   is taken from VPE::
+   is for VPE::
 
     options:
+      interface_speed_gbps: 10
+
       vnf__0:
         prox_path: /opt/nsb_bin/prox
         prox_config: ``configs/handle_vpe-4.cfg``
@@ -267,6 +269,12 @@ Now let's examine the components of the file in detail
           ``configs/vpe_rules.lua`` : ````
         prox_generate_parameter: True
 
+   ``interface_speed_gbps`` - this specifies the speed of the interface
+   in Gigabits Per Second. This is used to calculate pps(packets per second).
+   If the interfaces are of different speeds, then this specifies the speed
+   of the slowest interface. This parameter is optional. If omitted the
+   interface speed defaults to 10Gbps.
+
    ``prox_files`` - this specified that a number of addition files
    need to be provided for the test to run correctly. This files
    could provide routing information,hashing information or a
index b1fef6d..69778ed 100644 (file)
@@ -26,6 +26,8 @@ scenarios:
     vnf__0: vnf_0.yardstick
 
   options:
+    interface_speed_gbps: 10
+
     vnf__0:
       prox_path: /opt/nsb_bin/prox
       prox_config: "configs/handle_l2fwd-2.cfg"
index e17c5c2..ab067a8 100644 (file)
@@ -26,6 +26,8 @@ scenarios:
     vnf__0: vnf_0.yardstick
 
   options:
+    interface_speed_gbps: 10
+
     vnf__0:
       prox_path: /opt/nsb_bin/prox
       prox_config: "configs/handle_l2fwd-4.cfg"
index faceeb6..bc48f99 100644 (file)
@@ -24,7 +24,7 @@ import unittest
 from tests.unit import STL_MOCKS
 from yardstick.common import utils
 from yardstick.network_services.vnf_generic.vnf.base import VnfdHelper
-
+from yardstick.network_services import constants
 
 STLClient = mock.MagicMock()
 stl_patch = mock.patch.dict("sys.modules", STL_MOCKS)
@@ -46,7 +46,6 @@ if stl_patch:
     from yardstick.network_services.vnf_generic.vnf.prox_helpers import ProxVpeProfileHelper
     from yardstick.network_services.vnf_generic.vnf.prox_helpers import ProxlwAFTRProfileHelper
 
-
 class TestCoreTuple(unittest.TestCase):
     def test___init__(self):
         core_tuple = CoreSocketTuple('core 5s6')
@@ -1537,7 +1536,9 @@ class TestProxDataHelper(unittest.TestCase):
         sut = mock.MagicMock()
         sut.port_stats.return_value = list(range(10))
 
-        data_helper = ProxDataHelper(vnfd_helper, sut, pkt_size, 25, None)
+        data_helper = ProxDataHelper(
+            vnfd_helper, sut, pkt_size, 25, None,
+            constants.NIC_GBPS_DEFAULT * constants.ONE_GIGABIT_IN_BITS)
 
         self.assertEqual(data_helper.rx_total, 6)
         self.assertEqual(data_helper.tx_total, 7)
@@ -1551,7 +1552,7 @@ class TestProxDataHelper(unittest.TestCase):
         sut = mock.MagicMock()
         sut.port_stats.return_value = list(range(10))
 
-        data_helper = ProxDataHelper(vnfd_helper, sut, None, None, None)
+        data_helper = ProxDataHelper(vnfd_helper, sut, None, None, None, None)
 
         expected = {
             'xe1': {
@@ -1574,13 +1575,15 @@ class TestProxDataHelper(unittest.TestCase):
         sut = mock.MagicMock()
         sut.port_stats.return_value = list(range(10))
 
-        data_helper = ProxDataHelper(vnfd_helper, sut, None, None, 5.4)
+        data_helper = ProxDataHelper(vnfd_helper, sut, None, None,
+            5.4, constants.NIC_GBPS_DEFAULT * constants.ONE_GIGABIT_IN_BITS)
         data_helper._totals_and_pps = 12, 32, 4.5
         data_helper.tsc_hz = 9.8
         data_helper.measured_stats = {'delta': TotStatsTuple(6.1, 6.2, 6.3, 6.4)}
         data_helper.latency = 7
 
         self.assertIsNone(data_helper.result_tuple)
+        self.assertEqual(data_helper.line_speed, 10000000000)
 
         expected = ProxTestDataTuple(5.4, 9.8, 6.1, 6.2, 6.3, 7, 12, 32, 4.5)
         with data_helper:
@@ -1595,7 +1598,7 @@ class TestProxDataHelper(unittest.TestCase):
     def test___enter___negative(self):
         vnfd_helper = mock.MagicMock()
 
-        data_helper = ProxDataHelper(vnfd_helper, None, None, None, None)
+        data_helper = ProxDataHelper(vnfd_helper, None, None, None, None, None)
 
         vnfd_helper.port_pairs.all_ports = []
         with self.assertRaises(AssertionError):
@@ -1617,7 +1620,7 @@ class TestProxDataHelper(unittest.TestCase):
         sut = ProxSocketHelper(mock.MagicMock())
         sut.get_all_tot_stats = mock.MagicMock(side_effect=[start, end])
 
-        data_helper = ProxDataHelper(vnfd_helper, sut, None, None, 5.4)
+        data_helper = ProxDataHelper(vnfd_helper, sut, None, None, 5.4, None)
 
         self.assertIsNone(data_helper.measured_stats)
 
@@ -1638,7 +1641,7 @@ class TestProxDataHelper(unittest.TestCase):
         sut = mock.MagicMock()
         sut.hz.return_value = '54.6'
 
-        data_helper = ProxDataHelper(vnfd_helper, sut, None, None, None)
+        data_helper = ProxDataHelper(vnfd_helper, sut, None, None, None, None)
 
         self.assertIsNone(data_helper.tsc_hz)
 
@@ -1935,7 +1938,8 @@ class TestProxProfileHelper(unittest.TestCase):
 
         helper = ProxProfileHelper(resource_helper)
 
-        helper.run_test(120, 5, 6.5)
+        helper.run_test(120, 5, 6.5,
+                        constants.NIC_GBPS_DEFAULT * constants.ONE_GIGABIT_IN_BITS)
 
 
 class TestProxMplsProfileHelper(unittest.TestCase):
@@ -2081,8 +2085,12 @@ class TestProxBngProfileHelper(unittest.TestCase):
 
         helper = ProxBngProfileHelper(resource_helper)
 
-        helper.run_test(120, 5, 6.5)
-        helper.run_test(-1000, 5, 6.5)  # negative pkt_size is the only way to make ratio > 1
+        helper.run_test(120, 5, 6.5,
+                        constants.NIC_GBPS_DEFAULT * constants.ONE_GIGABIT_IN_BITS)
+
+        # negative pkt_size is the only way to make ratio > 1
+        helper.run_test(-1000, 5, 6.5,
+                        constants.NIC_GBPS_DEFAULT * constants.ONE_GIGABIT_IN_BITS)
 
 
 class TestProxVpeProfileHelper(unittest.TestCase):
index 79951e3..0064b4f 100644 (file)
@@ -15,3 +15,5 @@
 REMOTE_TMP = "/tmp"
 DEFAULT_VNF_TIMEOUT = 3600
 PROCESS_JOIN_TIMEOUT = 3
+ONE_GIGABIT_IN_BITS = 1000000000
+NIC_GBPS_DEFAULT = 10
index 5700f98..c3277fb 100644 (file)
@@ -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
index 29f9c7b..e42431f 100644 (file)
@@ -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():
index 2cdb3f9..285e086 100644 (file)
@@ -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()
index ad78774..c19a8d4 100644 (file)
@@ -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
 
index 8e02cf3..de6fd93 100644 (file)
@@ -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)