Skip to content

Commit fef9fb6

Browse files
chore(ci_visibility): fetch test data concurrently [recreated] (#12993)
Recreating #12972 because we needed to revert PRs that were accidentally merged prematurely due to required status checks getting deleted. ## 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) Co-authored-by: Vítor De Araújo <[email protected]>
1 parent 306489d commit fef9fb6

File tree

1 file changed

+40
-31
lines changed

1 file changed

+40
-31
lines changed

Diff for: ddtrace/internal/ci_visibility/recorder.py

+40-31
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from concurrent.futures import ThreadPoolExecutor
12
import json
23
import os
34
from pathlib import Path
@@ -607,31 +608,46 @@ def _start_service(self) -> None:
607608
tracer_filters += [TraceCiVisibilityFilter(self._tags, self._service)] # type: ignore[arg-type]
608609
self.tracer.configure(trace_processors=tracer_filters)
609610

610-
if self.test_skipping_enabled():
611-
self._fetch_tests_to_skip()
612-
if self._itr_data is None:
613-
log.warning("Failed to fetch skippable items, no tests will be skipped.")
614-
return
615-
log.info("Intelligent Test Runner skipping level: %s", "suite" if self._suite_skipping_mode else "test")
616-
log.info("Skippable items fetched: %s", len(self._itr_data.skippable_items))
617-
log.info("ITR correlation ID: %s", self._itr_data.correlation_id)
618-
619-
if CIVisibility.is_efd_enabled():
620-
known_test_ids = self._fetch_known_tests()
621-
if known_test_ids is None:
622-
log.warning("Failed to fetch unique tests for Early Flake Detection")
611+
def _task_fetch_tests_to_skip():
612+
if self.test_skipping_enabled():
613+
self._fetch_tests_to_skip()
614+
if self._itr_data is None:
615+
log.warning("Failed to fetch skippable items, no tests will be skipped.")
616+
return
617+
log.info("Intelligent Test Runner skipping level: %s", "suite" if self._suite_skipping_mode else "test")
618+
log.info("Skippable items fetched: %s", len(self._itr_data.skippable_items))
619+
log.info("ITR correlation ID: %s", self._itr_data.correlation_id)
620+
621+
def _task_fetch_known_tests():
622+
if CIVisibility.is_efd_enabled():
623+
known_test_ids = self._fetch_known_tests()
624+
if known_test_ids is None:
625+
log.warning("Failed to fetch unique tests for Early Flake Detection")
626+
else:
627+
self._known_test_ids = known_test_ids
628+
log.info("Unique tests fetched for Early Flake Detection: %s", len(self._known_test_ids))
623629
else:
624-
self._known_test_ids = known_test_ids
625-
log.info("Unique tests fetched for Early Flake Detection: %s", len(self._known_test_ids))
626-
else:
627-
if (
628-
self._api_settings.early_flake_detection.enabled
629-
and not ddconfig._test_visibility_early_flake_detection_enabled
630-
):
631-
log.warning(
632-
"Early Flake Detection is enabled by API but disabled by "
633-
"DD_TEST_VISIBILITY_EARLY_FLAKE_DETECTION_ENABLED environment variable"
634-
)
630+
if (
631+
self._api_settings.early_flake_detection.enabled
632+
and not ddconfig._test_visibility_early_flake_detection_enabled
633+
):
634+
log.warning(
635+
"Early Flake Detection is enabled by API but disabled by "
636+
"DD_TEST_VISIBILITY_EARLY_FLAKE_DETECTION_ENABLED environment variable"
637+
)
638+
639+
def _task_fetch_test_management_tests():
640+
if self._api_settings.test_management.enabled:
641+
test_properties = self._fetch_test_management_tests()
642+
if test_properties is None:
643+
log.warning("Failed to fetch quarantined tests from Test Management")
644+
else:
645+
self._test_properties = test_properties
646+
647+
with ThreadPoolExecutor() as pool:
648+
pool.submit(_task_fetch_tests_to_skip)
649+
pool.submit(_task_fetch_known_tests)
650+
pool.submit(_task_fetch_test_management_tests)
635651

636652
if self._api_settings.flaky_test_retries_enabled and not asbool(
637653
os.environ.get("DD_CIVISIBILITY_FLAKY_RETRY_ENABLED", True)
@@ -641,13 +657,6 @@ def _start_service(self) -> None:
641657
"DD_CIVISIBILITY_FLAKY_RETRY_ENABLED environment variable"
642658
)
643659

644-
if self._api_settings.test_management.enabled:
645-
test_properties = self._fetch_test_management_tests()
646-
if test_properties is None:
647-
log.warning("Failed to fetch quarantined tests from Test Management")
648-
else:
649-
self._test_properties = test_properties
650-
651660
def _stop_service(self) -> None:
652661
if self._should_upload_git_metadata and not self._git_client.metadata_upload_finished():
653662
log.debug("git metadata upload still in progress, waiting before shutting down")

0 commit comments

Comments
 (0)