vsperf: Enhanced vswitchperf configuration 61/24361/6
authorMartin Klozik <martinx.klozik@intel.com>
Thu, 10 Nov 2016 14:58:44 +0000 (14:58 +0000)
committerMartin Klozik <martinx.klozik@intel.com>
Wed, 30 Nov 2016 15:03:31 +0000 (15:03 +0000)
Original implementation of vsperf specific class
was changed to relfect recent vsperf changes. It is
now possible to modify any of vsperf's configuration
parameters via --test-param CLI argument. It means, that
it is possible to write a yardstick TC, which will define
all required vsperf configuration inside the YAML TC
definition.
Vsperf documentation related to yardstick usage and
sample TC files are located inside vsperf repository
and they were updated by a separate patch.

JIRA: VSPERF-422

Change-Id: I978d1c85ffeb3c90d9d47a20c6c0e0f68b437123
Signed-off-by: Martin Klozik <martinx.klozik@intel.com>
Reviewed-by: <sunshine.wang@huawei.com>
Reviewed-by: <lvjing5@huawei.com>
Reviewed-by: <jean.gaoliang@huawei.com>
Reviewed-by: <david.j.chou@intel.com>
tests/unit/benchmark/scenarios/networking/test_vsperf.py
yardstick/benchmark/scenarios/networking/vsperf.py

index cb5c09a..25d5221 100644 (file)
@@ -39,17 +39,17 @@ class VsperfTestCase(unittest.TestCase):
         }
         self.args = {
             'options': {
-                'testname': 'rfc2544_p2p_continuous',
+                'testname': 'p2p_rfc2544_continuous',
                 'traffic_type': 'continuous',
-                'pkt_sizes': '64',
+                'frame_size': '64',
                 'bidirectional': 'True',
                 'iload': 100,
-                'duration': 29,
                 'trafficgen_port1': 'eth1',
                 'trafficgen_port2': 'eth3',
                 'external_bridge': 'br-ex',
-                'conf-file': 'vsperf-yardstick.conf',
-                'setup-script': 'setup_yardstick.sh',
+                'conf_file': 'vsperf-yardstick.conf',
+                'setup_script': 'setup_yardstick.sh',
+                'test_params': 'TRAFFICGEN_DURATION=30;',
             },
             'sla': {
                 'metrics': 'throughput_rx_fps',
index 82db1e2..39912a9 100644 (file)
@@ -32,14 +32,11 @@ class Vsperf(base.Scenario):
     the valid values are "rfc2544", "continuous", "back2back"
         type:    string
         default: "rfc2544"
-    pkt_sizes - a packet size for which test should be executed;
-        Multiple packet sizes can be tested by modification of Sequence runner
+    frame_size - a frame size for which test should be executed;
+        Multiple frame sizes can be tested by modification of sequence runner
         section inside TC YAML definition.
         type:    string
         default: "64"
-    duration - sets duration for which traffic will be generated
-        type:    int
-        default: 30
     bidirectional - speficies if traffic will be uni (False) or bi-directional
         (True)
         type:    string
@@ -47,9 +44,6 @@ class Vsperf(base.Scenario):
     iload - specifies frame rate
         type:    string
         default: 100
-    rfc2544_trials - the number of trials performed for each packet size
-        type:    string
-        default: NA
     multistream - the number of simulated streams
         type:    string
         default: 0 (disabled)
@@ -57,11 +51,24 @@ class Vsperf(base.Scenario):
         the valid values are "L4", "L3" and "L2"
         type:    string
         default: "L4"
-    conf-file - path to the vsperf configuration file, which will be uploaded
-        to the VM
+    test_params - specifies a string with a list of vsperf configuration
+        parameters, which will be passed to the '--test-params' CLI argument;
+        Parameters should be stated in the form of 'param=value' and separated
+        by a semicolon. Please check VSPERF documentation for details about
+        available configuration parameters and their data types.
+        In case that both 'test_params' and 'conf_file' are specified,
+        then values from 'test_params' will override values defined
+        in the configuration file.
+        type:    string
+        default: NA
+    conf_file - path to the vsperf configuration file, which will be uploaded
+        to the VM;
+        In case that both 'test_params' and 'conf_file' are specified,
+        then values from 'test_params' will override values defined
+        in configuration file.
         type:   string
         default: NA
-    setup-script - path to the setup script, which will be executed during
+    setup_script - path to the setup script, which will be executed during
         setup and teardown phases
         type:   string
         default: NA
@@ -80,8 +87,6 @@ class Vsperf(base.Scenario):
     """
     __scenario_type__ = "Vsperf"
 
-    VSPERF_CONF = '~/vsperf-yardstick.conf'
-
     def __init__(self, scenario_cfg, context_cfg):
         self.scenario_cfg = scenario_cfg
         self.context_cfg = context_cfg
@@ -93,13 +98,18 @@ class Vsperf(base.Scenario):
                                                          None)
         self.br_ex = self.scenario_cfg['options'].get('external_bridge',
                                                       'br-ex')
-        self.vsperf_conf = os.path.expanduser(
-            self.scenario_cfg['options'].get('conf-file', Vsperf.VSPERF_CONF))
-        self.setup_script = self.scenario_cfg['options'].get('setup-script',
+        self.vsperf_conf = self.scenario_cfg['options'].get('conf_file', None)
+        if self.vsperf_conf:
+            self.vsperf_conf = os.path.expanduser(self.vsperf_conf)
+
+        self.setup_script = self.scenario_cfg['options'].get('setup_script',
                                                              None)
         if self.setup_script:
             self.setup_script = os.path.expanduser(self.setup_script)
 
+        self.test_params = self.scenario_cfg['options'].get('test-params',
+                                                            None)
+
     def setup(self):
         '''scenario setup'''
         vsperf = self.context_cfg['host']
@@ -123,9 +133,10 @@ class Vsperf(base.Scenario):
         # traffic generation could last long
         self.client.wait(timeout=1800)
 
-        # copy script to host
-        self.client.run("cat > ~/vsperf.conf",
-                        stdin=open(self.vsperf_conf, "rb"))
+        # copy script to host if needed
+        if self.vsperf_conf:
+            self.client.run("cat > ~/vsperf.conf",
+                            stdin=open(self.vsperf_conf, "rb"))
 
         # execute external setup script
         if self.setup_script:
@@ -166,18 +177,26 @@ class Vsperf(base.Scenario):
         options = self.scenario_cfg['options']
         test_params = []
         test_params.append(add_test_params(options, "traffic_type", "rfc2544"))
-        test_params.append(add_test_params(options, "pkt_sizes", "64"))
-        test_params.append(add_test_params(options, "duration", None))
         test_params.append(add_test_params(options, "bidirectional", "False"))
         test_params.append(add_test_params(options, "iload", 100))
-        test_params.append(add_test_params(options, "rfc2544_trials", None))
         test_params.append(add_test_params(options, "multistream", None))
         test_params.append(add_test_params(options, "stream_type", None))
+        if 'frame_size' in options:
+            test_params.append("%s=(%s,)" % ('TRAFFICGEN_PKT_SIZES',
+                                             options['frame_size']))
+        if 'test_params' in options:
+            test_params.append(options['test_params'])
+
+        # filter empty parameters and escape quotes and double quotes
+        test_params = [tp.replace('"', '\\"').replace("'", "\\'")
+                       for tp in test_params if tp]
 
         # execute vsperf
         cmd = "source ~/vsperfenv/bin/activate ; cd vswitchperf ; "
-        cmd += "./vsperf --mode trafficgen --conf-file ~/vsperf.conf "
-        cmd += "--test-params=\"%s\"" % (';'.join(filter(None, test_params)))
+        cmd += "./vsperf --mode trafficgen "
+        if self.vsperf_conf:
+            cmd += "--conf-file ~/vsperf.conf "
+        cmd += "--test-params=\"%s\"" % (';'.join(test_params))
         LOG.debug("Executing command: %s", cmd)
         status, stdout, stderr = self.client.execute(cmd)