summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorMartin Klozik <martinx.klozik@intel.com>2016-12-14 14:02:43 +0000
committerMartin Klozik <martinx.klozik@intel.com>2017-01-16 08:50:02 +0000
commit4481df385ac03ece015ccb429201f96189dc5ae2 (patch)
treea959a804e7b1efd663dbb24a447609421e339211 /tools
parentcafcb9f24b422a4b3a0b19ba00c83fe2819dcbaa (diff)
traffic: Configurable traffic details
Traffic generated by traffic generator is based on default values and their modifications specific to particular testing scenario. Traffic default values were defined inside VSPERF code and it was not possible to change them. This patch introduces new TRAFFIC dictionary inside 03_traffic.conf. Thus user can modify any of TRAFFIC values either in configuration file or by CLI or by 'Parameters' section of testcase definition. Following CLI options were obsoleted by this patch: 'bidirectional', 'traffic_type', 'iload', 'multistream', 'stream_type' and 'pre-installed_flows' Following CLI option was renamed to be consistent with other options: 'tunnel_type' => 'TUNNEL_TYPE' Following sections of testcase definition were obsoleted: "Traffic Type", "biDirectional", "MultiStream", "Stream Type", "Pre-installed Flows", "Flow Type" and "iLoad" New TRAFFIC dictionary should be used instead of old CLI options and old testcase definition sections. Testcase definitons, yardstick sample testcases and documentation were updated to reflect configuration changes. JIRA: VSPERF-433 Change-Id: I03a388c766491d5688e715f6d7b51e8e0377ec27 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: Bill Michalowski <bmichalo@redhat.com> Reviewed-by: Antonio Fischetti <antonio.fischetti@intel.com> Reviewed-by: <sridhar.rao@spirent.com>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/pkt_gen/dummy/dummy.py11
-rwxr-xr-xtools/pkt_gen/ixia/ixia.py5
-rwxr-xr-xtools/pkt_gen/ixnet/ixnet.py8
-rw-r--r--tools/pkt_gen/moongen/moongen.py18
-rwxr-xr-xtools/pkt_gen/trafficgen/__init__.py1
-rwxr-xr-xtools/pkt_gen/trafficgen/trafficgen.py14
-rw-r--r--tools/pkt_gen/trafficgen/trafficgenhelper.py94
-rwxr-xr-xtools/pkt_gen/xena/xena.py21
8 files changed, 27 insertions, 145 deletions
diff --git a/tools/pkt_gen/dummy/dummy.py b/tools/pkt_gen/dummy/dummy.py
index 528b5902..7a4daab6 100755
--- a/tools/pkt_gen/dummy/dummy.py
+++ b/tools/pkt_gen/dummy/dummy.py
@@ -26,6 +26,7 @@ own.
import json
from conf import settings
+from conf import merge_spec
from tools.pkt_gen import trafficgen
from core.results.results_constants import ResultsConstants
@@ -116,7 +117,7 @@ class Dummy(trafficgen.ITrafficGenerator):
result = {}
if traffic:
- traffic_ = trafficgen.merge_spec(traffic_, traffic)
+ traffic_ = merge_spec(traffic_, traffic)
results = get_user_traffic(
'burst',
@@ -135,7 +136,7 @@ class Dummy(trafficgen.ITrafficGenerator):
result[ResultsConstants.PAYLOAD_ERR] = results[1]
result[ResultsConstants.SEQ_ERR] = results[2]
- return trafficgen.BurstResult(*results)
+ return results
def send_cont_traffic(self, traffic=None, duration=30):
"""
@@ -145,7 +146,7 @@ class Dummy(trafficgen.ITrafficGenerator):
result = {}
if traffic:
- traffic_ = trafficgen.merge_spec(traffic_, traffic)
+ traffic_ = merge_spec(traffic_, traffic)
results = get_user_traffic(
'continuous',
@@ -182,7 +183,7 @@ class Dummy(trafficgen.ITrafficGenerator):
result = {}
if traffic:
- traffic_ = trafficgen.merge_spec(traffic_, traffic)
+ traffic_ = merge_spec(traffic_, traffic)
results = get_user_traffic(
'throughput',
@@ -219,7 +220,7 @@ class Dummy(trafficgen.ITrafficGenerator):
result = {}
if traffic:
- traffic_ = trafficgen.merge_spec(traffic_, traffic)
+ traffic_ = merge_spec(traffic_, traffic)
results = get_user_traffic(
'back2back',
diff --git a/tools/pkt_gen/ixia/ixia.py b/tools/pkt_gen/ixia/ixia.py
index 5c5fb3df..ed947e70 100755
--- a/tools/pkt_gen/ixia/ixia.py
+++ b/tools/pkt_gen/ixia/ixia.py
@@ -42,6 +42,7 @@ from collections import OrderedDict
from tools import systeminfo
from tools.pkt_gen import trafficgen
from conf import settings
+from conf import merge_spec
from core.results.results_constants import ResultsConstants
_ROOT_DIR = os.path.dirname(os.path.realpath(__file__))
@@ -203,7 +204,7 @@ class Ixia(trafficgen.ITrafficGenerator):
params['traffic'] = self.traffic_defaults.copy()
if traffic:
- params['traffic'] = trafficgen.merge_spec(
+ params['traffic'] = merge_spec(
params['traffic'], traffic)
for cmd in _build_set_cmds(params):
@@ -268,7 +269,7 @@ class Ixia(trafficgen.ITrafficGenerator):
params['traffic'] = self.traffic_defaults.copy()
if traffic:
- params['traffic'] = trafficgen.merge_spec(
+ params['traffic'] = merge_spec(
params['traffic'], traffic)
for cmd in _build_set_cmds(params):
diff --git a/tools/pkt_gen/ixnet/ixnet.py b/tools/pkt_gen/ixnet/ixnet.py
index 6262a10a..f84ab668 100755
--- a/tools/pkt_gen/ixnet/ixnet.py
+++ b/tools/pkt_gen/ixnet/ixnet.py
@@ -88,6 +88,7 @@ import csv
from collections import OrderedDict
from tools.pkt_gen import trafficgen
from conf import settings
+from conf import merge_spec
from core.results.results_constants import ResultsConstants
_ROOT_DIR = os.path.dirname(os.path.realpath(__file__))
@@ -155,6 +156,7 @@ class IxNet(trafficgen.ITrafficGenerator):
def __init__(self):
"""Initialize IXNET members
"""
+ super().__init__()
self._script = os.path.join(settings.getValue('TRAFFICGEN_IXIA_3RD_PARTY'),
settings.getValue('TRAFFICGEN_IXNET_TCL_SCRIPT'))
self._tclsh = tkinter.Tcl()
@@ -227,7 +229,7 @@ class IxNet(trafficgen.ITrafficGenerator):
self._params['traffic'] = self.traffic_defaults.copy()
if traffic:
- self._params['traffic'] = trafficgen.merge_spec(
+ self._params['traffic'] = merge_spec(
self._params['traffic'], traffic)
self._cfg['bidir'] = self._bidir
@@ -281,7 +283,7 @@ class IxNet(trafficgen.ITrafficGenerator):
self._params['traffic'] = self.traffic_defaults.copy()
if traffic:
- self._params['traffic'] = trafficgen.merge_spec(
+ self._params['traffic'] = merge_spec(
self._params['traffic'], traffic)
self._cfg['bidir'] = self._bidir
@@ -418,7 +420,7 @@ class IxNet(trafficgen.ITrafficGenerator):
self._params['traffic'] = self.traffic_defaults.copy()
if traffic:
- self._params['traffic'] = trafficgen.merge_spec(
+ self._params['traffic'] = merge_spec(
self._params['traffic'], traffic)
self._cfg['bidir'] = self._bidir
diff --git a/tools/pkt_gen/moongen/moongen.py b/tools/pkt_gen/moongen/moongen.py
index 7fd67661..9d604db2 100644
--- a/tools/pkt_gen/moongen/moongen.py
+++ b/tools/pkt_gen/moongen/moongen.py
@@ -28,19 +28,17 @@ import subprocess
# VSPerf imports
from conf import settings
+from conf import merge_spec
from core.results.results_constants import ResultsConstants
-from tools.pkt_gen.trafficgen.trafficgenhelper import (
- TRAFFIC_DEFAULTS,
- merge_spec)
from tools.pkt_gen.trafficgen.trafficgen import ITrafficGenerator
class Moongen(ITrafficGenerator):
"""Moongen Traffic generator wrapper."""
- _traffic_defaults = TRAFFIC_DEFAULTS.copy()
_logger = logging.getLogger(__name__)
def __init__(self):
"""Moongen class constructor."""
+ super().__init__()
self._logger.info("In moongen __init__ method")
self._params = {}
self._moongen_host_ip_addr = (
@@ -57,18 +55,6 @@ class Moongen(ITrafficGenerator):
'MOONGEN: Invalid line speed in configuration ' + \
'file (today 10Gbps supported)')
- @property
- def traffic_defaults(self):
- """Default traffic values.
-
- These can be expected to be constant across traffic generators,
- so no setter is provided. Changes to the structure or contents
- will likely break traffic generator implementations or tests
- respectively.
- """
- self._logger.info("In Moongen traffic_defaults method")
- return self._traffic_defaults
-
def create_moongen_cfg_file(self, traffic, duration=60,
acceptable_loss_pct=1, one_shot=0):
"""Create the Moongen configuration file from VSPERF's traffic profile
diff --git a/tools/pkt_gen/trafficgen/__init__.py b/tools/pkt_gen/trafficgen/__init__.py
index 2a3b9bd3..34d8ebe1 100755
--- a/tools/pkt_gen/trafficgen/__init__.py
+++ b/tools/pkt_gen/trafficgen/__init__.py
@@ -16,4 +16,3 @@
"""
from tools.pkt_gen.trafficgen.trafficgen import *
-from tools.pkt_gen.trafficgen.trafficgenhelper import *
diff --git a/tools/pkt_gen/trafficgen/trafficgen.py b/tools/pkt_gen/trafficgen/trafficgen.py
index fb40cd92..262df71d 100755
--- a/tools/pkt_gen/trafficgen/trafficgen.py
+++ b/tools/pkt_gen/trafficgen/trafficgen.py
@@ -15,16 +15,18 @@
This is an abstract class for traffic generators.
"""
+import copy
+from conf import settings
-#TODO update Back2Back method description when Result implementation will
-#be ready.
-
-from tools.pkt_gen.trafficgen.trafficgenhelper import TRAFFIC_DEFAULTS
+CMD_PREFIX = 'gencmd : '
class ITrafficGenerator(object):
"""Model of a traffic generator device.
"""
- _traffic_defaults = TRAFFIC_DEFAULTS.copy()
+ def __init__(self):
+ """Initialization of interface
+ """
+ self._default_traffic = copy.deepcopy(settings.getValue('TRAFFIC'))
@property
def traffic_defaults(self):
@@ -35,7 +37,7 @@ class ITrafficGenerator(object):
will likely break traffic generator implementations or tests
respectively.
"""
- return self._traffic_defaults
+ return self._default_traffic
def __enter__(self):
"""Connect to the traffic generator.
diff --git a/tools/pkt_gen/trafficgen/trafficgenhelper.py b/tools/pkt_gen/trafficgen/trafficgenhelper.py
deleted file mode 100644
index 47f8b262..00000000
--- a/tools/pkt_gen/trafficgen/trafficgenhelper.py
+++ /dev/null
@@ -1,94 +0,0 @@
-# Copyright 2015-2016 Intel Corporation.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-"""Helper methods collection.
-
-Collection of helper methods used by traffic generators
-implementation.
-"""
-
-from collections import namedtuple
-
-CMD_PREFIX = 'gencmd : '
-TRAFFIC_DEFAULTS = {
- 'traffic_type' : 'rfc2544_throughput',
- 'frame_rate' : 100,
- 'bidir' : 'False', # will be passed as string in title format to tgen
- 'multistream' : 0,
- 'stream_type' : 'L4',
- 'pre_installed_flows' : 'No', # used by vswitch implementation
- 'flow_type' : 'port', # used by vswitch implementation
-
- 'l2': {
- 'framesize': 64,
- 'srcmac': '00:00:00:00:00:00',
- 'dstmac': '00:00:00:00:00:00',
- },
- 'l3': {
- 'proto': 'udp',
- 'srcip': '1.1.1.1',
- 'dstip': '90.90.90.90',
- },
- 'l4': {
- 'srcport': 3000,
- 'dstport': 3001,
- },
- 'vlan': {
- 'enabled': False,
- 'id': 0,
- 'priority': 0,
- 'cfi': 0,
- },
-}
-
-#TODO remove namedtuples and implement results through IResult interface found
-#in core/results
-
-BurstResult = namedtuple(
- 'BurstResult',
- 'frames_tx frames_rx bytes_tx bytes_rx payload_err seq_err')
-Back2BackResult = namedtuple(
- 'Back2BackResult',
- 'rx_fps rx_mbps tx_percent rx_percent tx_count b2b_frames '
- 'frame_loss_frames frame_loss_percent')
-
-
-def merge_spec(orig, new):
- """Merges ``new`` dict with ``orig`` dict, and return orig.
-
- This takes into account nested dictionaries. Example:
-
- >>> old = {'foo': 1, 'bar': {'foo': 2, 'bar': 3}}
- >>> new = {'foo': 6, 'bar': {'foo': 7}}
- >>> merge_spec(old, new)
- {'foo': 6, 'bar': {'foo': 7, 'bar': 3}}
-
- You'll notice that ``bar.bar`` is not removed. This is the desired result.
- """
- for key in orig:
- if key not in new:
- continue
-
- # Not allowing derived dictionary types for now
- # pylint: disable=unidiomatic-typecheck
- if type(orig[key]) == dict:
- orig[key] = merge_spec(orig[key], new[key])
- else:
- orig[key] = new[key]
-
- for key in new:
- if key not in orig:
- orig[key] = new[key]
-
- return orig
-
diff --git a/tools/pkt_gen/xena/xena.py b/tools/pkt_gen/xena/xena.py
index 798bb832..20577e8d 100755
--- a/tools/pkt_gen/xena/xena.py
+++ b/tools/pkt_gen/xena/xena.py
@@ -36,10 +36,8 @@ import scapy.layers.inet as inet
# VSPerf imports
from conf import settings
+from conf import merge_spec
from core.results.results_constants import ResultsConstants
-from tools.pkt_gen.trafficgen.trafficgenhelper import (
- TRAFFIC_DEFAULTS,
- merge_spec)
from tools.pkt_gen.trafficgen.trafficgen import ITrafficGenerator
# Xena module imports
@@ -56,10 +54,10 @@ class Xena(ITrafficGenerator):
"""
Xena Traffic generator wrapper class
"""
- _traffic_defaults = TRAFFIC_DEFAULTS.copy()
_logger = logging.getLogger(__name__)
def __init__(self):
+ super().__init__()
self.mono_pipe = None
self.xmanager = None
self._params = {}
@@ -71,7 +69,7 @@ class Xena(ITrafficGenerator):
user_home = os.path.expanduser('~')
self._log_path = '{}/Xena/Xena2544-2G/Logs/xena2544.log'.format(
- user_home)
+ user_home)
# make the folder and log file if they doesn't exist
if not os.path.exists(self._log_path):
@@ -80,18 +78,6 @@ class Xena(ITrafficGenerator):
# empty the file contents
open(self._log_path, 'w').close()
-
- @property
- def traffic_defaults(self):
- """Default traffic values.
-
- These can be expected to be constant across traffic generators,
- so no setter is provided. Changes to the structure or contents
- will likely break traffic generator implementations or tests
- respectively.
- """
- return self._traffic_defaults
-
@staticmethod
def _create_throughput_result(root):
"""
@@ -703,4 +689,3 @@ class Xena(ITrafficGenerator):
if __name__ == "__main__":
pass
-