summaryrefslogtreecommitdiffstats
path: root/core/traffic_controller.py
diff options
context:
space:
mode:
authorMartin Klozik <martinx.klozik@intel.com>2017-08-31 15:01:18 +0200
committerMartin Klozik <martinx.klozik@intel.com>2017-11-03 08:36:29 +0000
commitb1534957e463b5e34957a8d48ce5c6b0552ffbb4 (patch)
tree10985b181d62cffb4ea36355de66dc8ea4edbf8a /core/traffic_controller.py
parent87f6e48ca1b17361955f0d31551b0c6360028688 (diff)
teststeps: Improvements and bugfixing of teststeps
This patch introduces several improvements and small bugfixes of teststeps. These changes were identified during implementation of OVS/DPDK regression tests. Patch content: * teststeps: step aliases were implemented * teststeps: improved filtering by regex for any step, which returns string or list of stings; filter will process all lines * teststeps: support for log object * teststeps: support for trafficgen get_results call * teststeps: configurable suppression of step validation * trafficgen: remove old results before traffic is executed * trafficgen: support for flow control on/off (IxNet) * trafficgen: support for configurable learning frames (IxNet) * trafficgen: support for runtime changes of TRAFFICGEN_PKT_SIZES, _DURATION and _LOSSRATE * vnf: flush pexpect output of previous commands * vnf: use execute_and_wait() to ensure correct cmds order * vnf: dpdk vHost User interface name set according to its type, e.g. dpdkvhostuserclient * vswitch: support for OVS restart * decap: simplify configuration of tunneling decapsulation tests * settings: values of all configuration options are restored after TC execution * modified formatting of test description used by --list * testcase name and description is logged before its execution * small bugfixes JIRA: VSPERF-539 Change-Id: I550ba0d897ece89abd3f33d6d66f545c4d863e7b Signed-off-by: Martin Klozik <martinx.klozik@intel.com> Reviewed-by: Al Morton <acmorton@att.com> Reviewed-by: Christian Trautman <ctrautma@redhat.com> Reviewed-by: Sridhar Rao <sridhar.rao@spirent.com> Reviewed-by: Trevor Cooper <trevor.cooper@intel.com>
Diffstat (limited to 'core/traffic_controller.py')
-rw-r--r--core/traffic_controller.py39
1 files changed, 28 insertions, 11 deletions
diff --git a/core/traffic_controller.py b/core/traffic_controller.py
index 5ebdc0d9..d6e7629c 100644
--- a/core/traffic_controller.py
+++ b/core/traffic_controller.py
@@ -40,13 +40,25 @@ class TrafficController(object):
self._traffic_gen_class = traffic_gen_class()
self._traffic_started = False
self._traffic_started_call_count = 0
+ self._duration = None
+ self._lossrate = None
+ self._packet_sizes = None
+
+ self._mode = str(settings.getValue('mode')).lower()
+ self._results = []
+
+ def configure(self, traffic):
+ """Set configuration values just before test execution so they
+ can be changed during runtime by test steps.
+ """
self._duration = int(settings.getValue('TRAFFICGEN_DURATION'))
self._lossrate = float(settings.getValue('TRAFFICGEN_LOSSRATE'))
self._packet_sizes = settings.getValue('TRAFFICGEN_PKT_SIZES')
-
- self._mode = str(settings.getValue('mode')).lower()
self._results = []
+ # update type with detailed traffic value
+ self._type = traffic['traffic_type']
+
def __enter__(self):
"""Call initialisation function.
"""
@@ -101,18 +113,18 @@ class TrafficController(object):
print("Please respond with 'yes', 'y', 'no' or 'n' ", end='')
return True
- def send_traffic(self, dummy_traffic):
+ def send_traffic(self, traffic):
"""Triggers traffic to be sent from the traffic generator.
This is a blocking function.
:param traffic: A dictionary describing the traffic to send.
"""
- raise NotImplementedError(
- "The TrafficController does not implement",
- "the \"send_traffic\" function.")
+ self._logger.debug('send_traffic with ' +
+ str(self._traffic_gen_class))
+ self.configure(traffic)
- def send_traffic_async(self, dummy_traffic, dummy_function):
+ def send_traffic_async(self, traffic, dummy_function):
"""Triggers traffic to be sent asynchronously.
This is not a blocking function.
@@ -127,9 +139,9 @@ class TrafficController(object):
If this function requires more than one argument, all should be
should be passed using the args list and appropriately handled.
"""
- raise NotImplementedError(
- "The TrafficController does not implement",
- "the \"send_traffic_async\" function.")
+ self._logger.debug('send_traffic_async with ' +
+ str(self._traffic_gen_class))
+ self.configure(traffic)
def stop_traffic(self):
"""Kills traffic being sent from the traffic generator.
@@ -155,7 +167,7 @@ class TrafficController(object):
def validate_send_traffic(self, dummy_result, dummy_traffic):
"""Verify that send traffic has succeeded
"""
- if len(self._results):
+ if self._results:
if 'b2b_frames' in self._results[-1]:
return float(self._results[-1]['b2b_frames']) > 0
elif 'throughput_rx_fps' in self._results[-1]:
@@ -164,3 +176,8 @@ class TrafficController(object):
return True
else:
return False
+
+ def validate_get_results(self, result):
+ """Verify that results has been returned
+ """
+ return self._results == result