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 errors while fetching skippable test data [backport 2.9] #10521

Merged
merged 3 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions ddtrace/internal/ci_visibility/recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,12 @@ def _fetch_tests_to_skip(self, skipping_mode: str):
self._test_suites_to_skip = []
self._tests_to_skip = defaultdict(list)

except Exception:
log.warning("Error retrieving skippable test data, no tests will be skipped", exc_info=True)
error_type = ERROR_TYPES.UNKNOWN
self._test_suites_to_skip = []
self._tests_to_skip = defaultdict(list)

finally:
record_itr_skippable_request(
sw.elapsed() * 1000,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
fixes:
- |
CI Visibility: This fix resolves an issue where exceptions other than timeouts and connection errors raised
while fetching the list of skippable tests for ITR were not being handled correctly and caused the tracer to
crash.
19 changes: 19 additions & 0 deletions tests/ci_visibility/test_ci_visibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,25 @@ def test_ci_visibility_service_skippable_timeout(_do_request, _check_enabled_fea
CIVisibility.disable()


@mock.patch(
"ddtrace.internal.ci_visibility.recorder.CIVisibility._check_enabled_features",
return_value=_CIVisibilitySettings(True, True, False, True),
)
@mock.patch("ddtrace.internal.ci_visibility.recorder._do_request", side_effect=ValueError)
def test_ci_visibility_service_skippable_other_error(_do_request, _check_enabled_features):
with override_env(
dict(
DD_API_KEY="foobar.baz",
DD_APP_KEY="foobar",
DD_CIVISIBILITY_AGENTLESS_ENABLED="1",
)
), _dummy_noop_git_client():
ddtrace.internal.ci_visibility.recorder.ddconfig = _get_default_civisibility_ddconfig()
CIVisibility.enable(service="test-service")
assert CIVisibility._instance._test_suites_to_skip == []
CIVisibility.disable()


@mock.patch("ddtrace.internal.ci_visibility.recorder._do_request")
def test_ci_visibility_service_enable_with_itr_enabled(_do_request):
with override_env(
Expand Down
Loading