summaryrefslogtreecommitdiffstats
path: root/vnfs/vnf
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 /vnfs/vnf
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 'vnfs/vnf')
-rw-r--r--vnfs/vnf/vnf.py60
1 files changed, 42 insertions, 18 deletions
diff --git a/vnfs/vnf/vnf.py b/vnfs/vnf/vnf.py
index 759bdd66..5ac2ada3 100644
--- a/vnfs/vnf/vnf.py
+++ b/vnfs/vnf/vnf.py
@@ -17,6 +17,7 @@ Interface for VNF.
"""
import time
+import pexpect
from tools import tasks
class IVnf(tasks.Process):
@@ -40,14 +41,7 @@ class IVnf(tasks.Process):
self._number + 1, self._number)
IVnf._number_vnfs = IVnf._number_vnfs + 1
self._log_prefix = 'vnf_%d_cmd : ' % self._number
-
- def start(self):
- """
- Starts VNF instance.
-
- This is a blocking function
- """
- super(IVnf, self).start()
+ self._login_active = False
def stop(self):
"""
@@ -60,6 +54,18 @@ class IVnf(tasks.Process):
# sporadic reboot of host. (caused by hugepages or DPDK ports)
super(IVnf, self).kill(signal='-9', sleep=10)
+ def login(self, dummy_timeout=120):
+ """
+ Login to GUEST instance.
+
+ This can be used after booting the machine
+
+ :param timeout: Timeout to wait for login to complete.
+
+ :returns: True if login is active
+ """
+ raise NotImplementedError()
+
def execute(self, cmd, delay=0):
"""
execute ``cmd`` with given ``delay``.
@@ -77,6 +83,14 @@ class IVnf(tasks.Process):
:returns: None.
"""
self._logger.debug('%s%s', self._log_prefix, cmd)
+
+ # ensure that output from previous commands is flushed
+ try:
+ while not self._child.expect(r'.+', timeout=0.1):
+ pass
+ except (pexpect.TIMEOUT, pexpect.EOF):
+ pass
+
self._child.sendline(cmd)
time.sleep(delay)
@@ -95,10 +109,10 @@ class IVnf(tasks.Process):
Please note that this value can be floating
point which allows to pass milliseconds.
- :returns: True if result_cmd has been detected before
- timeout has been reached, False otherwise.
+ :returns: output of executed command
"""
self._child.expect(prompt, timeout=timeout)
+ return self._child.before
def execute_and_wait(self, cmd, timeout=30, prompt=''):
"""
@@ -119,27 +133,37 @@ class IVnf(tasks.Process):
``prompt`` passed in __init__
method will be used.
- :returns: True if end of execution has been detected
- before timeout has been reached, False otherwise.
+ :returns: output of executed command
"""
self.execute(cmd)
- self.wait(prompt=prompt, timeout=timeout)
+ return self.wait(prompt=prompt, timeout=timeout)
- # pylint: disable=simplifiable-if-statement
- def validate_start(self, dummy_result):
+ def validate_start(self, dummyresult):
""" Validate call of VNF start()
"""
if self._child and self._child.isalive():
return True
- else:
- return False
+
+ return False
def validate_stop(self, result):
- """ Validate call of fVNF stop()
+ """ Validate call of VNF stop()
"""
return not self.validate_start(result)
@staticmethod
+ def validate_execute_and_wait(result, dummy_cmd, dummy_timeout=30, dummy_prompt=''):
+ """ Validate command execution within VNF
+ """
+ return len(result) > 0
+
+ @staticmethod
+ def validate_login(result):
+ """ Validate successful login into guest
+ """
+ return result
+
+ @staticmethod
def reset_vnf_counter():
"""
Reset internal VNF counters