Skip to content
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
5 changes: 5 additions & 0 deletions ddtrace/internal/ci_visibility/recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ def _check_enabled_features(self):
# type: () -> Tuple[bool, bool]
if not self._app_key:
return False, False

# DEV: Remove this ``if`` once ITR is in GA
if not ddconfig._ci_visibility_intelligent_testrunner_enabled:
return False, False

url = "https://api.%s/api/v2/libraries/tests/services/setting" % self._dd_site
_headers = {"dd-api-key": self._api_key, "dd-application-key": self._app_key}
payload = {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
fixes:
- |
CI Visibility: This fix resolves an issue where the tracer was doing extra requests if the ``DD_CIVISIBILITY_ITR_ENABLED`` env var was not set.
18 changes: 17 additions & 1 deletion tests/ci_visibility/test_ci_visibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,24 @@ def test_ci_visibility_service_enable():


@mock.patch("ddtrace.internal.ci_visibility.recorder._do_request")
def test_ci_visibility_service_enable_with_app_key(_do_request):
def test_ci_visibility_service_enable_with_app_key_and_itr_disabled(_do_request):
with override_env(dict(DD_API_KEY="foobar.baz", DD_APP_KEY="foobar")):
_do_request.return_value = Response(
status=200,
body='{"data":{"id":"1234","type":"ci_app_tracers_test_service_settings","attributes":'
'{"code_coverage":true,"tests_skipping":true}}}',
)
CIVisibility.enable(service="test-service")
assert CIVisibility._instance._code_coverage_enabled_by_api is False
assert CIVisibility._instance._test_skipping_enabled_by_api is False
CIVisibility.disable()


@mock.patch("ddtrace.internal.ci_visibility.recorder._do_request")
def test_ci_visibility_service_enable_with_app_key_and_itr_enabled(_do_request):

with override_env(dict(DD_API_KEY="foobar.baz", DD_APP_KEY="foobar", DD_CIVISIBILITY_ITR_ENABLED="1")):
ddtrace.internal.ci_visibility.recorder.ddconfig = ddtrace.settings.Config()
_do_request.return_value = Response(
status=200,
body='{"data":{"id":"1234","type":"ci_app_tracers_test_service_settings","attributes":'
Expand Down