aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/traffic_controller.py39
-rw-r--r--core/traffic_controller_rfc2544.py18
-rw-r--r--core/traffic_controller_rfc2889.py18
3 files changed, 46 insertions, 29 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
diff --git a/core/traffic_controller_rfc2544.py b/core/traffic_controller_rfc2544.py
index cb839518..488dde6f 100644
--- a/core/traffic_controller_rfc2544.py
+++ b/core/traffic_controller_rfc2544.py
@@ -30,8 +30,14 @@ class TrafficControllerRFC2544(TrafficController, IResults):
:param traffic_gen_class: The traffic generator class to be used.
"""
- super(TrafficControllerRFC2544, self).__init__(traffic_gen_class)
+ super().__init__(traffic_gen_class)
self._type = 'rfc2544'
+ self._tests = None
+
+ def configure(self, traffic):
+ """See TrafficController for description
+ """
+ super().configure(traffic)
self._tests = int(settings.getValue('TRAFFICGEN_RFC2544_TESTS'))
def send_traffic(self, traffic):
@@ -39,11 +45,8 @@ class TrafficControllerRFC2544(TrafficController, IResults):
"""
if not self.traffic_required():
return
- self._logger.debug('send_traffic with ' +
- str(self._traffic_gen_class))
- # update type with detailed traffic value
- self._type = traffic['traffic_type']
+ super().send_traffic(traffic)
for packet_size in self._packet_sizes:
# Merge framesize with the default traffic definition
@@ -74,11 +77,8 @@ class TrafficControllerRFC2544(TrafficController, IResults):
"""
if not self.traffic_required():
return
- self._logger.debug('send_traffic_async with ' +
- str(self._traffic_gen_class))
- # update type with detailed traffic value
- self._type = traffic['traffic_type']
+ super().send_traffic_async(traffic, function)
for packet_size in self._packet_sizes:
traffic['l2'] = {'framesize': packet_size}
diff --git a/core/traffic_controller_rfc2889.py b/core/traffic_controller_rfc2889.py
index 01aaa722..64ab0ba6 100644
--- a/core/traffic_controller_rfc2889.py
+++ b/core/traffic_controller_rfc2889.py
@@ -30,8 +30,14 @@ class TrafficControllerRFC2889(TrafficController, IResults):
:param traffic_gen_class: The traffic generator class to be used.
"""
- super(TrafficControllerRFC2889, self).__init__(traffic_gen_class)
+ super().__init__(traffic_gen_class)
self._type = 'rfc2889'
+ self._trials = None
+
+ def configure(self, traffic):
+ """See TrafficController for description
+ """
+ super().configure(traffic)
self._trials = int(settings.getValue('TRAFFICGEN_RFC2889_TRIALS'))
def send_traffic(self, traffic):
@@ -39,11 +45,8 @@ class TrafficControllerRFC2889(TrafficController, IResults):
"""
if not self.traffic_required():
return
- self._logger.debug('send_traffic with ' +
- str(self._traffic_gen_class))
- # update type with detailed traffic value
- self._type = traffic['traffic_type']
+ super().send_traffic(traffic)
for packet_size in self._packet_sizes:
# Merge framesize with the default traffic definition
@@ -71,11 +74,8 @@ class TrafficControllerRFC2889(TrafficController, IResults):
"""
if not self.traffic_required():
return
- self._logger.debug('send_traffic_async with ' +
- str(self._traffic_gen_class))
- # update type with detailed traffic value
- self._type = traffic['traffic_type']
+ super().send_traffic_async(traffic, function)
for packet_size in self._packet_sizes:
traffic['l2'] = {'framesize': packet_size}