-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a first version of retry strategy for new tests
- Loading branch information
1 parent
0adab10
commit 2cfdeb6
Showing
7 changed files
with
98 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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 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 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,41 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "base" | ||
|
||
require_relative "../../ext/test" | ||
|
||
module Datadog | ||
module CI | ||
module TestRetries | ||
module Strategy | ||
# retry every new test up to 10 times (early flake detection) | ||
class RetryNew < Base | ||
def initialize(duration_thresholds:) | ||
@duration_thresholds = duration_thresholds | ||
@attempts = 0 | ||
# will be changed based on test span duration | ||
@max_attempts = 10 | ||
end | ||
|
||
def should_retry? | ||
@attempts < @max_attempts | ||
end | ||
|
||
def record_retry(test_span) | ||
super | ||
|
||
@attempts += 1 | ||
|
||
Datadog.logger.debug { "Retry Attempts [#{@attempts} / #{@max_attempts}]" } | ||
end | ||
|
||
def record_duration(duration) | ||
@max_attempts = @duration_thresholds.max_attempts_for_duration(duration) | ||
|
||
Datadog.logger.debug { "Recorded test duration of [#{@duration}], new Max Attempts value is [#{@max_attempts}]" } | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains 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 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 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,16 @@ | ||
module Datadog | ||
module CI | ||
module TestRetries | ||
module Strategy | ||
class RetryNew < Base | ||
@duration_thresholds: Datadog::CI::Remote::SlowTestRetries | ||
|
||
@attempts: Integer | ||
@max_attempts: Integer | ||
|
||
def initialize: (duration_thresholds: Datadog::CI::Remote::SlowTestRetries) -> void | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains 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