[Avocado-devel] Job API and Avocado-VT

Cleber Rosa crosa at redhat.com
Fri Apr 27 02:03:42 UTC 2018


Hi All,

I'd like to share an experiment I was doing with the "Job API".
Basically, the Job is not a public API (yet), while "avocado.Test" is.
Because of that, some solutions to allow the specification of "test
suites" have been created, such as the "YAML loader" plugin.

But, it's our understanding (and I include Lukas here based on many
conversations), that a more direct API can actually be easier to use.
In hopes to gather user feedback and and kick back the development of
the Job API, this is one functional example:

--- START


#!/usr/bin/env python

import sys

from avocado.core import output
from avocado.core.job import Job
from avocado_vt.test import VirtTest


def virt_test(name, params):
    return (VirtTest, {'vt_params': params,
                       'name': name})

class MyJob(Job):
    def __init__(self):
        super(MyJob, self).__init__()
        output.reconfigure(self.args)

    def create_test_suite(self):
        self.test_suite = [
            virt_test('skip', {'provider': 'io-github-autotest-qemu',
                               'type': 'skip'}),
            virt_test('fail', {'provider': 'io-github-autotest-qemu',
                               'type': 'fail'}),
        ]
        self.result.tests_total = len(self.test_suite)


if __name__ == '__main__':
    with MyJob() as job:
        exit_status = job.run()
    sys.exit(exit_status)


--- END

Running it (chmod +x <file>, ./<file>) results in:

JOB ID     : 429e1e0957c50654d7fee646f86cbc69a00d5258
JOB LOG    :
/home/cleber/avocado/job-results/job-2018-04-26T21.57-429e1e0/job.log
 (1/2) skip: CANCEL (0.57 s)
 (2/2) fail: FAIL (0.59 s)
RESULTS    : PASS 0 | ERROR 0 | FAIL 1 | SKIP 0 | WARN 0 | INTERRUPT 0 |
CANCEL 1

So, the tests chosen here need a minimal set of parameters, but are
first class "Avocado-VT" tests.  So, it would be possible to run any
other test, given the right parameters are passed.

We're aware of people running jobs containing INSTRUMENTED, SIMPLE and
Avocado-VT tests, and we'd like to hear how this looks to you.

Thanks!

-- 
Cleber Rosa
[ Sr Software Engineer - Virtualization Team - Red Hat ]
[ Avocado Test Framework - avocado-framework.github.io ]
[  7ABB 96EB 8B46 B94D 5E0F  E9BB 657E 8D33 A5F2 09F3  ]




More information about the Avocado-devel mailing list