[Avocado-devel] Simple yaml_to_mux example
Alan Martinovic
alan.martinovic at senic.com
Mon Mar 4 16:22:02 UTC 2019
Hey,
I found the docs a bit to technical to soon.
Am trying to migrate to use a yaml instead of "avocado run -p"
in my tests but got overwhelmed by the complexity.
Just sharing the examples and findings while in the process of
migrating.
I'll be using the sleeptest.py.
```
#sleeptest.py
import time
from avocado import Test
class SleepTest(Test):
def test(self):
sleep_length = self.params.get('duration')
self.log.debug("Sleeping for %.2f seconds", sleep_length)
time.sleep(sleep_length)
```
I want to get the "duration" parameter passed from an external file,
so I'll generate a simple yaml file because it seems that the plugin
yaml_to_mux takes yamls. Am using the "yaml_to_mux" because it
seems the simplest.
```
# variant.yaml
duration: 10
```
The yaml-to-mux needs to be installed first otherwise avocado gives errors.
```
pip3 install avocado-framework-plugin-varianter-yaml-to-mux
```
Running the tests takes the "duration: 3" from the yaml and passes it
into the test execution.
```
$ avocado run sleeptest.py --mux-yaml variant.yaml
JOB ID : 4ec5259cd7c69a7cc3a7c0ef3d02984883eb7f5b
JOB LOG :
/home/user/avocado/job-results/job-2019-03-04T17.18-4ec5259/job.log
(1/1) sleeptest.py:SleepTest.test;run-7e0b: PASS (3.03 s)
RESULTS : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 |
CANCEL 0 JOB TIME : 3.18 s
```
The only thing different is this chunk ";run-7e0b:" added to the test.
Don't know enough atm to say what than means.
Be Well,
Alan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/avocado-devel/attachments/20190304/6272966f/attachment.htm>
More information about the Avocado-devel
mailing list