diff --git a/infrared_plugin/plugin.spec b/infrared_plugin/plugin.spec index e48d07889..7fcf58c59 100644 --- a/infrared_plugin/plugin.spec +++ b/infrared_plugin/plugin.spec @@ -191,6 +191,10 @@ subparsers: type: Value help: Extra options to be passed to PyTest ansible_variable: pytest_addopts + pytest-maxfail: + type: Value + help: Max number of test case failures before aborting + ansible_variable: pytest_maxfail run-tests-timeout: type: Value help: Timeout (in seconds) to interrupt test cases execution diff --git a/roles/tobiko-run/vars/test-workflow-faults-iha.yaml b/roles/tobiko-run/vars/test-workflow-faults-iha.yaml index f387ad39f..5bf59d34c 100644 --- a/roles/tobiko-run/vars/test-workflow-faults-iha.yaml +++ b/roles/tobiko-run/vars/test-workflow-faults-iha.yaml @@ -4,3 +4,4 @@ test_workflow_steps: - tox_description: 'run disruptive test cases' tox_envlist: instanceha tox_step_name: instanceha + pytest_maxfail: 1 diff --git a/roles/tobiko-run/vars/test-workflow-faults-neutron.yaml b/roles/tobiko-run/vars/test-workflow-faults-neutron.yaml index 8c356f5bb..d7ef67a32 100644 --- a/roles/tobiko-run/vars/test-workflow-faults-neutron.yaml +++ b/roles/tobiko-run/vars/test-workflow-faults-neutron.yaml @@ -10,6 +10,7 @@ test_workflow_steps: - tox_description: 'run disruptive test cases' tox_envlist: neutron_faults tox_step_name: neutron_faults + pytest_maxfail: 1 - tox_description: 'verify Neutron resources' tox_envlist: neutron diff --git a/roles/tobiko-run/vars/test-workflow-faults.yaml b/roles/tobiko-run/vars/test-workflow-faults.yaml index 38d19e905..2ba8942bf 100644 --- a/roles/tobiko-run/vars/test-workflow-faults.yaml +++ b/roles/tobiko-run/vars/test-workflow-faults.yaml @@ -18,6 +18,7 @@ test_workflow_steps: tox_step_name: faults tox_environment: TOBIKO_PREVENT_CREATE: no + pytest_maxfail: 1 - tox_description: 'run sanity test cases after disruptive test cases' tox_envlist: sanity diff --git a/roles/tobiko-tox/defaults/main.yaml b/roles/tobiko-tox/defaults/main.yaml index a65a02fde..a77ec9b57 100644 --- a/roles/tobiko-tox/defaults/main.yaml +++ b/roles/tobiko-tox/defaults/main.yaml @@ -20,8 +20,10 @@ tox_run_tests_timeout: 18000 # 5 hours tox_constraints: '' tox_constrain_env: - PYTEST_ADDOPTS: - "{% if not test_flaky %}-m 'not flaky' {% endif %}{{ pytest_addopts }}" + PYTEST_ADDOPTS: > + {% if not test_flaky%}-m 'not flaky'{% endif %} + {% if pytest_maxfail %}--maxfail '{{ pytest_maxfail }}'{% endif %} + {{ pytest_addopts }} TOX_REPORT_DIR: '{{ tox_report_dir }}' TOX_REPORT_NAME: '{{ tox_report_name }}' TOX_CONSTRAINTS: '{{ tox_constraints }}' @@ -35,4 +37,5 @@ tox_expected_rcs: ignore_test_failures: no pytest_addopts: '' +pytest_maxfail: '' test_flaky: false diff --git a/roles/tobiko-tox/tasks/tox.yaml b/roles/tobiko-tox/tasks/tox.yaml index 3dca56752..e51de7872 100644 --- a/roles/tobiko-tox/tasks/tox.yaml +++ b/roles/tobiko-tox/tasks/tox.yaml @@ -13,9 +13,17 @@ tox_command_line: '{{ tox_command_line.split() | join(" ") }}' -- name: combine environment variables +- name: combine and normalize environment variable values set_fact: - tox_env: '{{ tox_environment | from_yaml | combine(tox_constrain_env) }}' + tox_env: > + {{ tox_env | + default({}) | + combine({ item.key: (item.value | string).strip() }) }} + loop: > + {{ ((tox_environment | from_yaml | dict2items) + + (tox_constrain_env | dict2items)) }} + when: + - (item.value | string).strip() # skip empty strings - name: show tox variables debug: var="{{ item }}" diff --git a/tox.ini b/tox.ini index 1937df606..dd804950a 100644 --- a/tox.ini +++ b/tox.ini @@ -242,7 +242,6 @@ setenv = OS_TEST_PATH = {toxinidir}/tobiko/tests/faults TOX_NUM_PROCESSES = 1 PYTEST_TIMEOUT = 3600 - RUN_TESTS_EXTRA_ARGS = --maxfail=1 {env:OS_TEST_PATH} [testenv:octavia_faults]