From: Ondrej Lichtner olichtne@redhat.com
Changes in v2: * added 4th patch that fixes #175 * Fixed float and int conversion in patch 3/4 in the Netperf module, thanks to jtluka for noticing
Ondrej Lichtner (4): NmConfigDevice: don't crash when deactivating an inactive connection NetTest{Slave, Controller}: add is_installed tcpdump check Netperf: fix confidence parsing when result is 0 NetConfigDevice: skip undefined ovs internal port options
lnst/Controller/NetTestController.py | 11 +++++++++-- lnst/Slave/NetConfigDevice.py | 9 +++++---- lnst/Slave/NetTestSlave.py | 4 ++++ lnst/Slave/NmConfigDevice.py | 10 +++++++++- test_modules/Netperf.py | 13 +++++++++---- 5 files changed, 36 insertions(+), 11 deletions(-)
From: Ondrej Lichtner olichtne@redhat.com
If the NM connection was deactivated during test execution and never reactivated, the deconfiguration of the Slave failed due to an unhandled exception. This left the slave in an inconsistent state and failed the recipe execution.
This commit fixes that catching the related exception and ignoring it.
Fixes #145.
Signed-off-by: Ondrej Lichtner olichtne@redhat.com --- lnst/Slave/NmConfigDevice.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/lnst/Slave/NmConfigDevice.py b/lnst/Slave/NmConfigDevice.py index cbd3420..a9e0c1f 100644 --- a/lnst/Slave/NmConfigDevice.py +++ b/lnst/Slave/NmConfigDevice.py @@ -17,6 +17,7 @@ import dbus import uuid import socket, struct import time +from dbus.exceptions import DBusException from lnst.Common.ExecCmd import exec_cmd from lnst.Slave.NetConfigCommon import get_slaves, get_option, get_slave_option, parse_netem from lnst.Common.NetUtils import scan_netdevs @@ -291,7 +292,14 @@ class NmConfigDeviceGeneric(object): % config["name"]) logging.debug("Active connection object path: %s" % self._acon_obj_path) - self._nm_if.DeactivateConnection(self._acon_obj_path) + try: + self._nm_if.DeactivateConnection(self._acon_obj_path) + except DBusException as e: + if e.get_dbus_name() == "org.freedesktop.NetworkManager."\ + "ConnectionNotActive": + pass + else: + raise e self._acon_obj_path = None
def nm_enslave(self, slave_type, master_uuid, slave_conf):
From: Ondrej Lichtner olichtne@redhat.com
When the --packet-capture argument was specified and tcpdump wasn't installed on one of the machines LNST would fail and report a very nondescriptive exception.
This commit adds a is_installed check to the slave method "start_packet_capture" and the generated exception is then handled on the Controller, reporting a more useful error message.
Fixes #161.
Signed-off-by: Ondrej Lichtner olichtne@redhat.com --- lnst/Controller/NetTestController.py | 11 +++++++++-- lnst/Slave/NetTestSlave.py | 4 ++++ 2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/lnst/Controller/NetTestController.py b/lnst/Controller/NetTestController.py index 889dfa7..791dd95 100644 --- a/lnst/Controller/NetTestController.py +++ b/lnst/Controller/NetTestController.py @@ -651,8 +651,15 @@ class NetTestController: self._cleanup_slaves() raise
- if self._packet_capture: - self._start_packet_capture() + try: + if self._packet_capture: + self._start_packet_capture() + except Exception as exc: + logging.error("Couldn't start packet capture.") + logging.error(str(exc)) + self._cleanup_slaves() + return {"passed": False, + "err_msg": str(exc)}
err = None try: diff --git a/lnst/Slave/NetTestSlave.py b/lnst/Slave/NetTestSlave.py index 8d8fada..b18f47d 100644 --- a/lnst/Slave/NetTestSlave.py +++ b/lnst/Slave/NetTestSlave.py @@ -31,6 +31,7 @@ from lnst.Common.NetTestCommand import NetTestCommandContext from lnst.Common.NetTestCommand import NetTestCommand from lnst.Common.NetTestCommand import DEFAULT_TIMEOUT from lnst.Common.Utils import check_process_running +from lnst.Common.Utils import is_installed from lnst.Common.ConnectionHandler import send_data from lnst.Common.ConnectionHandler import ConnectionHandler from lnst.Common.Config import lnst_config @@ -359,6 +360,9 @@ class SlaveMethods: return True
def start_packet_capture(self, filt): + if not is_installed("tcpdump"): + raise Exception("Can't start packet capture, tcpdump not available") + files = {} for if_id, dev in self._if_manager.get_mapped_devices().iteritems(): if dev.get_netns() != None:
From: Ondrej Lichtner olichtne@redhat.com
When the measured netperf result is 0, the confidence is reported as "-nan" which resulted in tracebacks when parsing the value with a regex for numbers.
This commit fixes that by checking if the regex passed and returning 0 in cases when the regex doesn't fit the string.
Fixes #170
Signed-off-by: Ondrej Lichtner olichtne@redhat.com --- test_modules/Netperf.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/test_modules/Netperf.py b/test_modules/Netperf.py index d09bdfc..6950bb8 100644 --- a/test_modules/Netperf.py +++ b/test_modules/Netperf.py @@ -235,12 +235,17 @@ class Netperf(TestGeneric): def _parse_confidence_omni(self, output): pattern_throughput_confid = "THROUGHPUT_CONFID=([-]?\d+.\d+)" pattern_confidence_level = "CONFIDENCE_LEVEL=(\d+)" - throughput_confid = float(re.search(pattern_throughput_confid, output).group(1)) - confidence_level = int(re.search(pattern_confidence_level, output).group(1))
- real_confidence = (confidence_level, throughput_confid/2) + throughput_confid = re.search(pattern_throughput_confid, output) + confidence_level = re.search(pattern_confidence_level, output)
- return real_confidence + if throughput_confid is not None and confidence_level is not None: + throughput_confid = float(throughput_confid.group(1)) + confidence_level = int(confidence_level.group(1)) + real_confidence = (confidence_level, throughput_confid/2) + return real_confidence + else: + return (0, 0.0)
def _parse_confidence_non_omni(self, output): normal_pattern = r'+/-(\d+.\d*)% @ (\d+)% conf.'
From: Ondrej Lichtner olichtne@redhat.com
When there were no options specified for an ovs internal port, the slave configuration would fail, with an exception, trying to access a nonexistant dictionary key. This could be fixe both on the controller side by sending an empty list of options from the XML parser or on the slave by checking if the key is defined. However, since we're soon going to move to pure python recipes I decided to fix it just on the slave since it's sufficient and the problem won't reappear after the Python recipes switch.
Fixes #175.
Signed-off-by: Ondrej Lichtner olichtne@redhat.com --- lnst/Slave/NetConfigDevice.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/lnst/Slave/NetConfigDevice.py b/lnst/Slave/NetConfigDevice.py index a0fa0e1..89d471e 100644 --- a/lnst/Slave/NetConfigDevice.py +++ b/lnst/Slave/NetConfigDevice.py @@ -518,11 +518,12 @@ class NetConfigDeviceOvsBridge(NetConfigDeviceGeneric): i["name"] = self._if_manager.assign_name_generic(prefix="int")
options = "" - for opt in i["options"]: - options += " %s=%s" % (opt["name"], opt["value"]) + if "options" in i: + for opt in i["options"]: + options += " %s=%s" % (opt["name"], opt["value"])
- if opt["name"] == "name": - i["name"] = opt["value"] + if opt["name"] == "name": + i["name"] = opt["value"]
exec_cmd("ovs-vsctl add-port %s %s -- set Interface %s "\ "type=internal %s" % (br_name, i["name"],
Tue, Jul 26, 2016 at 12:47:38PM CEST, olichtne@redhat.com wrote:
From: Ondrej Lichtner olichtne@redhat.com
Changes in v2:
- added 4th patch that fixes #175
- Fixed float and int conversion in patch 3/4 in the Netperf module, thanks to
jtluka for noticing
Ondrej Lichtner (4): NmConfigDevice: don't crash when deactivating an inactive connection NetTest{Slave, Controller}: add is_installed tcpdump check Netperf: fix confidence parsing when result is 0 NetConfigDevice: skip undefined ovs internal port options
lnst/Controller/NetTestController.py | 11 +++++++++-- lnst/Slave/NetConfigDevice.py | 9 +++++---- lnst/Slave/NetTestSlave.py | 4 ++++ lnst/Slave/NmConfigDevice.py | 10 +++++++++- test_modules/Netperf.py | 13 +++++++++---- 5 files changed, 36 insertions(+), 11 deletions(-)
-- 2.9.0 _______________________________________________ LNST-developers mailing list lnst-developers@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/lnst-developers@lists.fedorahoste...
Ack to series.
Acked-by: Jan Tluka jtluka@redhat.com
lnst-developers@lists.fedorahosted.org