[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lnst-developers
Subject:    [PATCH-next v2 03/18] lnst.Recipes.ENRT.BaseEnrtRecipe: add config description generators
From:       olichtne () redhat ! com
Date:       2019-06-13 11:50:16
Message-ID: 20190613115031.27335-4-olichtne () redhat ! com
[Download RAW message or body]

From: Ondrej Lichtner <olichtne@redhat.com>

Both test wide configuration and sub configurations now generate
descriptions as a separate recipe result, using overrideable methods to
generate the descriptions with multiple lines.

The idea is for each subclass to add additional information based on
what configuration was done.

Signed-off-by: Ondrej Lichtner <olichtne@redhat.com>
---
 lnst/Recipes/ENRT/BaseEnrtRecipe.py | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/lnst/Recipes/ENRT/BaseEnrtRecipe.py b/lnst/Recipes/ENRT/BaseEnrtRecipe.py
index 66f563d..3b561ae 100644
--- a/lnst/Recipes/ENRT/BaseEnrtRecipe.py
+++ b/lnst/Recipes/ENRT/BaseEnrtRecipe.py
@@ -1,4 +1,5 @@
 import re
+import pprint
 from contextlib import contextmanager
 
 from lnst.Common.LnstError import LnstError
@@ -119,6 +120,7 @@ def test(self):
     @contextmanager
     def _test_wide_context(self):
         config = self.test_wide_configuration()
+        self.describe_test_wide_configuration(config)
         try:
             yield config
         finally:
@@ -130,9 +132,23 @@ def test_wide_configuration(self):
     def test_wide_deconfiguration(self, main_config):
         raise NotImplementedError("Method must be defined by a child class.")
 
+    def describe_test_wide_configuration(self, config):
+        description = self.generate_test_wide_description(config)
+        self.add_result(True, "Summary of used Recipe parameters:\n{}".format(
+                        pprint.pformat(self.params._to_dict())))
+        self.add_result(True, "\n".join(description))
+
+    def generate_test_wide_description(self, config):
+        return [
+            "Testwide configuration for recipe {} description:".format(
+                self.__class__.__name__
+            )
+        ]
+
     @contextmanager
     def _sub_context(self, main_config, sub_config):
         self.apply_sub_configuration(main_config, sub_config)
+        self.describe_sub_configuration(sub_config)
         try:
             yield (main_config, sub_config)
         finally:
@@ -188,6 +204,13 @@ def remove_sub_configuration(self, main_config, sub_config):
         server_netns.run("ethtool -K {} {}".format(server_nic.name,
                                                    ethtool_offload_string))
 
+    def describe_sub_configuration(self, config):
+        description = self.generate_sub_configuration_description(config)
+        self.add_result(True, "\n".join(description))
+
+    def generate_sub_configuration_description(self, config):
+        return ["Sub configuration description:"]
+
     def generate_ping_configurations(self, main_config, sub_config):
         client_nic = main_config.endpoint1
         server_nic = main_config.endpoint2
-- 
2.22.0
_______________________________________________
LNST-developers mailing list -- lnst-developers@lists.fedorahosted.org
To unsubscribe send an email to lnst-developers-leave@lists.fedorahosted.org
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedorahosted.org/archives/list/lnst-developers@lists.fedorahosted.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic