Class: Datadog::CI::Remote::SlowTestRetries

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog/ci/remote/slow_test_retries.rb

Overview

Parses “slow_test_retries” payload for early flake detection settings

Example payload:

"5s" => 10,
"10s" => 5,
"30s" => 3,
"5m" => 2

The payload above means that for tests that run less than 5 seconds, we should retry them 10 times, for tests that run less than 10 seconds, we should retry them 5 times, and so on.

Defined Under Namespace

Classes: Entry

Constant Summary collapse

DURATION_MEASURES =
{
  "s" => 1,
  "m" => 60
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payload) ⇒ SlowTestRetries

Returns a new instance of SlowTestRetries.



28
29
30
# File 'lib/datadog/ci/remote/slow_test_retries.rb', line 28

def initialize(payload)
  @entries = parse(payload)
end

Instance Attribute Details

#entriesObject (readonly)

Returns the value of attribute entries.



19
20
21
# File 'lib/datadog/ci/remote/slow_test_retries.rb', line 19

def entries
  @entries
end

Instance Method Details

#max_attempts_for_duration(duration) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/datadog/ci/remote/slow_test_retries.rb', line 32

def max_attempts_for_duration(duration)
  @entries.each do |entry|
    return entry.max_attempts if duration < entry.duration
  end

  0
end