[Avocado-devel] parametrize tests

Lukáš Doktor ldoktor at redhat.com
Mon Apr 30 14:03:31 UTC 2018


Dne 25.4.2018 v 18:56 Sergey Bronnikov napsal(a):
> Hello!
> 
> I have started to learning avocado and stuck with a problem.
> There are some tests which I want to run in Qemu so I use avocado-vt
> plugin. For all of my tests should use fixed HDD interface and NIC model -
> "nic_model: rtl8139", "drive_format: ahci" and some options should be
> disabled - for example 'smp'. How to do it right in avocado?
> 
> I read chapter "Cartesion config" in documentation, but documentation
> describe only basic artificial examples and doesn't contain best practices.
> 
> Sergey
> 

Hello Sergey,

Avocado-vt is quite a heavy beast, but very powerful, so bear with us and one day you'll be spawning millions of combinations from top of your head.

As for the combinations, Avocado-vt by default creates many different combinations, filtering them out and running (usually) one combination. Based on host hardware it's usually:

* bridge
* default_bios
* no_virtio_rng
* filesystem
* no_9p_export
* smallpages
* no_pci_assignable
* qcow2
* virtio_scsi
* smp2
* virtio_net
* Guest.JeOS.27.x86_64
* Host.Fedora.m27.u0
* Host_arch_x86_64
* i440fx

followed by test (which actually is just another "variant" that specified special keyword "type"). You can change some by arguments (`--vt-machine-type`, `--vt-guest-os`, ...) other by config in `/etc/avocado/conf.d/vt.conf` (eg: `vt.qemu.smp`) and the rest you can tweak directly by `--vt-extra-params $key=$value` (eg: `--vt-extra-params smp=1 extra_params=" -serial tcp:0:4444,server") [1]

Now you said your test is incompatible with "smp", so you just have to add:

```python
    if int(self.params.get('smp')) > 1:
        self.skip("Test is not supported on multi-cpu setup")
```

which will make the test to be canceled (skipped) when executed with multiple cpus. You'll only be able to execute that test by changing the `vt.qemu.smp` config entry, or using `--vt-extra-params smp=1`, which forces Avocado-vt to use single cpu.

The same applies for other filters like required block driver, network card etc. You can find the reference guide for all the special variables here:

    http://avocado-vt.readthedocs.io/en/latest/cartesian/index.html

or simply look in 

    https://github.com/avocado-framework/avocado-vt/tree/master/shared/cfg

(preferably use the files located, after `avocado vt-bootstrap` in `$AVOCADO_DATA/avocado-vt/backends/$BACKEND/cfg`).

Happy hacking,
Lukáš


[1] note the `--vt-extra-params` is a low level Swiss-army tool. It overrides directly the avocado-vt params, not propagating the changes to test name, which can bring some confusion. Anyway from test point of view it works well

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/avocado-devel/attachments/20180430/6bb316ca/attachment.sig>


More information about the Avocado-devel mailing list