Class: Datadog::CI::TestVisibility::KnownTests
- Inherits:
-
Object
- Object
- Datadog::CI::TestVisibility::KnownTests
- Defined in:
- lib/datadog/ci/test_visibility/known_tests.rb
Overview
fetches and stores a list of known tests from the backend
Defined Under Namespace
Classes: Response
Instance Method Summary collapse
- #fetch(test_session) ⇒ Object
-
#initialize(dd_env:, api: nil, config_tags: {}) ⇒ KnownTests
constructor
A new instance of KnownTests.
Constructor Details
#initialize(dd_env:, api: nil, config_tags: {}) ⇒ KnownTests
Returns a new instance of KnownTests.
71 72 73 74 75 |
# File 'lib/datadog/ci/test_visibility/known_tests.rb', line 71 def initialize(dd_env:, api: nil, config_tags: {}) @api = api @dd_env = dd_env @config_tags = end |
Instance Method Details
#fetch(test_session) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/datadog/ci/test_visibility/known_tests.rb', line 77 def fetch(test_session) api = @api return Set.new unless api request_payload = payload(test_session) Datadog.logger.debug("Fetching unique known tests with request: #{request_payload}") http_response = api.api_request( path: Ext::Transport::DD_API_UNIQUE_TESTS_PATH, payload: request_payload ) CI::Transport::Telemetry.api_requests( Ext::Telemetry::METRIC_KNOWN_TESTS_REQUEST, 1, compressed: http_response.request_compressed ) Utils::Telemetry.distribution(Ext::Telemetry::METRIC_KNOWN_TESTS_REQUEST_MS, http_response.duration_ms) Utils::Telemetry.distribution( Ext::Telemetry::METRIC_KNOWN_TESTS_RESPONSE_BYTES, http_response.response_size.to_f, {Ext::Telemetry::TAG_RESPONSE_COMPRESSED => http_response.gzipped_content?.to_s} ) unless http_response.ok? CI::Transport::Telemetry.api_requests_errors( Ext::Telemetry::METRIC_KNOWN_TESTS_REQUEST_ERRORS, 1, error_type: http_response.telemetry_error_type, status_code: http_response.code ) end Response.from_http_response(http_response).tests end |