Class: Datadog::CI::Remote::Component
- Inherits:
-
Object
- Object
- Datadog::CI::Remote::Component
- Includes:
- Utils::Stateful
- Defined in:
- lib/datadog/ci/remote/component.rb
Overview
Remote configuration component. Responsible for fetching library settings and configuring the library accordingly.
Constant Summary collapse
- FILE_STORAGE_KEY =
"remote_component_state"
Class Method Summary collapse
Instance Method Summary collapse
-
#configure(test_session) ⇒ Object
called on test session start, uses test session info to send configuration request to the backend.
-
#initialize(library_settings_client:, test_discovery_enabled: false) ⇒ Component
constructor
A new instance of Component.
- #restore_state(state) ⇒ Object
- #restore_state_from_datadog_test_runner ⇒ Object
-
#serialize_state ⇒ Object
Implementation of Stateful interface.
- #storage_key ⇒ Object
Methods included from Utils::Stateful
#load_cached_known_tests, #load_cached_settings, #load_cached_skippable_tests, #load_cached_test_management, #load_component_state, #store_component_state, #test_optimization_cache
Constructor Details
#initialize(library_settings_client:, test_discovery_enabled: false) ⇒ Component
Returns a new instance of Component.
32 33 34 35 |
# File 'lib/datadog/ci/remote/component.rb', line 32 def initialize(library_settings_client:, test_discovery_enabled: false) @library_settings_client = library_settings_client @test_discovery_enabled = test_discovery_enabled end |
Class Method Details
.build(api:, dd_env:, test_skipping_mode:, config_tags:, test_discovery_enabled:) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/datadog/ci/remote/component.rb', line 18 def self.build(api:, dd_env:, test_skipping_mode:, config_tags:, test_discovery_enabled:) library_settings_client = LibrarySettingsClient.new( api: api, dd_env: dd_env, test_skipping_mode: test_skipping_mode, config_tags: ) new( library_settings_client: library_settings_client, test_discovery_enabled: test_discovery_enabled ) end |
Instance Method Details
#configure(test_session) ⇒ Object
called on test session start, uses test session info to send configuration request to the backend
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/datadog/ci/remote/component.rb', line 38 def configure(test_session) fetch_library_configuration(test_session) # configure different components in parallel because they might block on HTTP requests configuration_workers = [ Worker.new { test_impact_analysis.configure(@library_configuration, test_session) }, Worker.new { test_retries.configure(@library_configuration, test_session) }, Worker.new { test_tracing.configure(@library_configuration, test_session) }, Worker.new { test_management.configure(@library_configuration, test_session) }, Worker.new { impacted_tests_detection.configure(@library_configuration, test_session) }, Worker.new { code_coverage.configure(@library_configuration) } ] # launch configuration workers configuration_workers.each(&:perform) # block until all workers are done configuration_workers.each(&:wait_until_done) end |
#restore_state(state) ⇒ Object
65 66 67 |
# File 'lib/datadog/ci/remote/component.rb', line 65 def restore_state(state) @library_configuration = state[:library_configuration] end |
#restore_state_from_datadog_test_runner ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/datadog/ci/remote/component.rb', line 73 def restore_state_from_datadog_test_runner Datadog.logger.debug { "Restoring library configuration from Test Optimization cache" } settings = load_cached_settings if settings.nil? Datadog.logger.debug { "Restoring library configuration failed, will request again" } return false end Datadog.logger.debug { "Restored library configuration from Test Optimization: #{settings}" } @library_configuration = LibrarySettings.from_json(settings) true end |
#serialize_state ⇒ Object
Implementation of Stateful interface
59 60 61 62 63 |
# File 'lib/datadog/ci/remote/component.rb', line 59 def serialize_state { library_configuration: @library_configuration } end |
#storage_key ⇒ Object
69 70 71 |
# File 'lib/datadog/ci/remote/component.rb', line 69 def storage_key FILE_STORAGE_KEY end |