diff --git a/infrared_plugin/jenkins.yaml b/infrared_plugin/jenkins.yaml new file mode 100644 index 000000000..9930dfaeb --- /dev/null +++ b/infrared_plugin/jenkins.yaml @@ -0,0 +1,7 @@ +--- + +# Test cases failures are threated as success to allow Jenkinst to complete +# yellow builds +tox_expected_rcs: + - '{{ tox_succeeded_rc }}' + - '{{ tox_failed_rc }}' diff --git a/infrared_plugin/main.yaml b/infrared_plugin/main.yaml index 6e7be04c2..988115448 100644 --- a/infrared_plugin/main.yaml +++ b/infrared_plugin/main.yaml @@ -43,6 +43,10 @@ dest: '{{ playbook_dir }}/roles' state: link + - name: "include Jenkins settings" + include_vars: jenkins.yaml + when: "(lookup('env','JENKINS_URL') | length) > 0" + - hosts: '{{ test_host | default(hostvars.localhost.test_host) | default("localhost") }}' diff --git a/infrared_plugin/plugin.spec b/infrared_plugin/plugin.spec index 8af70c69d..0f087d729 100644 --- a/infrared_plugin/plugin.spec +++ b/infrared_plugin/plugin.spec @@ -171,6 +171,10 @@ subparsers: type: Value help: URL or path to upper contraints file ansible_variable: upper_constraints_file + ignore-test-failures: + type: Flag + help: Ignore test execution errors + ansible_variable: ignore_test_failures - title: Collect stage options: diff --git a/roles/tobiko-tox/defaults/main.yaml b/roles/tobiko-tox/defaults/main.yaml index 85b396e43..c109524e6 100644 --- a/roles/tobiko-tox/defaults/main.yaml +++ b/roles/tobiko-tox/defaults/main.yaml @@ -21,3 +21,10 @@ tox_constrain_env: TOX_REPORT_DIR: '{{ tox_report_dir }}' TOX_REPORT_NAME: '{{ tox_report_name }}' TOX_CONSTRAINTS_FILE: '{{ tox_constraints_file }}' + +tox_succeeded_rc: 0 +tox_failed_rc: 1 + +tox_expected_rcs: + - '{{ tox_succeeded_rc }}' +ignore_test_failures: no diff --git a/roles/tobiko-tox/tasks/tox.yaml b/roles/tobiko-tox/tasks/tox.yaml index 43fa81783..19fe92f53 100644 --- a/roles/tobiko-tox/tasks/tox.yaml +++ b/roles/tobiko-tox/tasks/tox.yaml @@ -20,6 +20,7 @@ tox_description: '{{ tox_description }}' tox_dir: '{{ tox_dir }}' tox_environment: '{{ tox_environment | combine(tox_constrain_env) }}' + tox_expected_rcs: '{{ tox_expected_rcs }}' - name: "{{ tox_description }}" @@ -29,27 +30,27 @@ register: run_tox environment: '{{ tox_environment | combine(tox_constrain_env) }}' + failed_when: run_tox.rc != tox_succeeded_rc ignore_errors: yes -- name: "show test cases results" +- name: "show test cases output" debug: var=run_tox.stdout_lines when: - (run_tox.stdout_lines | length) > 0 -- name: - block: - - name: "show test cases errors" - debug: var=run_tox.stderr_lines - when: - - (run_tox.stderr_lines | length) > 0 - - - name: 'report test cases failure' - debug: - msg: 'test cases have failed' - failed_when: yes - +- name: "show test cases errors" + debug: var=run_tox.stderr_lines when: - - run_tox is defined - run_tox is failed + - (run_tox.stderr_lines | length) > 0 + + +- name: 'raise test cases failure' + debug: + msg: 'test cases have failed' + when: run_tox is failed + failed_when: + - not (ignore_test_failures | bool) + - run_tox.rc not in tox_expected_rcs diff --git a/tools/run_tests.py b/tools/run_tests.py index e4e31afe6..045d3fb00 100644 --- a/tools/run_tests.py +++ b/tools/run_tests.py @@ -53,6 +53,7 @@ def main(): succeeded = run_tests() if succeeded: LOG.info('SUCCEEDED') + sys.exit(0) else: LOG.info('FAILED') sys.exit(1)