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

Reenable coverate instrumentation of test files #11819

Closed
wants to merge 2 commits into from

Conversation

labbati
Copy link
Member

@labbati labbati commented Dec 20, 2024

With this change https://github.com/DataDog/dd-trace-py/pull/11379/files#diff-3985b6c4c52757d7d726c3002c85935f582641d687acd0f6ab50f93e1294205dR330 in #11379 we had made a number of tests in tests/coverage/ failing by design, since now the coverage code was non-instrumenting code if it is vendored (aka non-user code). Tests were regularly failing in main.

Problem is that code from dd-trace-py/tests is considered vendored by the algorithm, as dd-trace-py is installed locally (think pip install -e ./) by the hatch dd_coverage.py3.* environments, used to run tests: https://gitlab.ddbuild.io/DataDog/apm-reliability/dd-trace-py/-/jobs/747303728#L56.

This commit introduces an hack: if the code is invoked as part of a pytest run AND comes from the tests folder, then can be instrumented by the coverage module.

While not proud of it, it is the best trade off I could think about without foundational changes to how we run tests in pytest.

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

CODEOWNERS have been resolved as:

ddtrace/internal/coverage/code.py                                       @DataDog/apm-core-python @datadog/ci-app-libraries
ddtrace/internal/packages.py                                            @DataDog/apm-core-python

@pr-commenter
Copy link

pr-commenter bot commented Dec 20, 2024

Benchmarks

Benchmark execution time: 2024-12-24 14:33:21

Comparing candidate commit 736ec99 in PR branch labbati/coverage-broken-tests with baseline commit 998ee2c in branch main.

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

scenario:iast_aspects-ospathdirname_aspect

  • 🟥 execution_time [+300.996ns; +367.269ns] or [+8.265%; +10.085%]

scenario:iast_aspects-ospathjoin_aspect

  • 🟩 execution_time [-508.698ns; -433.617ns] or [-9.025%; -7.693%]

scenario:iast_aspects-ospathsplitdrive_aspect

  • 🟥 execution_time [+190.191ns; +234.595ns] or [+7.157%; +8.829%]

@labbati labbati marked this pull request as ready for review December 24, 2024 13:52
@labbati labbati requested review from a team as code owners December 24, 2024 13:52
@labbati labbati closed this Dec 24, 2024
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.

1 participant