Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ci_visibility): handle pytest ATR retry failures in unittest classes #12030

Merged

Conversation

vitor-de-araujo
Copy link
Contributor

@vitor-de-araujo vitor-de-araujo commented Jan 22, 2025

Auto Test Retries had a bug where retries of tests defined inside unittest classes would always succeed, even if the test failed. This was because for unittest classes, pytest saves the exception status in the pytest_runtest_makereport hook, which was not called during retries. This PR fixes it so that the hook is called.

Checklist

  • PR author has checked that all the criteria below are met
  • The PR description includes an overview of the change
  • The PR description articulates the motivation for the change
  • The change includes tests OR the PR description describes a testing strategy
  • The PR description notes risks associated with the change, if any
  • Newly-added code is easy to change
  • The change follows the library release note guidelines
  • The change includes or references documentation updates if necessary
  • Backport labels are set (if applicable)

Reviewer Checklist

  • Reviewer has checked that all the criteria below are met
  • Title is accurate
  • All changes are related to the pull request's stated goal
  • Avoids breaking API changes
  • Testing strategy adequately addresses listed risks
  • Newly-added code is easy to change
  • Release note makes sense to a user of the library
  • If necessary, author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment
  • Backport labels are set in a manner that is consistent with the release branch maintenance policy

Copy link
Contributor

github-actions bot commented Jan 22, 2025

CODEOWNERS have been resolved as:

releasenotes/notes/ci_visibility-fix-pytest-classes-b54582b09727fdc1.yaml  @DataDog/apm-python
ddtrace/contrib/internal/pytest/_retry_utils.py                         @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/pytest/test_pytest_atr.py                                 @DataDog/ci-app-libraries

@datadog-dd-trace-py-rkomorn
Copy link

datadog-dd-trace-py-rkomorn bot commented Jan 22, 2025

Datadog Report

Branch report: vitor-de-araujo/SDTEST-1469/retry-unittest-classes
Commit report: 1bba8ac
Test service: dd-trace-py

✅ 0 Failed, 130 Passed, 1378 Skipped, 4m 39.99s Total duration (35m 6.44s time saved)

@pr-commenter
Copy link

pr-commenter bot commented Jan 22, 2025

Benchmarks

Benchmark execution time: 2025-01-23 09:54:20

Comparing candidate commit 1bba8ac in PR branch vitor-de-araujo/SDTEST-1469/retry-unittest-classes with baseline commit 2f52abb in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 394 metrics, 2 unstable metrics.

@vitor-de-araujo vitor-de-araujo changed the title fix(ci_visibility): retry tests defined in unittest classes with pytest fix(ci_visibility): handle ATR retry failures in unittest classes with pytest Jan 23, 2025
@vitor-de-araujo vitor-de-araujo changed the title fix(ci_visibility): handle ATR retry failures in unittest classes with pytest fix(ci_visibility): handle pytest ATR retry failures in unittest classes Jan 23, 2025
@vitor-de-araujo vitor-de-araujo marked this pull request as ready for review January 23, 2025 09:20
@vitor-de-araujo vitor-de-araujo requested review from a team as code owners January 23, 2025 09:20
@vitor-de-araujo vitor-de-araujo enabled auto-merge (squash) January 23, 2025 16:13
@vitor-de-araujo vitor-de-araujo merged commit dc7037e into main Jan 23, 2025
520 of 524 checks passed
@vitor-de-araujo vitor-de-araujo deleted the vitor-de-araujo/SDTEST-1469/retry-unittest-classes branch January 23, 2025 16:54
github-actions bot pushed a commit that referenced this pull request Jan 23, 2025
…ses (#12030)

Auto Test Retries had a bug where retries of tests defined inside
unittest classes would always succeed, even if the test failed. This was
because for unittest classes, pytest saves the exception status in the
[`pytest_runtest_makereport`
hook](https://github.com/pytest-dev/pytest/blob/8.3.x/src/_pytest/unittest.py#L368),
which was not called during retries. This PR fixes it so that the hook
is called.

## Checklist
- [x] PR author has checked that all the criteria below are met
- The PR description includes an overview of the change
- The PR description articulates the motivation for the change
- The change includes tests OR the PR description describes a testing
strategy
- The PR description notes risks associated with the change, if any
- Newly-added code is easy to change
- The change follows the [library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## Reviewer Checklist
- [x] Reviewer has checked that all the criteria below are met
- Title is accurate
- All changes are related to the pull request's stated goal
- Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- Testing strategy adequately addresses listed risks
- Newly-added code is easy to change
- Release note makes sense to a user of the library
- If necessary, author has acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment
- Backport labels are set in a manner that is consistent with the
[release branch maintenance
policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)

(cherry picked from commit dc7037e)
github-actions bot pushed a commit that referenced this pull request Jan 23, 2025
…ses (#12030)

Auto Test Retries had a bug where retries of tests defined inside
unittest classes would always succeed, even if the test failed. This was
because for unittest classes, pytest saves the exception status in the
[`pytest_runtest_makereport`
hook](https://github.com/pytest-dev/pytest/blob/8.3.x/src/_pytest/unittest.py#L368),
which was not called during retries. This PR fixes it so that the hook
is called.

## Checklist
- [x] PR author has checked that all the criteria below are met
- The PR description includes an overview of the change
- The PR description articulates the motivation for the change
- The change includes tests OR the PR description describes a testing
strategy
- The PR description notes risks associated with the change, if any
- Newly-added code is easy to change
- The change follows the [library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## Reviewer Checklist
- [x] Reviewer has checked that all the criteria below are met
- Title is accurate
- All changes are related to the pull request's stated goal
- Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- Testing strategy adequately addresses listed risks
- Newly-added code is easy to change
- Release note makes sense to a user of the library
- If necessary, author has acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment
- Backport labels are set in a manner that is consistent with the
[release branch maintenance
policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)

(cherry picked from commit dc7037e)
github-actions bot pushed a commit that referenced this pull request Jan 23, 2025
…ses (#12030)

Auto Test Retries had a bug where retries of tests defined inside
unittest classes would always succeed, even if the test failed. This was
because for unittest classes, pytest saves the exception status in the
[`pytest_runtest_makereport`
hook](https://github.com/pytest-dev/pytest/blob/8.3.x/src/_pytest/unittest.py#L368),
which was not called during retries. This PR fixes it so that the hook
is called.

## Checklist
- [x] PR author has checked that all the criteria below are met
- The PR description includes an overview of the change
- The PR description articulates the motivation for the change
- The change includes tests OR the PR description describes a testing
strategy
- The PR description notes risks associated with the change, if any
- Newly-added code is easy to change
- The change follows the [library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## Reviewer Checklist
- [x] Reviewer has checked that all the criteria below are met
- Title is accurate
- All changes are related to the pull request's stated goal
- Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- Testing strategy adequately addresses listed risks
- Newly-added code is easy to change
- Release note makes sense to a user of the library
- If necessary, author has acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment
- Backport labels are set in a manner that is consistent with the
[release branch maintenance
policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)

(cherry picked from commit dc7037e)
wantsui added a commit that referenced this pull request Jan 23, 2025
vitor-de-araujo added a commit that referenced this pull request Jan 28, 2025
…ses [backport 2.20] (#12048)

Backport dc7037e from #12030 to 2.20.

Auto Test Retries had a bug where retries of tests defined inside
unittest classes would always succeed, even if the test failed. This was
because for unittest classes, pytest saves the exception status in the
[`pytest_runtest_makereport`
hook](https://github.com/pytest-dev/pytest/blob/8.3.x/src/_pytest/unittest.py#L368),
which was not called during retries. This PR fixes it so that the hook
is called.

## Checklist
- [x] PR author has checked that all the criteria below are met
- The PR description includes an overview of the change
- The PR description articulates the motivation for the change
- The change includes tests OR the PR description describes a testing
strategy
- The PR description notes risks associated with the change, if any
- Newly-added code is easy to change
- The change follows the [library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## Reviewer Checklist
- [x] Reviewer has checked that all the criteria below are met 
- Title is accurate
- All changes are related to the pull request's stated goal
- Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- Testing strategy adequately addresses listed risks
- Newly-added code is easy to change
- Release note makes sense to a user of the library
- If necessary, author has acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment
- Backport labels are set in a manner that is consistent with the
[release branch maintenance
policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)

Co-authored-by: Vítor De Araújo <[email protected]>
vitor-de-araujo added a commit that referenced this pull request Jan 29, 2025
…ses [backport 2.18] (#12046)

Backport dc7037e from #12030 to 2.18.

Auto Test Retries had a bug where retries of tests defined inside
unittest classes would always succeed, even if the test failed. This was
because for unittest classes, pytest saves the exception status in the
[`pytest_runtest_makereport`
hook](https://github.com/pytest-dev/pytest/blob/8.3.x/src/_pytest/unittest.py#L368),
which was not called during retries. This PR fixes it so that the hook
is called.

## Checklist
- [x] PR author has checked that all the criteria below are met
- The PR description includes an overview of the change
- The PR description articulates the motivation for the change
- The change includes tests OR the PR description describes a testing
strategy
- The PR description notes risks associated with the change, if any
- Newly-added code is easy to change
- The change follows the [library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## Reviewer Checklist
- [x] Reviewer has checked that all the criteria below are met 
- Title is accurate
- All changes are related to the pull request's stated goal
- Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- Testing strategy adequately addresses listed risks
- Newly-added code is easy to change
- Release note makes sense to a user of the library
- If necessary, author has acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment
- Backport labels are set in a manner that is consistent with the
[release branch maintenance
policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)

Co-authored-by: Vítor De Araújo <[email protected]>
Co-authored-by: Brett Langdon <[email protected]>
ZStriker19 pushed a commit that referenced this pull request Jan 30, 2025
…ses (#12030)

Auto Test Retries had a bug where retries of tests defined inside
unittest classes would always succeed, even if the test failed. This was
because for unittest classes, pytest saves the exception status in the
[`pytest_runtest_makereport`
hook](https://github.com/pytest-dev/pytest/blob/8.3.x/src/_pytest/unittest.py#L368),
which was not called during retries. This PR fixes it so that the hook
is called.

## Checklist
- [x] PR author has checked that all the criteria below are met
- The PR description includes an overview of the change
- The PR description articulates the motivation for the change
- The change includes tests OR the PR description describes a testing
strategy
- The PR description notes risks associated with the change, if any
- Newly-added code is easy to change
- The change follows the [library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## Reviewer Checklist
- [x] Reviewer has checked that all the criteria below are met 
- Title is accurate
- All changes are related to the pull request's stated goal
- Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- Testing strategy adequately addresses listed risks
- Newly-added code is easy to change
- Release note makes sense to a user of the library
- If necessary, author has acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment
- Backport labels are set in a manner that is consistent with the
[release branch maintenance
policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants