Thu, Jun 05, 2014 at 01:50:31PM CEST, jpirko(a)redhat.com wrote:
Tue, Jun 03, 2014 at 06:03:32PM CEST, jtluka(a)redhat.com wrote:
>We have currently two test modules that have dependency on a test_tool,
>TCPConnection and Multicast which are wrappers around tcp_conn and
>multicast test tools.
>
>Reduced synchronization feature introduced a dependency bug. Since the
>test module used in an lnst recipe does not have any information about
>required test tool such tool will not be synchronized to lnst slave and
>will end with an Exception like this:
>
>Exception: CommandException: Tools 'tcp_conn' not found
>
>The patch is introducing the required_tools variable that has to be
>specified in a test module source file that will use such test tool
>using exec_from() method.
>
>The variable contains a list of strings describing dependant test tools.
>
><example>
>required_tools = ["tcp_conn"]
>
>class TCPConnection(TestGeneric):
> def run(self):
> self.exec_from("tcp_conn", "./tcp_listen -x -y -z")
Hmm. Wouldn't it be better to semi-parse this code and compose
"required_tools" automatically?
Yeah, this way we won't have to modify the current test modules. On the
other hand parsing is more sensitive to errors. Command could be split
to more lines, e.g.
self.exec_from(\
"tcp_conn"...
I know this is an extreme situation but it can happen. I'll explore the
parsing option further and I'll let you know soon.
></example>
>
>Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
>---
> lnst/Controller/NetTestController.py | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
>diff --git a/lnst/Controller/NetTestController.py
b/lnst/Controller/NetTestController.py
>index 400cd19..fdfe470 100644
>--- a/lnst/Controller/NetTestController.py
>+++ b/lnst/Controller/NetTestController.py
>@@ -246,6 +246,21 @@ class NetTestController:
> msg = "Module '%s' not found on the
controller"\
> % mod
> raise RecipeError(msg, cmd)
>+
>+ # check deps of test module
>+ mod_path =
self._resource_table['module'][mod]['path']
>+ mod_src = imp.load_source(mod, mod_path)
>+ try:
>+ req_tools = getattr(mod_src, "required_tools")
>+ except AttributeError:
>+ # test module does not have any dependencies
>+ req_tools = []
>+ except:
>+ raise
>+
>+ for tool in req_tools:
>+ sync_table['tools'][tool] =
res_table['tools'][tool]
>+
> if cmd['type'] == 'exec' and 'from' in
cmd:
> tool = cmd['from']
> if tool in res_table['tools']:
>--
>1.8.1.4
>
>_______________________________________________
>LNST-developers mailing list
>LNST-developers(a)lists.fedorahosted.org
>https://lists.fedorahosted.org/mailman/listinfo/lnst-developers