summaryrefslogtreecommitdiffstats
path: root/tools
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 /tools
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 'tools')
-rw-r--r--tools/functions.py42
-rwxr-xr-xtools/pkt_gen/ixnet/ixnet.py11
-rw-r--r--tools/teststepstools.py8
3 files changed, 53 insertions, 8 deletions
diff --git a/tools/functions.py b/tools/functions.py
index e8bc31da..9292867d 100644
--- a/tools/functions.py
+++ b/tools/functions.py
@@ -19,6 +19,7 @@ import os
import logging
import glob
import shutil
+import re
from conf import settings as S
MAX_L4_FLOWS = 65536
@@ -171,3 +172,44 @@ def check_traffic(traffic):
traffic['multistream'] = MAX_L4_FLOWS
return traffic
+
+def filter_output(output, regex):
+ """Filter output by defined regex. Output can be either string, list or tuple.
+ Every string is split into list line by line. After that regex is applied
+ to filter only matching lines, which are returned back.
+
+ :returns: list of matching records
+ """
+ result = []
+ if isinstance(output, str):
+ for line in output.split('\n'):
+ result += re.findall(regex, line)
+ return result
+ elif isinstance(output, list) or isinstance(output, tuple):
+ tmp_res = []
+ for item in output:
+ tmp_res.append(filter_output(item, regex))
+ return tmp_res
+ else:
+ raise RuntimeError('Only strings and lists are supported by filter_output(), '
+ 'but output has type {}'.format(type(output)))
+
+def format_description(desc, length):
+ """ Split description into multiple lines based on given line length.
+
+ :param desc: A string with testcase description
+ :param length: A maximum line length
+ """
+ # split description to multiple lines
+ words = desc.split()
+ output = []
+ line = ''
+ for word in words:
+ if len(line) + len(word) < length:
+ line += '{} '.format(word)
+ else:
+ output.append(line.strip())
+ line = '{} '.format(word)
+
+ output.append(line.strip())
+ return output
diff --git a/tools/pkt_gen/ixnet/ixnet.py b/tools/pkt_gen/ixnet/ixnet.py
index 972fa331..b8fb1879 100755
--- a/tools/pkt_gen/ixnet/ixnet.py
+++ b/tools/pkt_gen/ixnet/ixnet.py
@@ -153,9 +153,8 @@ class IxNet(trafficgen.ITrafficGenerator):
"""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()
+ self._script = None
self._cfg = None
self._logger = logging.getLogger(__name__)
self._params = None
@@ -177,6 +176,8 @@ class IxNet(trafficgen.ITrafficGenerator):
def configure(self):
"""Configure system for IxNetwork.
"""
+ self._script = os.path.join(settings.getValue('TRAFFICGEN_IXIA_3RD_PARTY'),
+ settings.getValue('TRAFFICGEN_IXNET_TCL_SCRIPT'))
self._cfg = {
'lib_path': settings.getValue('TRAFFICGEN_IXNET_LIB_PATH'),
# IxNetwork machine configuration
@@ -225,6 +226,8 @@ class IxNet(trafficgen.ITrafficGenerator):
'multipleStreams': traffic['multistream'],
'streamType': traffic['stream_type'],
'rfc2544TestType': 'throughput',
+ 'flowControl': "True" if traffic['flow_control'] else "False",
+ 'learningFrames': "True" if traffic['learning_frames'] else "False",
}
self._params['traffic'] = self.traffic_defaults.copy()
@@ -280,6 +283,8 @@ class IxNet(trafficgen.ITrafficGenerator):
'multipleStreams': traffic['multistream'],
'streamType': traffic['stream_type'],
'rfc2544TestType': 'throughput',
+ 'flowControl': "True" if traffic['flow_control'] else "False",
+ 'learningFrames': "True" if traffic['learning_frames'] else "False",
}
self._params['traffic'] = self.traffic_defaults.copy()
@@ -418,6 +423,8 @@ class IxNet(trafficgen.ITrafficGenerator):
'multipleStreams': traffic['multistream'],
'streamType': traffic['stream_type'],
'rfc2544TestType': 'back2back',
+ 'flowControl': "True" if traffic['flow_control'] else "False",
+ 'learningFrames': "True" if traffic['learning_frames'] else "False",
}
self._params['traffic'] = self.traffic_defaults.copy()
diff --git a/tools/teststepstools.py b/tools/teststepstools.py
index 5d551c68..639e3437 100644
--- a/tools/teststepstools.py
+++ b/tools/teststepstools.py
@@ -15,10 +15,10 @@
"""Various helper functions for step driven testcases
"""
-import re
import logging
import subprocess
import locale
+from tools.functions import filter_output
_LOGGER = logging.getLogger(__name__)
@@ -93,11 +93,7 @@ class TestStepsTools(object):
output = output.decode(locale.getdefaultlocale()[1])
if regex:
- for line in output.split('\n'):
- result = re.findall(regex, line)
- if result:
- return result
- return []
+ return filter_output(output, regex)
return output