From: Ondrej Lichtner <olichtne(a)redhat.com>
This commit extends the xml format used by the result serializer to
include command sequences of the original recipe. I added this because
we use a lot of recipes with multiple command sequences and it can get
pretty confusing trying to figure out which commands are in the same
command sequence, when you're not directly looking at the recipe.
I also added a 'result' attribute to the <recipe> node, that contains
the cumulative result of the recipe. This is a little bit redundant
because you can deduce it from the results of individual commands. But
it's more convenient like this.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Controller/NetTestController.py | 1 +
lnst/Controller/NetTestResultSerializer.py | 11 ++++++++++-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/lnst/Controller/NetTestController.py b/lnst/Controller/NetTestController.py
index a43c299..3cf3f91 100644
--- a/lnst/Controller/NetTestController.py
+++ b/lnst/Controller/NetTestController.py
@@ -285,6 +285,7 @@ class NetTestController:
for sequence in self._recipe["sequences"]:
try:
+ self._res_serializer.add_command_sequence()
res = self._run_command_sequence(sequence)
except CommandException as exc:
logging.debug(exc)
diff --git a/lnst/Controller/NetTestResultSerializer.py
b/lnst/Controller/NetTestResultSerializer.py
index 499a076..25ba13f 100644
--- a/lnst/Controller/NetTestResultSerializer.py
+++ b/lnst/Controller/NetTestResultSerializer.py
@@ -35,6 +35,7 @@ class NetTestResultSerializer:
self._dom = impl.createDocument(None, "results", None)
self._top_el = self._dom.documentElement
self._cur_recipe_el = None
+ self._cur_cmd_seq_el = None
def __str__(self):
return self._dom.toprettyxml()
@@ -42,12 +43,19 @@ class NetTestResultSerializer:
def add_recipe(self, name):
recipe_el = self._dom.createElement("recipe")
recipe_el.setAttribute("name", name)
+ recipe_el.setAttribute("result", "PASS")
self._top_el.appendChild(recipe_el)
self._cur_recipe_el = recipe_el
+ self._cur_cmd_seq_el = None
+
+ def add_command_sequence(self):
+ cmd_seq_el = self._dom.createElement("command_sequence")
+ self._cur_recipe_el.appendChild(cmd_seq_el)
+ self._cur_cmd_seq_el = cmd_seq_el
def add_cmd_result(self, command, cmd_res):
command_el = self._dom.createElement("command")
- self._cur_recipe_el.appendChild(command_el)
+ self._cur_cmd_seq_el.appendChild(command_el)
for key in command:
if key == "options":
@@ -61,6 +69,7 @@ class NetTestResultSerializer:
res = "PASS"
else:
res = "FAIL"
+ self._cur_recipe_el.setAttribute("result", "FAIL")
result_el.setAttribute("result", res)
if "err_msg" in cmd_res:
--
1.8.1.4