Class: Datadog::CI::TestRetries::Driver::RetryFlakyFixed

Inherits:
Base
  • Object
show all
Defined in:
lib/datadog/ci/test_retries/driver/retry_flaky_fixed.rb

Overview

Retries tests marked as “attempt to fix” to verify the fix works consistently. Stops early after the first failed execution (fix did not work).

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#mark_as_retry, #record_duration, #tracks_retry_results?

Constructor Details

#initialize(test_span, max_attempts:) ⇒ RetryFlakyFixed

Returns a new instance of RetryFlakyFixed.



16
17
18
19
20
# File 'lib/datadog/ci/test_retries/driver/retry_flaky_fixed.rb', line 16

def initialize(test_span, max_attempts:)
  @attempts = 0
  @max_attempts = max_attempts
  @failed_once = !!test_span&.failed?
end

Instance Attribute Details

#max_attemptsObject (readonly)

Returns the value of attribute max_attempts.



14
15
16
# File 'lib/datadog/ci/test_retries/driver/retry_flaky_fixed.rb', line 14

def max_attempts
  @max_attempts
end

Instance Method Details

#record_retry(test_span) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/datadog/ci/test_retries/driver/retry_flaky_fixed.rb', line 26

def record_retry(test_span)
  super

  @attempts += 1
  @failed_once = true if test_span&.failed?

  Datadog.logger.debug { "Retry Attempts [#{@attempts} / #{@max_attempts}], Failed: [#{@failed_once}]" }
end

#retry_reasonObject



35
36
37
# File 'lib/datadog/ci/test_retries/driver/retry_flaky_fixed.rb', line 35

def retry_reason
  Ext::Test::RetryReason::RETRY_FLAKY_FIXED
end

#should_retry?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/datadog/ci/test_retries/driver/retry_flaky_fixed.rb', line 22

def should_retry?
  @attempts < @max_attempts && !@failed_once
end