[Avocado-devel] Multiplex and avocado-vt

Lucas Meneghel Rodrigues lookkas at gmail.com
Fri Nov 20 14:18:56 UTC 2015


On Fri, Nov 20, 2015 at 11:25 AM Olav Philipp Henschel <
olavph at linux.vnet.ibm.com> wrote:

> I believe the syntax you've given is for an avocado-virt test, which
> inherits from the class VirtTest, right?
> The way I use them, avocado-vt tests don't have a class, they are defined
> just by a "run" method.
>

That's right. However, each run() function is passed a test object, that is
the parent class on which the run() function is injected to. All run
functions are passed this reference, so you can get avocado params by
accessing avocado_params in the test object.


> Based on the code you pointed to, in VirtTest __init__, I've written a
> simple function to get the avocado params:
>
> from avocado.core import multiplexer
> def get_avocado_params(params):
>      avocado_params_raw = params.get('avocado_params', None)
>      if avocado_params_raw is not None:
>          params_list, mux_path = avocado_params_raw[0],
> avocado_params_raw[1]
>      else:
>          params_list, mux_path = [], []
>      return multiplexer.AvocadoParams(params_list, "", "", mux_path, {})
>
> This way, I've been able to use them in an avocado-vt test like this:
>
> avocado_params = get_avocado_params(params)
> param = avocado_params.get("param_name")
>
> If there's a simpler way, please tell me.
>

Based on the above:

def run(test, params, env):
    ....
    test.avocado_params.get("param_name")

If you check avocado.core.plugins.vt, you'll see that I've put a comment
there:

        # Here we turn the data the multiplexer injected into the params and
        # turn it into an AvocadoParams object, that will allow users to
        # access data from it. Example:
        # sleep_length = test.avocado_params.get('sleep_length', default=1)

We call this "Frankenstein mode". The idea is that users can start to
leverage avocado features in this transitional path avocado-vt -> "the
future" (where a POC implementation of "future" is avocado-virt).

I'm eager to move to avocado-virt, it seems much nicer than avocado-vt, but
> we need the unattended_install test, which I believe is not yet supported.
> I might even give a try in porting it eventually.
>

Sure. Just keep in mind that we were figuring out avocado-virt from the
ground up, and there are some gaps. For example, we want to have a
templating system, to avoid too much API code to insert devices, but we're
not quite there with the design yet.


>
> Thank you for helping me with this,
> Olav
>
>
> On 19-11-2015 19:42, Cleber Rosa wrote:
> > Hi Olav,
> >
> > Avocado-vt tests, by default, do not use the parameters from the
> multiplex. By default, is parameters come from the precursor of the
> multiplexer (known as the cartesian config file).
> >
> > But, Avocado actually sends the parameters over, and there's a way to
> actually use them from within avocado-vt tests. The syntax (from within a
> test) is:
> >
> >     sleep_length = self.avocado_params.get('sleep_length', default=1)
> >
> > The parameter 'sleep_length' is a parameter that should come from the
> multiplexer.
> >
> > About Avocado-virt: this is where a more native (and pleasant)
> experience should be found. Unfortunately, it's still far from the same
> level of features and tests as Avocado-vt. But, Avocado-virt should receive
> most of our development energy from now on.
> >
> > If you feel that Avocado-virt better suits your needs, great! Let's work
> together on that!
> >
> > BTW, a few pointers on Avocado-vt + multiplexer:
> >
> >   -
> https://github.com/avocado-framework/avocado-vt/blob/master/avocado/core/plugins/vt.py#L254
> >   -
> https://github.com/avocado-framework/avocado-vt/blob/master/avocado/core/plugins/vt.py#L321
> >
> >
> > Thanks,
> > CR.
> >
> > ----- Original Message -----
> >> From: "Olav Philipp Henschel" <olavph at linux.vnet.ibm.com>
> >> To: avocado-devel at redhat.com
> >> Sent: Thursday, November 19, 2015 4:09:06 PM
> >> Subject: [Avocado-devel] Multiplex and avocado-vt
> >>
> >> Now that I got multiplexing to work, I've tried to use it with
> >> avocado-vt and didn't get the expected results.
> >> It prints the "Multiplex tree representation" and executes the tests
> >> once for each variant, but the tests didn't get the param values.
> >> I've noticed the params in new tests are an attribute of the Test class,
> >> which is not used in avocado-vt.
> >>
> >> Is it even possible to multiplex avocado-vt tests?
> >> If not, what's the current status on avocado-virt? Can we port other
> >> distros as guests already?
> >>
> >> Any information is appreciated,
> >> Olav P. Henschel
> >>
> >> _______________________________________________
> >> Avocado-devel mailing list
> >> Avocado-devel at redhat.com
> >> https://www.redhat.com/mailman/listinfo/avocado-devel
> >>
> > _______________________________________________
> > Avocado-devel mailing list
> > Avocado-devel at redhat.com
> > https://www.redhat.com/mailman/listinfo/avocado-devel
> >
>
> _______________________________________________
> Avocado-devel mailing list
> Avocado-devel at redhat.com
> https://www.redhat.com/mailman/listinfo/avocado-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/avocado-devel/attachments/20151120/52d057cb/attachment.htm>


More information about the Avocado-devel mailing list