vnfs: Enable PVP using vhost-user
[vswitchperf.git] / testcases / testcase.py
index cc1e6e4..77d5992 100644 (file)
@@ -14,7 +14,6 @@
 """TestCase base class
 """
 
-import time
 import csv
 import os
 import logging
@@ -31,7 +30,10 @@ class TestCase(object):
     def __init__(self, cfg, results_dir):
         """Pull out fields from test config
 
-        No external actions yet.
+        :param cfg: A dictionary of string-value pairs describing the test
+            configuration. Both the key and values strings use well-known
+            values.
+        :param results_dir: Where the csv formatted results are written.
         """
         self._logger = logging.getLogger(__name__)
         self.name = cfg['Name']
@@ -39,7 +41,12 @@ class TestCase(object):
         self._traffic_type = cfg['Traffic Type']
         self._deployment = cfg['Deployment']
         self._collector = cfg['Collector']
+        self._bidir = cfg['biDirectional']
+        self._frame_mod = cfg.get('Frame Modification', None)
+        if self._frame_mod:
+            self._frame_mod = self._frame_mod.lower()
         self._results_dir = results_dir
+        self._multistream = cfg.get('MultiStream', 0)
 
     def run(self):
         """Run the test
@@ -58,20 +65,32 @@ class TestCase(object):
             loader.get_vnf_class())
         vswitch_ctl = component_factory.create_vswitch(
             self._deployment,
-            loader.get_vswitch_class())
+            loader.get_vswitch_class(),
+            self._bidir)
         collector_ctl = component_factory.create_collector(
             self._collector,
             loader.get_collector_class())
 
+
         self._logger.debug("Setup:")
         collector_ctl.log_cpu_stats()
         with vswitch_ctl:
-            if vnf_ctl:
-                vnf_ctl.start()
-                traffic = {'traffic_type': self._traffic_type}
-            with traffic_ctl:
-                traffic_ctl.send_traffic(traffic)
-
+            with vnf_ctl:
+                traffic = {'traffic_type': self._traffic_type,
+                           'bidir': self._bidir,
+                           'multistream': self._multistream}
+
+                vswitch = vswitch_ctl.get_vswitch()
+                if self._frame_mod == "vlan":
+                    flow = {'table':'2', 'priority':'1000', 'metadata':'2',
+                            'actions': ['push_vlan:0x8100', 'goto_table:3']}
+                    vswitch.add_flow('br0', flow)
+                    flow = {'table':'2', 'priority':'1000', 'metadata':'1',
+                            'actions': ['push_vlan:0x8100', 'goto_table:3']}
+                    vswitch.add_flow('br0', flow)
+
+                with traffic_ctl:
+                    traffic_ctl.send_traffic(traffic)
 
         self._logger.debug("Traffic Results:")
         traffic_ctl.print_results()