-
Notifications
You must be signed in to change notification settings - Fork 4
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
[SDTEST-437] Auto test retries for RSpec #213
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d10bd98
move special ci-queue's test suite handling out of the test execution…
anmarchenko 8f80acd
first rough concept of #with_retries method
anmarchenko 3dfd553
first working RSpec test retries prototype
anmarchenko 426a243
more unit tests for test retry classes
anmarchenko c5f88ba
remove the line that should not have been committed
anmarchenko 30dd0cb
remove autogenerated file
anmarchenko abed841
add debug logging
anmarchenko 9e6f62e
test that memoized values are cleared between retries
anmarchenko 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 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
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,28 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "component" | ||
|
||
module Datadog | ||
module CI | ||
module TestRetries | ||
class NullComponent < Component | ||
attr_reader :retry_failed_tests_enabled, :retry_failed_tests_max_attempts, :retry_failed_tests_total_limit | ||
|
||
def initialize | ||
# enabled only by remote settings | ||
@retry_failed_tests_enabled = false | ||
@retry_failed_tests_max_attempts = 0 | ||
@retry_failed_tests_total_limit = 0 | ||
end | ||
|
||
def configure(library_settings) | ||
end | ||
|
||
def with_retries(&block) | ||
no_action = proc {} | ||
yield no_action | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
module Datadog | ||
module CI | ||
module TestRetries | ||
module Strategy | ||
class Base | ||
def should_retry? | ||
false | ||
end | ||
|
||
def record_retry(test_span) | ||
test_span&.set_tag(Ext::Test::TAG_IS_RETRY, "true") | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "base" | ||
|
||
module Datadog | ||
module CI | ||
module TestRetries | ||
module Strategy | ||
class NoRetry < Base | ||
def record_retry(test_span) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "base" | ||
|
||
require_relative "../../ext/test" | ||
|
||
module Datadog | ||
module CI | ||
module TestRetries | ||
module Strategy | ||
class RetryFailed < Base | ||
attr_reader :max_attempts | ||
|
||
def initialize(max_attempts:) | ||
@max_attempts = max_attempts | ||
|
||
@attempts = 0 | ||
@passed_once = false | ||
end | ||
|
||
def should_retry? | ||
@attempts < @max_attempts && !@passed_once | ||
end | ||
|
||
def record_retry(test_span) | ||
super | ||
|
||
@attempts += 1 | ||
@passed_once = true if test_span&.passed? | ||
|
||
Datadog.logger.debug { "Retry Attempts [#{@attempts} / #{@max_attempts}], Passed: [#{@passed_once}]" } | ||
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,25 @@ | ||
module Datadog | ||
module CI | ||
module TestRetries | ||
class NullComponent < Component | ||
@retry_failed_tests_enabled: untyped | ||
|
||
@retry_failed_tests_max_attempts: untyped | ||
|
||
@retry_failed_tests_total_limit: untyped | ||
|
||
attr_reader retry_failed_tests_enabled: untyped | ||
|
||
attr_reader retry_failed_tests_max_attempts: untyped | ||
|
||
attr_reader retry_failed_tests_total_limit: untyped | ||
|
||
def initialize: () -> void | ||
|
||
def configure: (untyped library_settings) -> nil | ||
|
||
def with_retries: () { (untyped) -> untyped } -> untyped | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module Datadog | ||
module CI | ||
module TestRetries | ||
module Strategy | ||
class Base | ||
def should_retry?: () -> bool | ||
|
||
def record_retry: (Datadog::CI::Test test_span) -> void | ||
end | ||
end | ||
end | ||
end | ||
end |
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.
if we're delaying the reporting until after the retries, then isn't it true that we would potentially hide the fact that there were flakes? or will the final trace data include the flake information?
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.
This is hiding reporting (for now) to RSpec formatter that prints the final message and tracks tests that failed (I might fix it in later versions to format retries correctly).
As tested in instrumentation_spec every retry is traced as a separate test span, so the test will be correctly identified as flaky. Also, test suite and test session statuses will be correctly reported as pass.