Class: Datadog::CI::TestRetries::Driver::RetryFailed

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#record_duration

Constructor Details

#initialize(max_attempts:) ⇒ RetryFailed

Returns a new instance of RetryFailed.



14
15
16
17
18
19
# File 'lib/datadog/ci/test_retries/driver/retry_failed.rb', line 14

def initialize(max_attempts:)
  @max_attempts = max_attempts

  @attempts = 0
  @passed_once = false
end

Instance Attribute Details

#max_attemptsObject (readonly)

Returns the value of attribute max_attempts.



12
13
14
# File 'lib/datadog/ci/test_retries/driver/retry_failed.rb', line 12

def max_attempts
  @max_attempts
end

Instance Method Details

#record_retry(test_span) ⇒ Object



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

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

#should_retry?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/datadog/ci/test_retries/driver/retry_failed.rb', line 21

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