Class: Datadog::CI::Remote::Component

Inherits:
Object
  • Object
show all
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"

Instance Method Summary collapse

Methods included from Utils::Stateful

#load_component_state, #store_component_state

Constructor Details

#initialize(library_settings_client:, test_discovery_enabled: false) ⇒ Component

Returns a new instance of Component.



17
18
19
20
# File 'lib/datadog/ci/remote/component.rb', line 17

def initialize(library_settings_client:, test_discovery_enabled: false)
  @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



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/datadog/ci/remote/component.rb', line 23

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_optimisation.configure(@library_configuration, test_session) },
    Worker.new { test_retries.configure(@library_configuration, test_session) },
    Worker.new { test_visibility.configure(@library_configuration, test_session) },
    Worker.new { test_management.configure(@library_configuration, test_session) },
    Worker.new { impacted_tests_detection.configure(@library_configuration, test_session) }
  ]

  # launch configuration workers
  configuration_workers.each(&:perform)

  # block until all workers are done
  configuration_workers.each(&:wait_until_done)
end

#restore_state(state) ⇒ Object



49
50
51
# File 'lib/datadog/ci/remote/component.rb', line 49

def restore_state(state)
  @library_configuration = state[:library_configuration]
end

#serialize_stateObject

Implementation of Stateful interface



43
44
45
46
47
# File 'lib/datadog/ci/remote/component.rb', line 43

def serialize_state
  {
    library_configuration: @library_configuration
  }
end

#storage_keyObject



53
54
55
# File 'lib/datadog/ci/remote/component.rb', line 53

def storage_key
  FILE_STORAGE_KEY
end