[Avocado-devel] Avocado 101 questions

Lukáš Doktor ldoktor at redhat.com
Wed Feb 13 16:57:17 UTC 2019


Dne 13. 02. 19 v 5:41 Fajun Chen napsal(a):
> Hi Lukas,
> 
> Thanks for the feedback. Our focus at this point is on proof-of-concept to identify what are the things Avocado can and can't do. Will come back later on the proper implementation of specific features.
> 

You're welcome and thanks for some of the good suggestions.

> Based on early discussions, the sequence capability provided by yaml loader is still very limited. Is there any way to call Avocado tests from Python code directly so we can have full control over the test sequence?
> 

Well the only real limitation is dynamic number of jobs (which I'm personally solving by generating parts of the `yaml` file ad-hoc). If you have a semi-fixed set of tests you can hierarchically organize them and use aliases https://pyyaml.org/wiki/PyYAMLDocumentation (the `*` and `&` chars) and `!include` tags to include snippets from other places. In the end you can use `--mux-filter-only` and `--mux-filter-out`.

Anyway we don't currently support the direct execution, but, especially if you pick an LTS release, it is possible to re-write the `avocado.core.runner`. It is even possible to do that via plugin system, see `optional_plugins/runner_remote/avocado_runner_remote` for details, but there might be caveats (incorrect number of tests in results, ...) and the API is internal, therefor it can change any-time (although unlikely withing LTS release, so 1.5 year should work...). (btw I had proof-of-concept implementation to support simultaneous test execution using set of workers, the number of changes was fairly small).

This should change when we find the time and resources to finish the Job API which is about this. To polish and stabilize the test-execution API in order to guarantee the stability and let people to write free-form jobs with dynamic amount of tests or programmable test dependencies. Anyway definitely not next-LTS material (which should be released next sprint).

Regards,
Lukáš

> Thanks,
> Fajun
> 
> 
> 
> On Fri, Feb 8, 2019 at 9:09 AM Lukáš Doktor <ldoktor at redhat.com <mailto:ldoktor at redhat.com>> wrote:
> 
>     Dne 06. 02. 19 v 7:22 Fajun Chen napsal(a):
>     > Hi Lukas,
>     >
>     > As an experiment, I made the following changes to avocado/core/runner.py:
>     > @@ -319,7 +319,7 @@
>     >          # be able to read from the tty, and would hang. Let's replace
>     >          # STDIN fd (0), with the same fd previously set by
>     >          # `multiprocessing.Process()`
>     > -        os.dup2(sys.stdin.fileno(), 0)
>     > +        # os.dup2(sys.stdin.fileno(), 0)
>     >
>     >          instance = loader.load_test(test_factory)
>     >          if instance.runner_queue is None:
>     > @@ -349,7 +349,10 @@
>     >                          TEST_LOG.info('  %s: %s', source, location)
>     >                  TEST_LOG.info('')
>     >          try:
>     > +            sys.stdin = open(0)
>     >              instance.run_avocado()
>     > +            sys.stdin.close()
>     > +            sys.stdin = open(os.devnull)
>     >          finally:
>     >              try:
>     >                  state = instance.get_state()
>     >
>     > I can interact with the test manually with the change. Understood the risk
>     > of keeping stdin fd open, but will it be manageable if our tests don't read
>     > from tty unless it's warranted?
>     >
>     > Thanks,
>     > Fajun
> 
>     Hello Fajun,
> 
>     sure, this will work for now (although failures are not handled), anyway if you decide to use Avocado I'd suggest the RFC or at least to open a discussion to have a proper implementation. I can imagine something like:
> 
>     ```
>     avocado run interactive.py --enable-stdin
>     JOB ID     : 8e9a0a9011d3e4b31d0fee5c2f727e32cf08ec7a
>     JOB LOG    : /home/medic/avocado/job-results/job-2019-02-08T17.05-8e9a0a9/job.log
>      (1/1) interactive.py:InteractiveTest.test:
>     Waiting on stdin on localhost:12345 \
>     PASS (75.75 s)
>     RESULTS    : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
>     JOB TIME   : 75.88 s
>     JOB HTML   : /home/medic/avocado/job-results/job-2019-02-08T17.05-8e9a0a9/results.html
>     ```
> 
>     (or even to use STDIN directly, but as one would perhaps like to see the stdout as well I think it'd be better to use socket and pipe in/out/err there...)
> 
>     Regards,
>     Lukáš
> 


-------------- 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/20190213/60e76326/attachment.sig>


More information about the Avocado-devel mailing list