Class: Datadog::CI::Remote::LibrarySettings
- Inherits:
-
Object
- Object
- Datadog::CI::Remote::LibrarySettings
- Defined in:
- lib/datadog/ci/remote/library_settings.rb
Overview
Wrapper around the settings HTTP response
Class Method Summary collapse
Instance Method Summary collapse
- #attempt_to_fix_retries_count ⇒ Object
- #code_coverage_enabled? ⇒ Boolean
- #early_flake_detection_enabled? ⇒ Boolean
- #faulty_session_threshold ⇒ Object
- #flaky_test_retries_enabled? ⇒ Boolean
- #impacted_tests_enabled? ⇒ Boolean
- #itr_enabled? ⇒ Boolean
- #known_tests_enabled? ⇒ Boolean
- #ok? ⇒ Boolean
- #payload ⇒ Object
- #require_git? ⇒ Boolean
- #slow_test_retries ⇒ Object
- #test_management_enabled? ⇒ Boolean
- #tests_skipping_enabled? ⇒ Boolean
Class Method Details
.from_http_response(http_response) ⇒ Object
17 18 19 |
# File 'lib/datadog/ci/remote/library_settings.rb', line 17 def self.from_http_response(http_response) new(http_response, nil) end |
.from_json(json) ⇒ Object
21 22 23 |
# File 'lib/datadog/ci/remote/library_settings.rb', line 21 def self.from_json(json) new(nil, json) end |
Instance Method Details
#attempt_to_fix_retries_count ⇒ Object
144 145 146 147 148 149 150 |
# File 'lib/datadog/ci/remote/library_settings.rb', line 144 def attempt_to_fix_retries_count return @attempt_to_fix_retries_count if defined?(@attempt_to_fix_retries_count) @attempt_to_fix_retries_count = test_management_payload.fetch( Ext::Transport::DD_API_SETTINGS_RESPONSE_ATTEMPT_TO_FIX_RETRIES_KEY, nil ) end |
#code_coverage_enabled? ⇒ Boolean
70 71 72 73 74 75 76 |
# File 'lib/datadog/ci/remote/library_settings.rb', line 70 def code_coverage_enabled? return @code_coverage_enabled if defined?(@code_coverage_enabled) @code_coverage_enabled = Utils::Parsing.convert_to_bool( payload.fetch(Ext::Transport::DD_API_SETTINGS_RESPONSE_CODE_COVERAGE_KEY, false) ) end |
#early_flake_detection_enabled? ⇒ Boolean
96 97 98 99 100 101 102 |
# File 'lib/datadog/ci/remote/library_settings.rb', line 96 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( early_flake_detection_payload.fetch(Ext::Transport::DD_API_SETTINGS_RESPONSE_ENABLED_KEY, false) ) end |
#faulty_session_threshold ⇒ Object
128 129 130 131 132 133 134 |
# File 'lib/datadog/ci/remote/library_settings.rb', line 128 def faulty_session_threshold return @faulty_session_threshold if defined?(@faulty_session_threshold) @faulty_session_threshold = early_flake_detection_payload.fetch( Ext::Transport::DD_API_SETTINGS_RESPONSE_FAULTY_SESSION_THRESHOLD_KEY, 0 ) end |
#flaky_test_retries_enabled? ⇒ Boolean
86 87 88 89 90 91 92 93 94 |
# File 'lib/datadog/ci/remote/library_settings.rb', line 86 def flaky_test_retries_enabled? return @flaky_test_retries_enabled if defined?(@flaky_test_retries_enabled) @flaky_test_retries_enabled = Utils::Parsing.convert_to_bool( payload.fetch( Ext::Transport::DD_API_SETTINGS_RESPONSE_FLAKY_TEST_RETRIES_KEY, false ) ) end |
#impacted_tests_enabled? ⇒ Boolean
112 113 114 115 116 117 118 |
# File 'lib/datadog/ci/remote/library_settings.rb', line 112 def impacted_tests_enabled? return @impacted_tests_enabled if defined?(@impacted_tests_enabled) @impacted_tests_enabled = Utils::Parsing.convert_to_bool( payload.fetch(Ext::Transport::DD_API_SETTINGS_RESPONSE_IMPACTED_TESTS_ENABLED_KEY, false) ) end |
#itr_enabled? ⇒ Boolean
62 63 64 65 66 67 68 |
# File 'lib/datadog/ci/remote/library_settings.rb', line 62 def itr_enabled? return @itr_enabled if defined?(@itr_enabled) @itr_enabled = Utils::Parsing.convert_to_bool( payload.fetch(Ext::Transport::DD_API_SETTINGS_RESPONSE_ITR_ENABLED_KEY, false) ) end |
#known_tests_enabled? ⇒ Boolean
104 105 106 107 108 109 110 |
# File 'lib/datadog/ci/remote/library_settings.rb', line 104 def known_tests_enabled? return @known_tests_enabled if defined?(@known_tests_enabled) @known_tests_enabled = Utils::Parsing.convert_to_bool( payload.fetch(Ext::Transport::DD_API_SETTINGS_RESPONSE_KNOWN_TESTS_ENABLED_KEY, false) ) end |
#ok? ⇒ Boolean
25 26 27 28 |
# File 'lib/datadog/ci/remote/library_settings.rb', line 25 def ok? resp = @http_response !resp.nil? && resp.ok? end |
#payload ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/datadog/ci/remote/library_settings.rb', line 30 def payload cached = @json return cached unless cached.nil? resp = @http_response return @json = default_payload if resp.nil? || !ok? begin @json = JSON.parse(resp.payload).dig(*Ext::Transport::DD_API_SETTINGS_RESPONSE_DIG_KEYS) || default_payload rescue JSON::ParserError => e Datadog.logger.error("Failed to parse settings response payload: #{e}. Payload was: #{resp.payload}") Transport::Telemetry.api_requests_errors( Ext::Telemetry::METRIC_GIT_REQUESTS_SETTINGS_ERRORS, 1, error_type: "invalid_json", status_code: nil ) @json = default_payload end end |
#require_git? ⇒ Boolean
54 55 56 57 58 59 60 |
# File 'lib/datadog/ci/remote/library_settings.rb', line 54 def require_git? return @require_git if defined?(@require_git) @require_git = Utils::Parsing.convert_to_bool( payload.fetch(Ext::Transport::DD_API_SETTINGS_RESPONSE_REQUIRE_GIT_KEY, false) ) end |
#slow_test_retries ⇒ Object
120 121 122 123 124 125 126 |
# File 'lib/datadog/ci/remote/library_settings.rb', line 120 def slow_test_retries return @slow_test_retries if defined?(@slow_test_retries) @slow_test_retries = SlowTestRetries.new( early_flake_detection_payload.fetch(Ext::Transport::DD_API_SETTINGS_RESPONSE_SLOW_TEST_RETRIES_KEY, {}) ) end |
#test_management_enabled? ⇒ Boolean
136 137 138 139 140 141 142 |
# File 'lib/datadog/ci/remote/library_settings.rb', line 136 def test_management_enabled? return @test_management_enabled if defined?(@test_management_enabled) @test_management_enabled = Utils::Parsing.convert_to_bool( test_management_payload.fetch(Ext::Transport::DD_API_SETTINGS_RESPONSE_ENABLED_KEY, false) ) end |
#tests_skipping_enabled? ⇒ Boolean
78 79 80 81 82 83 84 |
# File 'lib/datadog/ci/remote/library_settings.rb', line 78 def tests_skipping_enabled? return @tests_skipping_enabled if defined?(@tests_skipping_enabled) @tests_skipping_enabled = Utils::Parsing.convert_to_bool( payload.fetch(Ext::Transport::DD_API_SETTINGS_RESPONSE_TESTS_SKIPPING_KEY, false) ) end |