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

chore(ci_visibility): add quarantine support to pytest #11615

Merged
merged 35 commits into from
Dec 20, 2024

Conversation

vitor-de-araujo
Copy link
Contributor

@vitor-de-araujo vitor-de-araujo commented Dec 4, 2024

This PR adds preliminary support for quarantining tests in pytest.

The API to query which tests are quarantined does not exist yet on the backend side, and the final form of that API is still to be defined, so the code dealing with the API has been moved to a separate PR (#11770). Currently, we can mark tests as quarantined by manually adding the test.quarantine.is_quarantined tag to the test with a pytest decorator:

@pytest.mark.dd_tags(**{"test.quarantine.is_quarantined": True})
def test_fail_quarantined():
    assert False

For testing purposes, the environment variables _DD_TEST_FORCE_ENABLE_QUARANTINE and _DD_TEST_FORCE_ENABLE_ATR have been added to enable quarantine and ATR without depending on the backend.

The test reporting looks like below. Errors and logs for quarantined tests are not printed.
image

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

@pr-commenter
Copy link

pr-commenter bot commented Dec 4, 2024

Benchmarks

Benchmark execution time: 2024-12-20 12:17:07

Comparing candidate commit e419523 in PR branch vitor-de-araujo/SDTEST-1255/quarantine with baseline commit 20b2b03 in branch main.

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

scenario:iast_aspects-ospathdirname_aspect

  • 🟩 execution_time [-402.878ns; -334.100ns] or [-9.979%; -8.276%]

@vitor-de-araujo vitor-de-araujo changed the title Add quarantine support to pytest (WIP) Add quarantine support to pytest Dec 18, 2024
Copy link
Contributor

github-actions bot commented Dec 18, 2024

CODEOWNERS have been resolved as:

tests/ci_visibility/test_quarantine.py                                  @DataDog/ci-app-libraries
tests/contrib/pytest/test_pytest_quarantine.py                          @DataDog/ci-app-libraries
ddtrace/contrib/pytest/_atr_utils.py                                    @DataDog/ci-app-libraries
ddtrace/contrib/pytest/_plugin_v2.py                                    @DataDog/ci-app-libraries
ddtrace/contrib/pytest/_retry_utils.py                                  @DataDog/ci-app-libraries
ddtrace/internal/ci_visibility/_api_client.py                           @DataDog/ci-app-libraries
ddtrace/internal/ci_visibility/api/_base.py                             @DataDog/ci-app-libraries
ddtrace/internal/ci_visibility/api/_session.py                          @DataDog/ci-app-libraries
ddtrace/internal/ci_visibility/api/_suite.py                            @DataDog/ci-app-libraries
ddtrace/internal/ci_visibility/api/_test.py                             @DataDog/ci-app-libraries
ddtrace/internal/ci_visibility/constants.py                             @DataDog/ci-app-libraries
ddtrace/internal/ci_visibility/recorder.py                              @DataDog/ci-app-libraries
ddtrace/internal/ci_visibility/telemetry/events.py                      @DataDog/ci-app-libraries
ddtrace/internal/ci_visibility/telemetry/git.py                         @DataDog/ci-app-libraries
ddtrace/internal/test_visibility/api.py                                 @DataDog/ci-app-libraries
tests/ci_visibility/api_client/_util.py                                 @DataDog/ci-app-libraries
tests/ci_visibility/test_encoder.py                                     @DataDog/ci-app-libraries
tests/contrib/pytest/test_pytest_atr.py                                 @DataDog/ci-app-libraries
tests/contrib/pytest/test_pytest_efd.py                                 @DataDog/ci-app-libraries

@vitor-de-araujo vitor-de-araujo changed the title Add quarantine support to pytest feat(ci_visibility): add quarantine support to pytest Dec 18, 2024
@vitor-de-araujo vitor-de-araujo changed the title feat(ci_visibility): add quarantine support to pytest chore(ci_visibility): add quarantine support to pytest Dec 18, 2024
@vitor-de-araujo vitor-de-araujo added the changelog/no-changelog A changelog entry is not required for this PR. label Dec 18, 2024
@vitor-de-araujo vitor-de-araujo marked this pull request as ready for review December 19, 2024 08:31
@vitor-de-araujo vitor-de-araujo requested a review from a team as a code owner December 19, 2024 08:31
@datadog-dd-trace-py-rkomorn
Copy link

datadog-dd-trace-py-rkomorn bot commented Dec 20, 2024

Datadog Report

Branch report: vitor-de-araujo/SDTEST-1255/quarantine
Commit report: e419523
Test service: dd-trace-py

✅ 0 Failed, 922 Passed, 546 Skipped, 16m 53.61s Total duration (55m 44.02s time saved)

@vitor-de-araujo vitor-de-araujo merged commit 3f64666 into main Dec 20, 2024
212 checks passed
@vitor-de-araujo vitor-de-araujo deleted the vitor-de-araujo/SDTEST-1255/quarantine branch December 20, 2024 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog/no-changelog A changelog entry is not required for this PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants