-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #213 from DataDog/anmarchenko/auto_test_retries_rspec
[SDTEST-437] Auto test retries for RSpec
- Loading branch information
Showing
19 changed files
with
589 additions
and
51 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
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.