From: Ondrej Lichtner <olichtne(a)redhat.com>
In case of crash during recipe execution the result would be PASS even
though it should be FAIL. I tried to fix this before but it turns out I
only fixed it when the crash happened in the first command.
This commit should fix it completely, in the next patch I'll add an
error message to the command that caused the crash.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst-ctl | 2 ++
lnst/Controller/NetTestResultSerializer.py | 11 ++++++-----
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/lnst-ctl b/lnst-ctl
index 05f17c1..210c6dc 100755
--- a/lnst-ctl
+++ b/lnst-ctl
@@ -73,6 +73,8 @@ def get_recipe_result(args, file_path, cleanup, res_serializer,
packet_capture,
log_exc_traceback()
logging.error(err)
+ res_serializer.set_recipe_result(res)
+
return ((file_path, res))
def main():
diff --git a/lnst/Controller/NetTestResultSerializer.py
b/lnst/Controller/NetTestResultSerializer.py
index 7e83759..b41ac39 100644
--- a/lnst/Controller/NetTestResultSerializer.py
+++ b/lnst/Controller/NetTestResultSerializer.py
@@ -59,7 +59,12 @@ class NetTestResultSerializer:
self._top_el.appendChild(recipe_el)
self._cur_recipe_el = recipe_el
self._cur_cmd_seq_el = None
- self._first_command = True
+
+ def set_recipe_result(self, result):
+ if result:
+ self._cur_recipe_el.setAttribute("result", "PASS")
+ else:
+ self._cur_recipe_el.setAttribute("result", "FAIL")
def add_command_sequence(self):
cmd_seq_el = self._dom.createElement("command_sequence")
@@ -80,13 +85,9 @@ class NetTestResultSerializer:
if cmd_res["passed"]:
res = "PASS"
- if self._first_command:
- self._cur_recipe_el.setAttribute("result", "PASS")
else:
res = "FAIL"
- self._cur_recipe_el.setAttribute("result", "FAIL")
result_el.setAttribute("result", res)
- self._first_command = False
if "err_msg" in cmd_res:
err_el = self._dom.createElement("error_message")
--
1.8.1.4
Show replies by date
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