From: Ondrej Lichtner <olichtne(a)redhat.com>
If there was an exception raised during command execution, that command
wouldn't have a result assigned. This will be visible in the summary
output as a sequence of commands having passed but the overal recipe
result is FAIL.
This commit fixes that by adding a FAIL result to the command and an
error message to indicate that the command failed because of an
exception.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Controller/NetTestController.py | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/lnst/Controller/NetTestController.py b/lnst/Controller/NetTestController.py
index 3cf3f91..ae2a78a 100644
--- a/lnst/Controller/NetTestController.py
+++ b/lnst/Controller/NetTestController.py
@@ -210,9 +210,15 @@ class NetTestController:
seq_passed = True
for command in sequence["commands"]:
logging.info("Executing command: [%s]", str_command(command))
- cmd_res = self._run_command(command)
- if self._res_serializer:
- self._res_serializer.add_cmd_result(command, cmd_res)
+
+ try:
+ cmd_res = self._run_command(command)
+ except Exception as exc:
+ cmd_res = {"passed": False, "err_msg":
"Exception raised."}
+ raise exc
+ finally:
+ if self._res_serializer:
+ self._res_serializer.add_cmd_result(command, cmd_res)
logging.debug("Result: %s", str(cmd_res))
if "res_data" in cmd_res:
res_data = pformat(cmd_res["res_data"])
--
1.8.1.4