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:
Fri, Jul 22, 2016 at 01:09:58PM CEST, olichtne@redhat.com wrote:
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:
Just wondering if moving if-clause out of try-except block would not look better. Besides that ack.
Acked-by: Jan Tluka jtluka@redhat.com
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:
-- 2.9.0 _______________________________________________ LNST-developers mailing list lnst-developers@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/lnst-developers@lists.fedorahoste...
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..746bdac 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 = throughput_confid.group(1) + confidence_level = 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.'
Fri, Jul 22, 2016 at 01:09:59PM CEST, olichtne@redhat.com wrote:
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..746bdac 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 = throughput_confid.group(1)
The original statement had float() conversion. Did you remove it intentionally?
confidence_level = confidence_level.group(1)
Same for int()?
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.'
-- 2.9.0 _______________________________________________ LNST-developers mailing list lnst-developers@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/lnst-developers@lists.fedorahoste...
Fri, Jul 22, 2016 at 01:09:57PM CEST, olichtne@redhat.com wrote:
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(-)
Acked-by: Jan Tluka jtluka@redhat.com
lnst-developers@lists.fedorahosted.org