Repository: avocado-framework/avocado

Issue:
Unable to read values from yaml file in Avocado 39.0
I have a script which is working perfectly fine in Avocado 38.0 and I see values reflected from the yaml, but where as the same script on Avocado 39.0 is failing to take the values from yaml file.



Discussion:
Hello @vrbagalkote, can you please provide more details? What values are you talking about? Is your script part of a test, or does it parses the results, or is it some kind of a plugin to integrate avocado with your tools?

Hi @ldoktor , My script is a test case. And it gets input values from yaml file(disk name, raid level). Please refer below patch.

https://github.com/avocado-framework/avocado-misc-tests/pull/135

@ldoktor indeed multiplexer is not working after b6cbe7340ae16543665603a8bab8aa49d68bf9e2.


Resolving patch:
diff --git a/avocado/core/multiplexer.py b/avocado/core/multiplexer.py
--- a/avocado/core/multiplexer.py
+++ b/avocado/core/multiplexer.py
@@ -412,15 +412,22 @@ def get_number_of_tests(self, test_suite):
         else:
             return len(test_suite)
 
-    def itertests(self):
+    def itertests(self, template):
         """
-        Yield variant-id and test params
+        Processes the template and yields test definition with proper params
         """
         if self.variants:  # Copy template and modify it's params
             i = None
             for i, variant in enumerate(self.variants, 1):
-                yield i if self._has_multiple_variants else None, variant
+                test_factory = [template[0], template[1].copy()]
+                if "params" in test_factory[1]:
+                    msg = ("Unable to multiplex test %s, params are already "
+                           "present in test factory: %s"
+                           % (test_factory[0], test_factory[1]))
+                    raise ValueError(msg)
+                test_factory[1]['params'] = (variant, self._mux_path)
+                yield test_factory, i if self._has_multiple_variants else None
             if i is None:   # No variants, use template
-                yield None, None
+                yield template, None
         else:   # No variants, use template
-            yield None, None
+            yield template, None
diff --git a/avocado/core/runner.py b/avocado/core/runner.py
--- a/avocado/core/runner.py
+++ b/avocado/core/runner.py
@@ -454,29 +454,6 @@ def sigtstp_handler(signum, frame):     # pylint: disable=W0613
             return False
         return True
 
-    @staticmethod
-    def _iter_variants(template, mux):
-        """
-        Iterate through variants and set the params/variants accordingly.
-
-        :param template: test template
-        :param mux: the Mux object containing the variants
-        :return: Yields tuple(test_factory including params, variant id)
-        :raises ValueError: When variant and template declare params.
-        """
-        for variant, params in mux.itertests():
-            if params:
-                if "params" in template[1]:
-                    msg = ("Unable to multiplex test %s, params are already "
-                           "present in test factory: %s"
-                           % (template[0], template[1]))
-                    raise ValueError(msg)
-                factory = [template[0], template[1].copy()]
-                factory[1]["params"] = params
-            else:
-                factory = template
-            yield factory, variant
-
     def run_suite(self, test_suite, mux, timeout=0, replay_map=None,
                   test_result_total=0):
         """
@@ -506,8 +483,7 @@ def run_suite(self, test_suite, mux, timeout=0, replay_map=None,
                 test_template[1]['base_logdir'] = self.job.logdir
                 test_template[1]['job'] = self.job
                 break_loop = False
-                for test_factory, variant in self._iter_variants(test_template,
-                                                                 mux):
+                for test_factory, variant in mux.itertests(test_template):
                     index += 1
                     test_parameters = test_factory[1]
                     name = test_parameters.get("name")


Test patch: