-
Notifications
You must be signed in to change notification settings - Fork 481
refactor(ci_visibility): efd refactor #12983
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
Closed
Closed
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| """Settings for Early Flake Detection. | ||
|
|
||
| This module contains settings classes for the Early Flake Detection feature. | ||
| """ | ||
|
|
||
| import dataclasses | ||
| from typing import List | ||
| from typing import Tuple | ||
|
|
||
| from ddtrace.internal.logger import get_logger | ||
|
|
||
|
|
||
| log = get_logger(__name__) | ||
|
|
||
|
|
||
| @dataclasses.dataclass(frozen=True) | ||
| class EarlyFlakeDetectionSettings: | ||
| """Settings for Early Flake Detection. | ||
|
|
||
| This class encapsulates the settings for the Early Flake Detection feature, which | ||
| includes configuration for retry counts based on test duration and thresholds for | ||
| determining faulty sessions. | ||
|
|
||
| Attributes: | ||
| enabled: Whether Early Flake Detection is enabled | ||
| slow_test_retries_5s: Maximum retries for tests that take less than 5 seconds | ||
| slow_test_retries_10s: Maximum retries for tests that take less than 10 seconds | ||
| slow_test_retries_30s: Maximum retries for tests that take less than 30 seconds | ||
| slow_test_retries_5m: Maximum retries for tests that take less than 5 minutes | ||
| faulty_session_threshold: Percentage threshold for determining if a session is faulty | ||
| """ | ||
|
|
||
| enabled: bool = False | ||
| slow_test_retries_5s: int = 10 | ||
| slow_test_retries_10s: int = 5 | ||
| slow_test_retries_30s: int = 3 | ||
| slow_test_retries_5m: int = 2 | ||
| faulty_session_threshold: int = 30 | ||
|
|
||
| def get_threshold_definitions(self) -> List[Tuple[float, int]]: | ||
| """Get the duration thresholds and their associated retry limits. | ||
|
|
||
| Returns: | ||
| A list of tuples (duration_threshold, retry_limit) sorted by duration | ||
| """ | ||
| return [ | ||
| (5.0, self.slow_test_retries_5s), # ≤ 5 seconds tests | ||
| (10.0, self.slow_test_retries_10s), # ≤ 10 seconds tests | ||
| (30.0, self.slow_test_retries_30s), # ≤ 30 seconds tests | ||
| (300.0, self.slow_test_retries_5m), # ≤ 5 minutes tests | ||
| ] | ||
|
|
||
| def get_max_retries_for_duration(self, duration_seconds: float) -> int: | ||
| """Get the maximum number of retries allowed for a test with the given duration. | ||
|
|
||
| Args: | ||
| duration_seconds: The duration of the test in seconds | ||
|
|
||
| Returns: | ||
| The maximum number of retries allowed for this test | ||
| """ | ||
| for threshold, retries in self.get_threshold_definitions(): | ||
| if duration_seconds <= threshold: | ||
| return retries | ||
| return 0 # No retries for tests longer than 5 minutes | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⚪ Code Quality Violation
Class EarlyFlakeDetectionSettings should have an init method (...read more)
Ensure that a class has an
__init__method. This check is bypassed when the class is a data class (annotated with @DataClass).