Skip to content

Commit a966d1a

Browse files
chore(ci_visibility): support Attempt-to-Fix v4 (#13415)
This PR adds: - Sending commit sha in the test management request; - Marking failed attempts to fix with `@test.test_management.attempt_to_fix_passed: false` (previously it was marked with `true` if the attempt was successful, and not marked at all if not successful). ## 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)
1 parent f5f1cd0 commit a966d1a

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

ddtrace/contrib/internal/pytest/_plugin_v2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ def pytest_sessionstart(session: pytest.Session) -> None:
280280
test_impact_analysis="1" if _pytest_version_supports_itr() else None,
281281
test_management_quarantine="1",
282282
test_management_disable="1",
283-
test_management_attempt_to_fix="2" if _pytest_version_supports_attempt_to_fix() else None,
283+
test_management_attempt_to_fix="4" if _pytest_version_supports_attempt_to_fix() else None,
284284
)
285285

286286
InternalTestSession.discover(

ddtrace/internal/ci_visibility/_api_client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,7 @@ def fetch_test_management_tests(self) -> t.Optional[t.Dict[InternalTestId, TestP
592592
"attributes": {
593593
"repository_url": self._git_data.repository_url,
594594
"commit_message": self._git_data.commit_message,
595+
"sha": self._git_data.commit_sha,
595596
},
596597
}
597598
}

ddtrace/internal/ci_visibility/api/_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,8 +554,8 @@ def attempt_to_fix_finish_retry(
554554

555555
if all_failed:
556556
retry_test.set_tag(TEST_HAS_FAILED_ALL_RETRIES, True)
557-
elif all_passed:
558-
retry_test.set_tag(TEST_ATTEMPT_TO_FIX_PASSED, True)
557+
558+
retry_test.set_tag(TEST_ATTEMPT_TO_FIX_PASSED, all_passed)
559559

560560
retry_test.finish_test(status, exc_info=exc_info)
561561

tests/contrib/pytest/test_pytest_attempt_to_fix.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def test_attempt_to_fix_quarantined_test_fail(self):
138138
assert span.get_tag("test.test_management.is_quarantined") == "true"
139139
assert span.get_tag("test.status") == "fail"
140140

141-
assert test_spans[-1].get_tag("test.test_management.attempt_to_fix_passed") is None
141+
assert test_spans[-1].get_tag("test.test_management.attempt_to_fix_passed") == "false"
142142
assert test_spans[-1].get_tag("test.has_failed_all_retries") == "true"
143143

144144
def test_attempt_to_fix_quarantined_test_flaky(self):
@@ -158,7 +158,7 @@ def test_attempt_to_fix_quarantined_test_flaky(self):
158158
assert span.get_tag("test.test_management.is_quarantined") == "true"
159159
assert span.get_tag("test.status") == ("pass" if i == 10 else "fail")
160160

161-
assert test_spans[-1].get_tag("test.test_management.attempt_to_fix_passed") is None
161+
assert test_spans[-1].get_tag("test.test_management.attempt_to_fix_passed") == "false"
162162
assert test_spans[-1].get_tag("test.has_failed_all_retries") is None
163163

164164
def test_attempt_to_fix_disabled_test(self):
@@ -221,7 +221,7 @@ def test_attempt_to_fix_active_test_fail(self):
221221
assert span.get_tag("test.test_management.is_test_disabled") is None
222222
assert span.get_tag("test.status") == "fail"
223223

224-
assert test_spans[-1].get_tag("test.test_management.attempt_to_fix_passed") is None
224+
assert test_spans[-1].get_tag("test.test_management.attempt_to_fix_passed") == "false"
225225
assert test_spans[-1].get_tag("test.has_failed_all_retries") == "true"
226226

227227
def test_attempt_to_fix_active_test_skip(self):
@@ -242,7 +242,7 @@ def test_attempt_to_fix_active_test_skip(self):
242242
assert span.get_tag("test.test_management.is_test_disabled") is None
243243
assert span.get_tag("test.status") == "skip"
244244

245-
assert test_spans[-1].get_tag("test.test_management.attempt_to_fix_passed") is None
245+
assert test_spans[-1].get_tag("test.test_management.attempt_to_fix_passed") == "false"
246246
assert test_spans[-1].get_tag("test.has_failed_all_retries") is None
247247

248248
def test_pytest_attempt_to_fix_junit_xml_active(self):
@@ -319,5 +319,5 @@ def test_attempt_to_fix_itr_skipped_test(self):
319319
assert span.get_tag("test.test_management.is_test_disabled") == "true"
320320
assert span.get_tag("test.status") == "fail"
321321

322-
assert attempt_to_fix_spans[-1].get_tag("test.test_management.attempt_to_fix_passed") is None
322+
assert attempt_to_fix_spans[-1].get_tag("test.test_management.attempt_to_fix_passed") == "false"
323323
assert attempt_to_fix_spans[-1].get_tag("test.has_failed_all_retries") == "true"

0 commit comments

Comments
 (0)