avocado icon indicating copy to clipboard operation
avocado copied to clipboard

Runnable variant is not respected in Job API

Open richtja opened this issue 2 years ago • 0 comments

Describe the bug The runnable variant is not respected by avocado when it is set by Job API

Steps to reproduce Job API:

import sys

from avocado.core.job import Job
from avocado.core.suite import TestSuite
from avocado.core.nrunner.runnable import Runnable

config = {}

test = Runnable('avocado-instrumented', 'tmp/test.py:SleepTest.test', variant={'paths': ['/'], 'variant_id': None, 'variant': [['/', [['/', 'sleep_length', '0.01']]]]})
suite = TestSuite('suite_1', tests=[test])

with Job(config, [suite]) as j:
    sys.exit(j.run())

Test:

import time

from avocado import Test


class SleepTest(Test):

    """
    This test sleeps for 1s by default

    :param sleep_length: Sleep duration
    """

    def test(self):
        """
        Sleep for length seconds.
        """
        sleep_length = float(self.params.get('sleep_length', default=1))
        self.log.debug("Sleeping for %.2f seconds", sleep_length)
        time.sleep(sleep_length)

Expected behavior

$ python /tmp/suite.py 
JOB ID     : 57789244d65e558346636ea53901ee64e921178d
JOB LOG    : /home/jarichte/avocado/job-results/job-2022-04-27T11.23-5778924/job.log
 (suite_1-1/1) tmp/test.py:SleepTest.test: STARTED
 (suite_1-1/1) tmp/test.py:SleepTest.test: PASS (0.02 s)
RESULTS    : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB HTML   : /home/jarichte/avocado/job-results/job-2022-04-27T11.23-5778924/results.html
JOB TIME   : 1.30 s

$ grep "Sleeping for" ~/avocado/job-results/latest/test-results/suite_1-1-tmp_test.py_SleepTest.test/debug.log 
[stdlog] 2022-04-27 11:30:25,512 avocado.test DEBUG| Sleeping for 0.01 seconds

Current behavior

$ python /tmp/suite.py 
JOB ID     : 74138ce000d68be9e2343c21bac1d977c5b184d1
JOB LOG    : /home/jarichte/avocado/job-results/job-2022-04-27T11.25-74138ce/job.log
 (suite_1-1/1) tmp/test.py:SleepTest.test: STARTED
 (suite_1-1/1) tmp/test.py:SleepTest.test: PASS (1.01 s)
RESULTS    : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB HTML   : /home/jarichte/avocado/job-results/job-2022-04-27T11.25-74138ce/results.html
JOB TIME   : 2.22 s

$ grep "Sleeping for" ~/avocado/job-results/latest/test-results/suite_1-1-tmp_test.py_SleepTest.test/debug.log 
[stdlog] 2022-04-27 11:25:52,349 avocado.test DEBUG| Sleeping for 1.00 seconds

System information (please complete the following information):

  • OS: LSB Version: :core-4.1-amd64:core-4.1-noarch Distributor ID: Fedora Description: Fedora release 35 (Thirty Five) Release: 35 Codename: ThirtyFive

  • Avocado version: avocado master

  • Avocado installation method: github

richtja avatar Apr 27 '22 09:04 richtja