Skip to content

Commit

Permalink
set retry_new_tests_percentage_limit in TestRetries::Component
Browse files Browse the repository at this point in the history
  • Loading branch information
anmarchenko committed Aug 30, 2024
1 parent b9aadf3 commit 080014c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
6 changes: 4 additions & 2 deletions lib/datadog/ci/test_retries/component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module TestRetries
class Component
attr_reader :retry_failed_tests_enabled, :retry_failed_tests_max_attempts,
:retry_failed_tests_total_limit, :retry_failed_tests_count,
:retry_new_tests_enabled, :retry_new_tests_duration_thresholds
:retry_new_tests_enabled, :retry_new_tests_duration_thresholds, :retry_new_tests_percentage_limit

def initialize(
retry_failed_tests_enabled:,
Expand All @@ -28,6 +28,7 @@ def initialize(

@retry_new_tests_enabled = retry_new_tests_enabled
@retry_new_tests_duration_thresholds = nil
@retry_new_tests_percentage_limit = 0

@mutex = Mutex.new
end
Expand All @@ -38,8 +39,9 @@ def configure(library_settings)

return unless @retry_new_tests_enabled

# setup retrying new tests
# configure retrying new tests
@retry_new_tests_duration_thresholds = library_settings.slow_test_retries
@retry_new_tests_percentage_limit = library_settings.faulty_session_threshold
end

def with_retries(&block)
Expand Down
2 changes: 2 additions & 0 deletions sig/datadog/ci/test_retries/component.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ module Datadog

attr_reader retry_new_tests_duration_thresholds: Datadog::CI::Remote::SlowTestRetries?

attr_reader retry_new_tests_percentage_limit: Integer

@mutex: Thread::Mutex

def initialize: (retry_failed_tests_enabled: bool, retry_failed_tests_max_attempts: Integer, retry_failed_tests_total_limit: Integer, retry_new_tests_enabled: bool) -> void
Expand Down
5 changes: 4 additions & 1 deletion spec/datadog/ci/test_retries/component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
Datadog::CI::Remote::LibrarySettings,
flaky_test_retries_enabled?: remote_flaky_test_retries_enabled,
early_flake_detection_enabled?: remote_early_flake_detection_enabled,
slow_test_retries: slow_test_retries
slow_test_retries: slow_test_retries,
faulty_session_threshold: retry_new_tests_percentage_limit
)
end

let(:retry_failed_tests_enabled) { true }
let(:retry_failed_tests_max_attempts) { 1 }
let(:retry_failed_tests_total_limit) { 12 }
let(:retry_new_tests_enabled) { true }
let(:retry_new_tests_percentage_limit) { 30 }

let(:remote_flaky_test_retries_enabled) { false }
let(:remote_early_flake_detection_enabled) { false }
Expand Down Expand Up @@ -76,6 +78,7 @@

expect(component.retry_new_tests_enabled).to be true
expect(component.retry_new_tests_duration_thresholds.max_attempts_for_duration(1.2)).to eq(10)
expect(component.retry_new_tests_percentage_limit).to eq(retry_new_tests_percentage_limit)
end
end

Expand Down
7 changes: 5 additions & 2 deletions spec/support/contexts/ci_mode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
let(:use_single_threaded_coverage) { false }
let(:flaky_test_retries_enabled) { false }
let(:early_flake_detection_enabled) { false }
let(:faulty_session_threshold) { 30 }

let(:retry_failed_tests_max_attempts) { 5 }
let(:retry_failed_tests_total_limit) { 100 }
Expand Down Expand Up @@ -79,7 +80,8 @@
tests_skipping_enabled?: tests_skipping_enabled,
flaky_test_retries_enabled?: flaky_test_retries_enabled,
early_flake_detection_enabled?: early_flake_detection_enabled,
slow_test_retries: slow_test_retries
slow_test_retries: slow_test_retries,
faulty_session_threshold: faulty_session_threshold
),
# This is for the second call to fetch_library_settings
instance_double(
Expand All @@ -95,7 +97,8 @@
tests_skipping_enabled?: !tests_skipping_enabled,
flaky_test_retries_enabled?: flaky_test_retries_enabled,
early_flake_detection_enabled?: early_flake_detection_enabled,
slow_test_retries: slow_test_retries
slow_test_retries: slow_test_retries,
faulty_session_threshold: faulty_session_threshold
)
)
allow_any_instance_of(Datadog::CI::TestOptimisation::Skippable).to receive(:fetch_skippable_tests).and_return(skippable_tests_response)
Expand Down

0 comments on commit 080014c

Please sign in to comment.