Update run_tests.py environment variable names
Change-Id: I5f6ad7369f10df04f02aa96b22ab8236a0e060ef
This commit is contained in:
parent
544fe81e8a
commit
2ac4100069
@ -31,7 +31,6 @@ FROM ${base_image} as base
|
|||||||
|
|
||||||
ENV TOBIKO_DIR=/tobiko
|
ENV TOBIKO_DIR=/tobiko
|
||||||
ENV WHEEL_DIR=/wheel
|
ENV WHEEL_DIR=/wheel
|
||||||
ENV PACKAGES_DIR=/site_packages
|
|
||||||
ENV PYTHON=python${PYTHON_VERSION}
|
ENV PYTHON=python${PYTHON_VERSION}
|
||||||
|
|
||||||
RUN ${INSTALL_PACKAGES} ${PYTHON}
|
RUN ${INSTALL_PACKAGES} ${PYTHON}
|
||||||
@ -85,10 +84,10 @@ FROM source as test
|
|||||||
|
|
||||||
# Run tests variables
|
# Run tests variables
|
||||||
ENV PYTHONWARNINGS=ignore::Warning
|
ENV PYTHONWARNINGS=ignore::Warning
|
||||||
ENV OS_TEST_PATH=${TOBIKO_DIR}/tobiko/tests/unit
|
ENV TOBIKO_REPORT_DIR=/report
|
||||||
ENV TOX_REPORT_DIR=/report
|
ENV TOBIKO_REPORT_NAME=tobiko_results
|
||||||
ENV TOX_REPORT_NAME=tobiko_results
|
|
||||||
ENV TOBIKO_PREVENT_CREATE=false
|
ENV TOBIKO_PREVENT_CREATE=false
|
||||||
|
ENV TOBIKO_TEST_PATH=${TOBIKO_DIR}/tobiko/tests/unit
|
||||||
|
|
||||||
RUN ${INSTALL_PACKAGES} iperf3 iputils nmap-ncat findutils procps
|
RUN ${INSTALL_PACKAGES} iperf3 iputils nmap-ncat findutils procps
|
||||||
|
|
||||||
@ -103,7 +102,7 @@ ADD tools/ ${TOBIKO_DIR}/tools/
|
|||||||
COPY --from=install /usr/local /usr/local/
|
COPY --from=install /usr/local /usr/local/
|
||||||
|
|
||||||
WORKDIR ${TOBIKO_DIR}
|
WORKDIR ${TOBIKO_DIR}
|
||||||
CMD tools/run_tests.py ${OS_TEST_PATH}
|
CMD tools/run_tests.py ${TOBIKO_TEST_PATH}
|
||||||
|
|
||||||
|
|
||||||
FROM test as linters
|
FROM test as linters
|
||||||
|
@ -8,12 +8,12 @@ services:
|
|||||||
target: test
|
target: test
|
||||||
hostname: tobiko
|
hostname: tobiko
|
||||||
environment:
|
environment:
|
||||||
OS_TEST_PATH: tobiko/tests/unit
|
TOBIKO_TEST_PATH: tobiko/tests/unit
|
||||||
TOX_REPORT_NAME: tobiko_results_py3
|
TOBIKO_REPORT_NAME: tobiko_results_py3
|
||||||
volumes:
|
volumes:
|
||||||
- ./report:/report
|
- ./report:/report
|
||||||
- .:/tobiko
|
- .:/tobiko
|
||||||
- ~/.ssh:/root/.ssh
|
- ~/.ssh:/root/.ssh:ro
|
||||||
|
|
||||||
lower-constraints:
|
lower-constraints:
|
||||||
extends:
|
extends:
|
||||||
@ -22,7 +22,7 @@ services:
|
|||||||
args:
|
args:
|
||||||
base_image: lower-constraints
|
base_image: lower-constraints
|
||||||
environment:
|
environment:
|
||||||
TOX_REPORT_NAME: tobiko_results_lower_constraints
|
TOBIKO_REPORT_NAME: tobiko_results_lower_constraints
|
||||||
|
|
||||||
py39:
|
py39:
|
||||||
extends:
|
extends:
|
||||||
@ -31,7 +31,7 @@ services:
|
|||||||
args:
|
args:
|
||||||
base_image: py39
|
base_image: py39
|
||||||
environment:
|
environment:
|
||||||
TOX_REPORT_NAME: tobiko_results_py39
|
TOBIKO_REPORT_NAME: tobiko_results_py39
|
||||||
|
|
||||||
py310:
|
py310:
|
||||||
extends:
|
extends:
|
||||||
@ -40,7 +40,7 @@ services:
|
|||||||
args:
|
args:
|
||||||
base_image: py310
|
base_image: py310
|
||||||
environment:
|
environment:
|
||||||
TOX_REPORT_NAME: tobiko_results_py310
|
TOBIKO_REPORT_NAME: tobiko_results_py310
|
||||||
|
|
||||||
linters:
|
linters:
|
||||||
extends:
|
extends:
|
||||||
@ -52,36 +52,36 @@ services:
|
|||||||
extends:
|
extends:
|
||||||
service: py3
|
service: py3
|
||||||
environment:
|
environment:
|
||||||
OS_TEST_PATH: tobiko/tests/functional
|
TOBIKO_TEST_PATH: tobiko/tests/functional
|
||||||
TOX_REPORT_NAME: tobiko_results_functional
|
TOBIKO_REPORT_NAME: tobiko_results_functional
|
||||||
|
|
||||||
create-workloads:
|
create-workloads:
|
||||||
extends:
|
extends:
|
||||||
service: py3
|
service: py3
|
||||||
environment:
|
environment:
|
||||||
OS_TEST_PATH: tobiko/tests/scenario
|
TOBIKO_TEST_PATH: tobiko/tests/scenario
|
||||||
TOX_REPORT_NAME: tobiko_results_create_workloads
|
TOBIKO_REPORT_NAME: tobiko_results_create_workloads
|
||||||
|
|
||||||
disrupt-services:
|
disrupt-services:
|
||||||
extends:
|
extends:
|
||||||
service: py3
|
service: py3
|
||||||
environment:
|
environment:
|
||||||
OS_TEST_PATH: tobiko/tests/faults
|
TOBIKO_TEST_PATH: tobiko/tests/faults
|
||||||
TOX_REPORT_NAME: tobiko_results_disrupt_services
|
TOBIKO_REPORT_NAME: tobiko_results_disrupt_services
|
||||||
|
|
||||||
verify-workloads:
|
verify-workloads:
|
||||||
extends:
|
extends:
|
||||||
service: create-workloads
|
service: create-workloads
|
||||||
environment:
|
environment:
|
||||||
PREVENT_CREATE: 'true'
|
TOBIKO_PREVENT_CREATE: 'true'
|
||||||
TOX_REPORT_NAME: tobiko_results_verify_workloads
|
TOBIKO_REPORT_NAME: tobiko_results_verify_workloads
|
||||||
|
|
||||||
verify-services:
|
verify-services:
|
||||||
extends:
|
extends:
|
||||||
service: py3
|
service: py3
|
||||||
environment:
|
environment:
|
||||||
OS_TEST_PATH: tobiko/tests/sanity
|
TOBIKO_TEST_PATH: tobiko/tests/sanity
|
||||||
TOX_REPORT_NAME: tobiko_results_verify_services
|
TOBIKO_REPORT_NAME: tobiko_results_verify_services
|
||||||
|
|
||||||
infrared:
|
infrared:
|
||||||
build:
|
build:
|
||||||
@ -92,6 +92,6 @@ services:
|
|||||||
IR_EXTRA_ARGS: --tobiko-src-dir /tobiko
|
IR_EXTRA_ARGS: --tobiko-src-dir /tobiko
|
||||||
volumes:
|
volumes:
|
||||||
- ./report:/report
|
- ./report:/report
|
||||||
- .:/tobiko
|
- .:/tobiko:ro
|
||||||
- ./infrared_plugin:/tobiko-infrared
|
- ./infrared_plugin:/tobiko-infrared:ro
|
||||||
- ~/.ssh:/root/.ssh
|
- ~/.ssh:/root/.ssh:ro
|
||||||
|
@ -36,15 +36,23 @@ TOP_DIR = normalize_path(
|
|||||||
os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
|
os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
|
||||||
|
|
||||||
|
|
||||||
TOX_REPORT_NAME = os.environ.get('TOX_REPORT_NAME', "tobiko_results")
|
# Output dirs
|
||||||
|
REPORT_DIR = os.path.realpath(os.path.expanduser(
|
||||||
|
os.environ.get('TOBIKO_TEST_PATH') or
|
||||||
|
os.environ.get('TOX_REPORT_DIR') or
|
||||||
|
os.getcwd()))
|
||||||
|
|
||||||
TOX_REPORT_DIR = normalize_path(
|
REPORT_NAME = (
|
||||||
os.environ.get('TOX_REPORT_DIR', os.path.join(TOP_DIR, 'report')))
|
os.environ.get('TOBIKO_REPORT_NAME') or
|
||||||
|
os.environ.get('TOX_REPORT_NAME') or
|
||||||
|
'tobiko_results')
|
||||||
|
|
||||||
TOX_REPORT_PREFIX = os.path.join(TOX_REPORT_DIR, TOX_REPORT_NAME)
|
REPORT_PREFIX = os.path.join(REPORT_DIR, REPORT_NAME)
|
||||||
|
|
||||||
TOX_REPORT_HTML = os.environ.get(
|
REPORT_HTML = (
|
||||||
'TOX_REPORT_HTML', TOX_REPORT_PREFIX + '.html')
|
os.environ.get('TOBIKO_REPORT_HTML') or
|
||||||
|
os.environ.get('TOX_REPORT_HTML') or
|
||||||
|
REPORT_PREFIX + '.html')
|
||||||
|
|
||||||
|
|
||||||
@pytest.hookimpl
|
@pytest.hookimpl
|
||||||
@ -101,14 +109,14 @@ def configure_caplog(config):
|
|||||||
|
|
||||||
|
|
||||||
def configure_junitxml(config):
|
def configure_junitxml(config):
|
||||||
config.inicfg['junit_suite_name'] = TOX_REPORT_NAME
|
config.inicfg['junit_suite_name'] = REPORT_NAME
|
||||||
|
|
||||||
|
|
||||||
def configure_html(config):
|
def configure_html(config):
|
||||||
if config.pluginmanager.hasplugin('html'):
|
if config.pluginmanager.hasplugin('html'):
|
||||||
htmlpath = config.getoption('htmlpath')
|
htmlpath = config.getoption('htmlpath')
|
||||||
if htmlpath is None:
|
if htmlpath is None:
|
||||||
config.option.htmlpath = TOX_REPORT_HTML
|
config.option.htmlpath = REPORT_HTML
|
||||||
htmlpath = config.getoption('htmlpath')
|
htmlpath = config.getoption('htmlpath')
|
||||||
assert htmlpath is not None
|
assert htmlpath is not None
|
||||||
|
|
||||||
@ -211,7 +219,7 @@ def pytest_runtest_makereport(item, call):
|
|||||||
|
|
||||||
|
|
||||||
def pytest_html_report_title(report):
|
def pytest_html_report_title(report):
|
||||||
report.title = f"Tobiko test results ({TOX_REPORT_NAME})"
|
report.title = f"Tobiko test results ({REPORT_NAME})"
|
||||||
|
|
||||||
|
|
||||||
@pytest.hookimpl(hookwrapper=True)
|
@pytest.hookimpl(hookwrapper=True)
|
||||||
|
@ -30,34 +30,63 @@ from tools import common # noqa
|
|||||||
LOG = common.get_logger(__name__)
|
LOG = common.get_logger(__name__)
|
||||||
|
|
||||||
# Root tests dir
|
# Root tests dir
|
||||||
OS_TEST_PATH = common.normalize_path(
|
TEST_PATH = common.normalize_path(
|
||||||
|
os.environ.get('TOBIKO_TEST_PATH') or
|
||||||
os.environ.get('OS_TEST_PATH') or
|
os.environ.get('OS_TEST_PATH') or
|
||||||
os.path.join(TOP_DIR, 'tobiko', 'tests', 'unit'))
|
os.path.join(TOP_DIR, 'tobiko', 'tests', 'unit'))
|
||||||
|
|
||||||
# Output dirs
|
# Output dirs
|
||||||
TOX_REPORT_DIR = common.normalize_path(
|
REPORT_DIR = common.normalize_path(
|
||||||
os.environ.get('TOX_REPORT_DIR', os.getcwd()))
|
os.environ.get('TOBIKO_REPORT_DIR') or
|
||||||
|
os.environ.get('TOX_REPORT_DIR') or
|
||||||
|
os.getcwd())
|
||||||
|
|
||||||
TOX_REPORT_NAME = os.environ.get('TOX_REPORT_NAME', 'tobiko_results')
|
REPORT_NAME = (
|
||||||
TOX_REPORT_PREFIX = os.path.join(TOX_REPORT_DIR, TOX_REPORT_NAME)
|
os.environ.get('TOBIKO_REPORT_NAME') or
|
||||||
|
os.environ.get('TOX_REPORT_NAME') or
|
||||||
|
'tobiko_results')
|
||||||
|
|
||||||
TOX_REPORT_LOG = os.environ.get(
|
REPORT_PREFIX = os.path.join(REPORT_DIR, REPORT_NAME)
|
||||||
'TOX_REPORT_LOG', TOX_REPORT_PREFIX + '.log')
|
|
||||||
|
|
||||||
TOX_REPORT_HTML = os.environ.get(
|
REPORT_LOG = (
|
||||||
'TOX_REPORT_HTML', TOX_REPORT_PREFIX + '.html')
|
os.environ.get('TOBIKO_REPORT_LOG') or
|
||||||
|
os.environ.get('TOX_REPORT_LOG') or
|
||||||
|
REPORT_PREFIX + '.log')
|
||||||
|
|
||||||
TOX_REPORT_XML = os.environ.get(
|
REPORT_HTML = (
|
||||||
'TOX_REPORT_XML', TOX_REPORT_PREFIX + '.xml')
|
os.environ.get('TOBIKO_REPORT_HTML') or
|
||||||
|
os.environ.get('TOX_REPORT_HTML') or
|
||||||
|
REPORT_PREFIX + '.html')
|
||||||
|
|
||||||
TOX_NUM_PROCESSES = os.environ.get('TOX_NUM_PROCESSES') or 'auto'
|
REPORT_XML = (
|
||||||
|
os.environ.get('TOBIKO_REPORT_XML') or
|
||||||
|
os.environ.get('TOX_REPORT_XML') or
|
||||||
|
REPORT_PREFIX + '.xml')
|
||||||
|
|
||||||
TOX_RUN_TESTS_TIMEOUT = float(os.environ.get('TOX_RUN_TESTS_TIMEOUT') or 0.)
|
NUM_PROCESSES = (
|
||||||
|
os.environ.get('TOBIKO_NUM_PROCESSES') or
|
||||||
|
os.environ.get('TOX_NUM_PROCESSES') or
|
||||||
|
'auto')
|
||||||
|
|
||||||
TOX_RERUNS = int(os.environ.get('TOX_RERUNS') or 0)
|
RUN_TESTS_TIMEOUT = float(
|
||||||
TOX_RERUNS_DELAY = int(os.environ.get('TOX_RERUNS_DELAY') or 5)
|
os.environ.get('TOBIKO_RUN_TESTS_TIMEOUT') or
|
||||||
|
os.environ.get('TOX_RUN_TESTS_TIMEOUT') or
|
||||||
|
0.)
|
||||||
|
|
||||||
TOX_COVER = bool(os.environ.get('TOX_COVER', 'false').lower() in ['1', 'yes', 'true'])
|
RERUNS = int(
|
||||||
|
os.environ.get('TOBIKO_RERUNS') or
|
||||||
|
os.environ.get('TOX_RERUNS') or
|
||||||
|
0)
|
||||||
|
|
||||||
|
RERUNS_DELAY = int(
|
||||||
|
os.environ.get('TOBIKO_RERUNS_DELAY') or
|
||||||
|
os.environ.get('TOX_RERUNS_DELAY') or
|
||||||
|
5)
|
||||||
|
|
||||||
|
COVER = (
|
||||||
|
os.environ.get('TOBIKO_COVER') or
|
||||||
|
os.environ.get('TOX_COVER') or
|
||||||
|
'false') in ['1', 'yes', 'true']
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@ -95,19 +124,19 @@ def run_tests():
|
|||||||
|
|
||||||
def setup_timeout():
|
def setup_timeout():
|
||||||
|
|
||||||
if TOX_RUN_TESTS_TIMEOUT > 0.:
|
if RUN_TESTS_TIMEOUT > 0.:
|
||||||
|
|
||||||
def handle_timeout(_signum, _frame):
|
def handle_timeout(_signum, _frame):
|
||||||
LOG.error(
|
LOG.error(
|
||||||
f"run_tests.py timeout out after {TOX_RUN_TESTS_TIMEOUT} "
|
f"run_tests.py timeout out after {RUN_TESTS_TIMEOUT} "
|
||||||
"seconds")
|
"seconds")
|
||||||
terminate_childs()
|
terminate_childs()
|
||||||
raise subprocess.TimeoutExpired("run_tests.py",
|
raise subprocess.TimeoutExpired("run_tests.py",
|
||||||
TOX_RUN_TESTS_TIMEOUT)
|
RUN_TESTS_TIMEOUT)
|
||||||
|
|
||||||
signal.setitimer(signal.ITIMER_REAL, TOX_RUN_TESTS_TIMEOUT)
|
signal.setitimer(signal.ITIMER_REAL, RUN_TESTS_TIMEOUT)
|
||||||
signal.signal(signal.SIGALRM, handle_timeout)
|
signal.signal(signal.SIGALRM, handle_timeout)
|
||||||
LOG.debug(f'Run tests timeout set as {TOX_RUN_TESTS_TIMEOUT} seconds')
|
LOG.debug(f'Run tests timeout set as {RUN_TESTS_TIMEOUT} seconds')
|
||||||
|
|
||||||
|
|
||||||
def terminate_childs():
|
def terminate_childs():
|
||||||
@ -123,36 +152,37 @@ def terminate_childs():
|
|||||||
|
|
||||||
|
|
||||||
def cleanup_report_dir():
|
def cleanup_report_dir():
|
||||||
for report_file in [TOX_REPORT_LOG, TOX_REPORT_HTML, TOX_REPORT_XML]:
|
for report_file in [REPORT_LOG, REPORT_HTML, REPORT_XML]:
|
||||||
if not common.make_dir(os.path.dirname(report_file)):
|
if not common.make_dir(os.path.dirname(report_file)):
|
||||||
common.remove_file(report_file)
|
common.remove_file(report_file)
|
||||||
|
|
||||||
|
|
||||||
def log_environ():
|
def log_environ():
|
||||||
common.execute('env | sort >> "{log_file}"', log_file=TOX_REPORT_LOG,
|
common.execute('env | sort >> "{log_file}"',
|
||||||
|
log_file=REPORT_LOG,
|
||||||
capture_stdout=False)
|
capture_stdout=False)
|
||||||
|
|
||||||
|
|
||||||
def run_test_cases():
|
def run_test_cases():
|
||||||
xdist_options = ''
|
xdist_options = ''
|
||||||
if TOX_NUM_PROCESSES != '1':
|
if NUM_PROCESSES != '1':
|
||||||
xdist_options = f"--numprocesses '{TOX_NUM_PROCESSES}' --dist loadscope"
|
xdist_options = f"--numprocesses '{NUM_PROCESSES}' --dist loadscope"
|
||||||
rerun_options = ''
|
rerun_options = ''
|
||||||
if TOX_RERUNS:
|
if RERUNS:
|
||||||
rerun_options = f"--reruns '{TOX_RERUNS}' --reruns-delay '{TOX_RERUNS_DELAY}'"
|
rerun_options = f"--reruns '{RERUNS}' --reruns-delay '{RERUNS_DELAY}'"
|
||||||
cover_options = ''
|
cover_options = ''
|
||||||
if TOX_COVER:
|
if COVER:
|
||||||
cover_options = f"--cov=tobiko"
|
cover_options = f"--cov=tobiko"
|
||||||
|
|
||||||
# Pass environment variables to pytest command
|
# Pass environment variables to pytest command
|
||||||
environ = dict(os.environ, TOX_REPORT_NAME=TOX_REPORT_NAME)
|
environ = dict(os.environ, TOBIKO_REPORT_NAME=REPORT_NAME)
|
||||||
common.execute("pytest -v "
|
common.execute("pytest -v "
|
||||||
f"{xdist_options} "
|
f"{xdist_options} "
|
||||||
f"{rerun_options} "
|
f"{rerun_options} "
|
||||||
f"{cover_options} "
|
f"{cover_options} "
|
||||||
f"--log-file={TOX_REPORT_LOG} "
|
f"--log-file={REPORT_LOG} "
|
||||||
f"--junitxml={TOX_REPORT_XML} "
|
f"--junitxml={REPORT_XML} "
|
||||||
f"--html={TOX_REPORT_HTML} --self-contained-html "
|
f"--html={REPORT_HTML} --self-contained-html "
|
||||||
f"{common.get_posargs()}",
|
f"{common.get_posargs()}",
|
||||||
environ=environ,
|
environ=environ,
|
||||||
capture_stdout=False)
|
capture_stdout=False)
|
||||||
|
4
tox.ini
4
tox.ini
@ -56,10 +56,10 @@ setenv =
|
|||||||
TOX_COVER = true
|
TOX_COVER = true
|
||||||
TOX_COVER_DIR={env:TOX_COVER_DIR:{toxinidir}/cover}
|
TOX_COVER_DIR={env:TOX_COVER_DIR:{toxinidir}/cover}
|
||||||
|
|
||||||
commands =
|
commands_post =
|
||||||
{[testenv]commands}
|
|
||||||
coverage html -d "{env:TOX_COVER_DIR}"
|
coverage html -d "{env:TOX_COVER_DIR}"
|
||||||
coverage xml -o "{env:TOX_COVER_DIR}/coverage.xml"
|
coverage xml -o "{env:TOX_COVER_DIR}/coverage.xml"
|
||||||
|
|
||||||
whitelist_externals =
|
whitelist_externals =
|
||||||
find
|
find
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user