Skip to content

Conversation

@paride
Copy link
Contributor

@paride paride commented Jun 17, 2022

Proposed Commit Message

tox: integration-tests-jenkins: softfail if only some test failed

Prior to this change a single test failure when running the
integration-tests-jenkins tox environment caused Jenkins jobs to fully
fail (status FAILURE).

With this change the pytest's "some tests failed" return code [1] is
ignored, and the status of the Jenkins jobs is determined using the
junit report that pytest generates. Most of the time this will result
in UNSTABLE (yellow) jobs when some tests failed.

If the junit report is missing (or only reports failures) the job
will still be marked as FAILURE (red).

[1] https://docs.pytest.org/en/7.1.x/reference/exit-codes.html

Additional Context

See the internal Jenkins cloud-init view.

Test Steps

  1. Sabotage a test and run the integration-tests-jenkins on a subset
    of tests containing it. Verify that tox logs the failure but returns 0.
  2. Pass a test directory that doesn't exist to the environment via posargs.
    Verify that tox returns nonzero (should return 4 iirc).

Checklist:

  • My code follows the process laid out in the documentation
  • I have updated or added any unit tests accordingly
  • I have updated or added any documentation accordingly

Prior to this change a single test failure when running the
integration-tests-jenkins tox environment caused Jenkins jobs to fully
fail (status FAILURE).

With this change the pytest's "some tests failed" return code [1] is
ignored, and the status of the Jenkins jobs is determined using the
junit report that pytest generates. Most of the time this will result
in UNSTABLE (yellow) jobs when some tests failed.

If the junit report is missing (or only reports failures) the job
will still be marked as FAILURE (red).

[1] https://docs.pytest.org/en/7.1.x/reference/exit-codes.html
@paride
Copy link
Contributor Author

paride commented Jun 17, 2022

This should help distinguish tests failure from infrastructure/Jenkint/network/... issues. If you're wondering where we're telling pytest to generate the junit report it's here: https://github.com/canonical/server-jenkins-jobs/blob/4871903be5d8f411f7fe1b2cb0e7b8ff754e69fa/jenkins-jobs/cloud-init/integration.yaml#L167=.

@paride paride changed the title tox: integration-tests-jenkins: softfail if only some test failed tox: integration-tests-jenkins: softfail if only some test failed (SC-1117) Jun 17, 2022
Copy link
Contributor

@TheRealFalcon TheRealFalcon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants