Skip to content

Commit

Permalink
move enabled and slow_test_retries keys to constants
Browse files Browse the repository at this point in the history
  • Loading branch information
anmarchenko committed Aug 30, 2024
1 parent a8ed9a9 commit 063dea7
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
3 changes: 3 additions & 0 deletions lib/datadog/ci/ext/transport.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ module Transport
DD_API_SETTINGS_RESPONSE_REQUIRE_GIT_KEY = "require_git"
DD_API_SETTINGS_RESPONSE_FLAKY_TEST_RETRIES_KEY = "flaky_test_retries_enabled"
DD_API_SETTINGS_RESPONSE_EARLY_FLAKE_DETECTION_KEY = "early_flake_detection"
DD_API_SETTINGS_RESPONSE_ENABLED_KEY = "enabled"
DD_API_SETTINGS_RESPONSE_SLOW_TEST_RETRIES_KEY = "early_flake_detection"
DD_API_SETTINGS_RESPONSE_FAULTY_SESSION_THRESHOLD_KEY = "faulty_session_threshold"
DD_API_SETTINGS_RESPONSE_DEFAULT = {DD_API_SETTINGS_RESPONSE_ITR_ENABLED_KEY => false}.freeze

DD_API_GIT_SEARCH_COMMITS_PATH = "/api/v2/git/repository/search_commits"
Expand Down
16 changes: 9 additions & 7 deletions lib/datadog/ci/remote/library_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,25 +94,27 @@ def early_flake_detection_enabled?
return @early_flake_detection_enabled if defined?(@early_flake_detection_enabled)

@early_flake_detection_enabled = Utils::Parsing.convert_to_bool(
payload.fetch(
Ext::Transport::DD_API_SETTINGS_RESPONSE_EARLY_FLAKE_DETECTION_KEY,
{}
).fetch("enabled", false)
early_flake_detection_payload.fetch(Ext::Transport::DD_API_SETTINGS_RESPONSE_ENABLED_KEY, false)
)
end

def slow_test_retries
return @slow_test_retries if defined?(@slow_test_retries)

@slow_test_retries = SlowTestRetries.new(
payload
.fetch(Ext::Transport::DD_API_SETTINGS_RESPONSE_EARLY_FLAKE_DETECTION_KEY, {})
.fetch("slow_test_retries", {})
early_flake_detection_payload.fetch(Ext::Transport::DD_API_SETTINGS_RESPONSE_SLOW_TEST_RETRIES_KEY, {})
)
end

private

def early_flake_detection_payload
payload.fetch(
Ext::Transport::DD_API_SETTINGS_RESPONSE_EARLY_FLAKE_DETECTION_KEY,
{}
)
end

def default_payload
Ext::Transport::DD_API_SETTINGS_RESPONSE_DEFAULT
end
Expand Down
6 changes: 6 additions & 0 deletions sig/datadog/ci/ext/transport.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ module Datadog

DD_API_SETTINGS_RESPONSE_EARLY_FLAKE_DETECTION_KEY: "early_flake_detection"

DD_API_SETTINGS_RESPONSE_ENABLED_KEY: "enabled"

DD_API_SETTINGS_RESPONSE_SLOW_TEST_RETRIES_KEY: "slow_test_retries"

DD_API_SETTINGS_RESPONSE_FAULTY_SESSION_THRESHOLD_KEY: "faulty_session_threshold"

DD_API_SETTINGS_RESPONSE_DEFAULT: Hash[String, untyped]

DD_API_GIT_SEARCH_COMMITS_PATH: "/api/v2/git/repository/search_commits"
Expand Down
2 changes: 2 additions & 0 deletions sig/datadog/ci/remote/library_settings.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ module Datadog

private

def early_flake_detection_payload: () -> Hash[String, untyped]

def default_payload: () -> Hash[String, untyped]
end
end
Expand Down

0 comments on commit 063dea7

Please sign in to comment.