From 080014c4f5ed82ffc380d5cfe89d6f1dac9b2986 Mon Sep 17 00:00:00 2001 From: Andrey Date: Fri, 30 Aug 2024 14:50:07 +0200 Subject: [PATCH] set retry_new_tests_percentage_limit in TestRetries::Component --- lib/datadog/ci/test_retries/component.rb | 6 ++++-- sig/datadog/ci/test_retries/component.rbs | 2 ++ spec/datadog/ci/test_retries/component_spec.rb | 5 ++++- spec/support/contexts/ci_mode.rb | 7 +++++-- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/datadog/ci/test_retries/component.rb b/lib/datadog/ci/test_retries/component.rb index 8fda573e..007728de 100644 --- a/lib/datadog/ci/test_retries/component.rb +++ b/lib/datadog/ci/test_retries/component.rb @@ -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:, @@ -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 @@ -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) diff --git a/sig/datadog/ci/test_retries/component.rbs b/sig/datadog/ci/test_retries/component.rbs index 9a9e2988..66449ae3 100644 --- a/sig/datadog/ci/test_retries/component.rbs +++ b/sig/datadog/ci/test_retries/component.rbs @@ -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 diff --git a/spec/datadog/ci/test_retries/component_spec.rb b/spec/datadog/ci/test_retries/component_spec.rb index 567861ea..43586d96 100644 --- a/spec/datadog/ci/test_retries/component_spec.rb +++ b/spec/datadog/ci/test_retries/component_spec.rb @@ -6,7 +6,8 @@ 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 @@ -14,6 +15,7 @@ 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 } @@ -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 diff --git a/spec/support/contexts/ci_mode.rb b/spec/support/contexts/ci_mode.rb index 35ac66a1..58dd4e2c 100644 --- a/spec/support/contexts/ci_mode.rb +++ b/spec/support/contexts/ci_mode.rb @@ -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 } @@ -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( @@ -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)