On Mon, Mar 04, 2019 at 05:22:02PM +0100, Alan Martinovic wrote: > Hey, > I found the docs a bit to technical to soon.
Hi Alan, Yes, it's hard to come up with the right balance of easy of use and details, but I generally agree with you, the docs could offer a better learning experience. > Am trying to migrate to use a yaml instead of "avocado run -p" > in my tests but got overwhelmed by the complexity. > I feel your pain. > 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. > Basically, that is part of a "Test ID": https://avocado-framework.readthedocs.io/en/69.0/ReferenceGuide.html#test-id And it includes a "Variant ID": https://avocado-framework.readthedocs.io/en/69.0/ReferenceGuide.html#variant-ids BTW, if you're interested in just passing parameters, but reading them from a file, maybe you can take a look at the CIT varianter. It provides a simpler configuration syntax: https://avocado-framework.readthedocs.io/en/69.0/optional_plugins/varianter_cit.html https://github.com/avocado-framework/avocado/blob/69lts/examples/varianter_cit/params.ini > Be Well, > Alan Regards, - Cleber.