Skip to content

refactor(ci_visibility): remove core usage #13654

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

Merged
merged 63 commits into from
Jun 17, 2025
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
e7950ec
atr + xdist test improvements
gnufede Jun 10, 2025
6e67582
xdist + ITR tests
gnufede Jun 10, 2025
9a45af8
itr + xdist changes
gnufede Jun 10, 2025
1726ab1
plugin changes
gnufede Jun 10, 2025
c8277f3
integration tests for itr + xdist
gnufede Jun 10, 2025
6cb10a8
Revert "allow for test level skipping"
gnufede Jun 10, 2025
7cb7013
Merge branch 'main' into gnufede/SDTEST-2150-pytest-xdist-itr-skipped…
gnufede Jun 10, 2025
f804946
reduce test code
gnufede Jun 11, 2025
ec23911
add unit tests
gnufede Jun 11, 2025
4e422dd
finish regardless of itr
gnufede Jun 11, 2025
6e6c255
change place to set itr tags
gnufede Jun 11, 2025
d41b7c8
use proper channels to set distributed itr skip count
gnufede Jun 12, 2025
22bc855
details
gnufede Jun 12, 2025
6f7c2bc
xdist context propagation tests fixed
gnufede Jun 12, 2025
9785070
pass proper argument
gnufede Jun 12, 2025
96ee051
refactor 1
gnufede Jun 12, 2025
97bbbd7
style
gnufede Jun 12, 2025
36c48a5
refactor 2
gnufede Jun 12, 2025
42135a6
more refactors
gnufede Jun 12, 2025
245e204
proper name functions
gnufede Jun 12, 2025
65f1ef6
types
gnufede Jun 12, 2025
879eede
fmt
gnufede Jun 12, 2025
27df520
mypy
gnufede Jun 12, 2025
76b2ea5
🔥
gnufede Jun 12, 2025
9683ca2
remove discoverargs
gnufede Jun 12, 2025
3e062f4
🔥
gnufede Jun 12, 2025
0d9d8d8
🔥
gnufede Jun 13, 2025
eb366d9
registry
gnufede Jun 13, 2025
f5c8e48
style
gnufede Jun 13, 2025
3618a24
fix
gnufede Jun 13, 2025
3e72f8a
avoid circular imports
gnufede Jun 13, 2025
dbae478
remove more circular imports
gnufede Jun 13, 2025
ffdb58f
typo
gnufede Jun 13, 2025
94d21d7
remove catch and log exceptions
gnufede Jun 13, 2025
80297ad
💀
gnufede Jun 13, 2025
939ff28
mypy and other
gnufede Jun 13, 2025
4062664
undo
gnufede Jun 13, 2025
7483314
mypy
gnufede Jun 13, 2025
231c384
refactor to fix test
gnufede Jun 13, 2025
8a4b2df
fix some tests
gnufede Jun 13, 2025
1d877ad
fmt
gnufede Jun 13, 2025
fd99097
plugin v1 change
gnufede Jun 16, 2025
2c2323b
Merge remote-tracking branch 'origin/main' into gnufede/un-core
gnufede Jun 16, 2025
9cc6359
default is not to pass
vitor-de-araujo Jun 16, 2025
01c24f7
instance!
vitor-de-araujo Jun 16, 2025
dbbd469
set_benchmark_data
vitor-de-araujo Jun 16, 2025
f881219
catch and log exceptions, mypy
gnufede Jun 16, 2025
f159afb
Merge branch 'main' into gnufede/un-core
gnufede Jun 16, 2025
6b5fa90
dd_testing_raise;service registry simplification
gnufede Jun 17, 2025
0314e6f
typing
gnufede Jun 17, 2025
e214c27
fix sast complain
gnufede Jun 17, 2025
319d602
log warning instead of pass
gnufede Jun 17, 2025
6b97443
Remove unneeded *Args classes
gnufede Jun 17, 2025
b1823ff
use dd_testing_raise from ddconfig
gnufede Jun 17, 2025
dbfadbb
Update ddtrace/internal/ci_visibility/api/_test.py
gnufede Jun 17, 2025
8d8a18b
some fixes
vitor-de-araujo Jun 17, 2025
1f764eb
finish him!
vitor-de-araujo Jun 17, 2025
357f18a
Merge branch 'main' of github.com:DataDog/dd-trace-py into gnufede/un…
vitor-de-araujo Jun 17, 2025
cf4c043
itr:noskip
vitor-de-araujo Jun 17, 2025
a348899
it is not an error for CI Visibility to not be available when it's no…
vitor-de-araujo Jun 17, 2025
ad551e2
cleanup, itr:noskip
vitor-de-araujo Jun 17, 2025
66e3ea0
Merge branch 'main' of github.com:DataDog/dd-trace-py into gnufede/un…
vitor-de-araujo Jun 17, 2025
b5b6ec5
itr:noskip
vitor-de-araujo Jun 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions ddtrace/contrib/internal/pytest/_plugin_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ def pytest_configure_node(self, node):

node.workerinput["root_span"] = root_span

@pytest.hookimpl
def pytest_testnodedown(self, node, error):
if hasattr(node, "workeroutput") and "itr_skipped_count" in node.workeroutput:
if not hasattr(pytest, "global_worker_itr_results"):
pytest.global_worker_itr_results = 0
pytest.global_worker_itr_results += node.workeroutput["itr_skipped_count"]


def _handle_itr_should_skip(item, test_id) -> bool:
"""Checks whether a test should be skipped
Expand All @@ -135,6 +142,13 @@ def _handle_itr_should_skip(item, test_id) -> bool:
InternalTest.mark_itr_skipped(test_id)
# Marking the test as skipped by ITR so that it appears in pytest's output
item.add_marker(pytest.mark.skip(reason=SKIPPED_BY_ITR_REASON)) # TODO don't rely on internal for reason

# If we're in a worker process, count the skipped test
if hasattr(item.config, "workeroutput"):
if "itr_skipped_count" not in item.config.workeroutput:
item.config.workeroutput["itr_skipped_count"] = 0
item.config.workeroutput["itr_skipped_count"] += 1

return True

return False
Expand Down Expand Up @@ -267,6 +281,9 @@ def pytest_configure(config: pytest_Config) -> None:

if config.pluginmanager.hasplugin("xdist"):
config.pluginmanager.register(XdistHooks())

if not hasattr(config, "workerinput"): # Main process
pytest.global_worker_itr_results = 0
else:
# If the pytest ddtrace plugin is not enabled, we should disable CI Visibility, as it was enabled during
# pytest_load_initial_conftests
Expand Down Expand Up @@ -315,6 +332,7 @@ def pytest_sessionstart(session: pytest.Session) -> None:
InternalTestSession.set_library_capabilities(library_capabilities)

extracted_context = None
distributed_children = False
if hasattr(session.config, "workerinput"):
from ddtrace._trace.context import Context
from ddtrace.constants import USER_KEEP
Expand All @@ -332,8 +350,10 @@ def pytest_sessionstart(session: pytest.Session) -> None:
"pytest_sessionstart: Could not convert root_span %s to int",
received_root_span,
)
elif hasattr(pytest, "global_worker_itr_results"):
distributed_children = True

InternalTestSession.start(extracted_context)
InternalTestSession.start(distributed_children, extracted_context)

if InternalTestSession.efd_enabled() and not _pytest_version_supports_efd():
log.warning("Early Flake Detection disabled: pytest version is not supported")
Expand Down Expand Up @@ -453,7 +473,7 @@ def _pytest_runtest_protocol_post_yield(item, nextitem, coverage_collector):
InternalTestSuite.mark_itr_skipped(suite_id)
else:
_handle_coverage_dependencies(suite_id)
InternalTestSuite.finish(suite_id)
InternalTestSuite.finish(suite_id)
if nextitem is None or (next_test_id is not None and next_test_id.parent_id.parent_id != module_id):
InternalTestModule.finish(module_id)

Expand Down Expand Up @@ -767,6 +787,14 @@ def _pytest_sessionfinish(session: pytest.Session, exitstatus: int) -> None:
if ModuleCodeCollector.is_installed():
ModuleCodeCollector.uninstall()

# Count ITR skipped tests from workers if we're in the main process
if hasattr(pytest, "global_worker_itr_results"):
skipped_count = pytest.global_worker_itr_results
if skipped_count > 0:
# Update the session's internal _itr_skipped_count so that when _set_itr_tags() is called
# during session finishing, it will use the correct worker-aggregated count
InternalTestSession.set_itr_tags(skipped_count)

InternalTestSession.finish(
force_finish_children=True,
override_status=TestStatus.FAIL if session.exitstatus == pytest.ExitCode.TESTS_FAILED else None,
Expand Down
65 changes: 0 additions & 65 deletions ddtrace/ext/test_visibility/_utils.py

This file was deleted.

Loading
Loading