From b1534957e463b5e34957a8d48ce5c6b0552ffbb4 Mon Sep 17 00:00:00 2001 From: Martin Klozik Date: Thu, 31 Aug 2017 15:01:18 +0200 Subject: 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 Reviewed-by: Al Morton Reviewed-by: Christian Trautman Reviewed-by: Sridhar Rao Reviewed-by: Trevor Cooper --- vswitches/ovs.py | 27 +++++++++++++++++++++++++++ vswitches/ovs_dpdk_vhost.py | 2 +- vswitches/vswitch.py | 7 +++++++ 3 files changed, 35 insertions(+), 1 deletion(-) (limited to 'vswitches') diff --git a/vswitches/ovs.py b/vswitches/ovs.py index 7e16c142..76cabb0d 100644 --- a/vswitches/ovs.py +++ b/vswitches/ovs.py @@ -91,6 +91,27 @@ class IVSwitchOvs(IVSwitch, tasks.Process): self._logger.info("Vswitchd...Started.") + def restart(self): + """ Restart ``ovs-vswitchd`` instance. ``ovsdb-server`` is not restarted. + + :raises: pexpect.EOF, pexpect.TIMEOUT + """ + self._logger.info("Restarting vswitchd...") + if os.path.isfile(self._vswitchd_pidfile_path): + self._logger.info('Killing ovs-vswitchd...') + with open(self._vswitchd_pidfile_path, "r") as pidfile: + vswitchd_pid = pidfile.read().strip() + tasks.terminate_task(vswitchd_pid, logger=self._logger) + + try: + tasks.Process.start(self) + self.relinquish() + except (pexpect.EOF, pexpect.TIMEOUT) as exc: + logging.error("Exception during VSwitch start.") + self._kill_ovsdb() + raise exc + self._logger.info("Vswitchd...Started.") + def configure(self): """ Configure vswitchd through ovsdb if needed """ @@ -109,6 +130,7 @@ class IVSwitchOvs(IVSwitch, tasks.Process): """ self._logger.info("Terminating vswitchd...") self.kill() + self._bridges = {} self._logger.info("Vswitchd...Terminated.") def add_switch(self, switch_name, params=None): @@ -488,3 +510,8 @@ class IVSwitchOvs(IVSwitch, tasks.Process): """ bridge = self._bridges[switch_name] return 'stp_enable : true' in ''.join(bridge.bridge_info()) + + def validate_restart(self, dummy_result): + """ Validate restart + """ + return True diff --git a/vswitches/ovs_dpdk_vhost.py b/vswitches/ovs_dpdk_vhost.py index 3b20be35..11b32c88 100644 --- a/vswitches/ovs_dpdk_vhost.py +++ b/vswitches/ovs_dpdk_vhost.py @@ -149,7 +149,7 @@ class OvsDpdkVhost(IVSwitchOvs): nic_type = 'dpdkvhostuserclient' vhost_count = self._get_port_count('type={}'.format(nic_type)) - port_name = 'dpdkvhostuser' + str(vhost_count) + port_name = nic_type + str(vhost_count) params = ['--', 'set', 'Interface', port_name, 'type={}'.format(nic_type)] if not S.getValue('VSWITCH_VHOSTUSER_SERVER_MODE'): params += ['--', 'set', 'Interface', port_name, 'options:vhost-server-path=' diff --git a/vswitches/vswitch.py b/vswitches/vswitch.py index dd69e6d9..efa3a349 100644 --- a/vswitches/vswitch.py +++ b/vswitches/vswitch.py @@ -36,6 +36,13 @@ class IVSwitch(object): """ raise NotImplementedError() + def restart(self): + """Retart the vSwitch + + Restart of vSwitch is required for failover testcases. + """ + raise NotImplementedError() + def stop(self): """Stop the vSwitch -- cgit 1.2.3-korg