Skip to content

Commit

Permalink
add DD_CIVISIBILITY_EARLY_FLAKE_DETECTION_ENABLED killswitch to settings
Browse files Browse the repository at this point in the history
  • Loading branch information
anmarchenko committed Aug 29, 2024
1 parent f0d2445 commit 57a0d01
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/datadog/ci/configuration/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ def self.add_settings!(base)
o.default 1000
end

option :retry_new_tests_enabled do |o|
o.type :bool
o.env CI::Ext::Settings::ENV_RETRY_NEW_TESTS_ENABLED
o.default true
end

define_method(:instrument) do |integration_name, options = {}, &block|
return unless enabled

Expand Down
1 change: 1 addition & 0 deletions lib/datadog/ci/ext/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module Settings
ENV_RETRY_FAILED_TESTS_ENABLED = "DD_CIVISIBILITY_FLAKY_RETRY_ENABLED"
ENV_RETRY_FAILED_TESTS_MAX_ATTEMPTS = "DD_CIVISIBILITY_FLAKY_RETRY_COUNT"
ENV_RETRY_FAILED_TESTS_TOTAL_LIMIT = "DD_CIVISIBILITY_TOTAL_FLAKY_RETRY_COUNT"
ENV_RETRY_NEW_TESTS_ENABLED = "DD_CIVISIBILITY_EARLY_FLAKE_DETECTION_ENABLED"

# Source: https://docs.datadoghq.com/getting_started/site/
DD_SITE_ALLOWLIST = %w[
Expand Down
1 change: 1 addition & 0 deletions sig/datadog/ci/ext/settings.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module Datadog
ENV_RETRY_FAILED_TESTS_ENABLED: String
ENV_RETRY_FAILED_TESTS_MAX_ATTEMPTS: String
ENV_RETRY_FAILED_TESTS_TOTAL_LIMIT: String
ENV_RETRY_NEW_TESTS_ENABLED: String

DD_SITE_ALLOWLIST: Array[String]
end
Expand Down
41 changes: 41 additions & 0 deletions spec/datadog/ci/configuration/settings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,47 @@ def patcher
end
end

describe "#retry_new_tests_enabled" do
subject(:retry_new_tests_enabled) { settings.ci.retry_new_tests_enabled }

it { is_expected.to be true }

context "when #{Datadog::CI::Ext::Settings::ENV_RETRY_NEW_TESTS_ENABLED}" do
around do |example|
ClimateControl.modify(Datadog::CI::Ext::Settings::ENV_RETRY_NEW_TESTS_ENABLED => enable) do
example.run
end
end

context "is not defined" do
let(:enable) { nil }

it { is_expected.to be true }
end

context "is set to true" do
let(:enable) { "true" }

it { is_expected.to be true }
end

context "is set to false" do
let(:enable) { "false" }

it { is_expected.to be false }
end
end
end

describe "#retry_new_tests_enabled=" do
it "updates the #retry_failed_tests_enabled setting" do
expect { settings.ci.retry_new_tests_enabled = false }
.to change { settings.ci.retry_new_tests_enabled }
.from(true)
.to(false)
end
end

describe "#instrument" do
let(:integration_name) { :fake }

Expand Down

0 comments on commit 57a0d01

Please sign in to comment.