datadog-ci 1.0.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -2
  3. data/ext/datadog_cov/datadog_cov.c +259 -67
  4. data/lib/datadog/ci/configuration/components.rb +121 -79
  5. data/lib/datadog/ci/configuration/settings.rb +6 -0
  6. data/lib/datadog/ci/contrib/rspec/example.rb +1 -1
  7. data/lib/datadog/ci/contrib/rspec/patcher.rb +3 -3
  8. data/lib/datadog/ci/ext/settings.rb +1 -0
  9. data/lib/datadog/ci/span.rb +3 -3
  10. data/lib/datadog/ci/test.rb +1 -1
  11. data/lib/datadog/ci/test_module.rb +1 -1
  12. data/lib/datadog/ci/{itr/runner.rb → test_optimisation/component.rb} +13 -10
  13. data/lib/datadog/ci/{itr → test_optimisation}/coverage/ddcov.rb +1 -1
  14. data/lib/datadog/ci/{itr → test_optimisation}/coverage/event.rb +1 -1
  15. data/lib/datadog/ci/{itr → test_optimisation}/coverage/transport.rb +1 -1
  16. data/lib/datadog/ci/{itr → test_optimisation}/coverage/writer.rb +1 -1
  17. data/lib/datadog/ci/{itr → test_optimisation}/skippable.rb +1 -1
  18. data/lib/datadog/ci/test_session.rb +1 -1
  19. data/lib/datadog/ci/test_suite.rb +1 -1
  20. data/lib/datadog/ci/test_visibility/{recorder.rb → component.rb} +10 -10
  21. data/lib/datadog/ci/test_visibility/{null_recorder.rb → null_component.rb} +6 -4
  22. data/lib/datadog/ci/test_visibility/transport.rb +1 -1
  23. data/lib/datadog/ci/transport/adapters/net.rb +138 -0
  24. data/lib/datadog/ci/transport/api/agentless.rb +2 -2
  25. data/lib/datadog/ci/transport/api/evp_proxy.rb +1 -1
  26. data/lib/datadog/ci/transport/http.rb +7 -57
  27. data/lib/datadog/ci/version.rb +2 -2
  28. data/lib/datadog/ci.rb +15 -15
  29. metadata +12 -11
@@ -2,12 +2,12 @@
2
2
 
3
3
  require_relative "../ext/settings"
4
4
  require_relative "../git/tree_uploader"
5
- require_relative "../itr/runner"
6
- require_relative "../itr/coverage/transport"
7
- require_relative "../itr/coverage/writer"
5
+ require_relative "../test_optimisation/component"
6
+ require_relative "../test_optimisation/coverage/transport"
7
+ require_relative "../test_optimisation/coverage/writer"
8
+ require_relative "../test_visibility/component"
8
9
  require_relative "../test_visibility/flush"
9
- require_relative "../test_visibility/recorder"
10
- require_relative "../test_visibility/null_recorder"
10
+ require_relative "../test_visibility/null_component"
11
11
  require_relative "../test_visibility/serializers/factories/test_level"
12
12
  require_relative "../test_visibility/serializers/factories/test_suite_level"
13
13
  require_relative "../test_visibility/transport"
@@ -21,15 +21,15 @@ module Datadog
21
21
  module Configuration
22
22
  # Adds CI behavior to Datadog trace components
23
23
  module Components
24
- attr_reader :ci_recorder, :itr
24
+ attr_reader :test_visibility, :test_optimisation
25
25
 
26
26
  def initialize(settings)
27
+ @test_optimisation = nil
28
+ @test_visibility = TestVisibility::NullComponent.new
29
+
27
30
  # Activate CI mode if enabled
28
31
  if settings.ci.enabled
29
32
  activate_ci!(settings)
30
- else
31
- @itr = nil
32
- @ci_recorder = TestVisibility::NullRecorder.new
33
33
  end
34
34
 
35
35
  super
@@ -38,8 +38,8 @@ module Datadog
38
38
  def shutdown!(replacement = nil)
39
39
  super
40
40
 
41
- @ci_recorder&.shutdown!
42
- @itr&.shutdown!
41
+ @test_visibility&.shutdown!
42
+ @test_optimisation&.shutdown!
43
43
  end
44
44
 
45
45
  def activate_ci!(settings)
@@ -53,22 +53,21 @@ module Datadog
53
53
  return
54
54
  end
55
55
 
56
- # Configure ddtrace library for CI visibility mode
56
+ # Builds test visibility API layer in agentless or EvP proxy mode
57
+ test_visibility_api = build_test_visibility_api(settings)
58
+ # bail out early if api is misconfigured
59
+ return unless settings.ci.enabled
60
+
61
+ # Configure datadog gem for test visibility mode
62
+
57
63
  # Deactivate telemetry
58
64
  settings.telemetry.enabled = false
59
65
 
60
- # Deactivate remote configuration
66
+ # Test visibility uses its own remote settings
61
67
  settings.remote.enabled = false
62
68
 
63
- # do not use 128-bit trace ids for CI visibility
64
- # they are used for OTEL compatibility in Datadog tracer
65
- settings.tracing.trace_id_128_bit_generation_enabled = false
66
-
67
- # Activate underlying tracing test mode
68
- settings.tracing.test_mode.enabled = true
69
-
70
- # Choose user defined TraceFlush or default to CI TraceFlush
71
- settings.tracing.test_mode.trace_flush = settings.ci.trace_flush || CI::TestVisibility::Flush::Partial.new
69
+ # startup logs are useless for test visibility and create noise
70
+ settings.diagnostics.startup_logs.enabled = false
72
71
 
73
72
  # When timecop is present, Time.now is mocked and .now_without_mock_time is added on Time to
74
73
  # get the current time without the mock.
@@ -81,76 +80,70 @@ module Datadog
81
80
  end
82
81
  end
83
82
 
84
- # startup logs are useless for CI visibility and create noise
85
- settings.diagnostics.startup_logs.enabled = false
83
+ # Configure Datadog::Tracing module
86
84
 
87
- # transport creation
88
- writer_options = settings.ci.writer_options
89
- coverage_writer = nil
90
- test_visibility_api = build_test_visibility_api(settings)
85
+ # No need not use 128-bit trace ids for test visibility,
86
+ # they are used for OTEL compatibility in Datadog tracer
87
+ settings.tracing.trace_id_128_bit_generation_enabled = false
91
88
 
92
- if test_visibility_api
93
- # setup writer for code coverage payloads
94
- coverage_writer = ITR::Coverage::Writer.new(
95
- transport: ITR::Coverage::Transport.new(api: test_visibility_api)
96
- )
89
+ # Activate underlying tracing test mode with async worker
90
+ settings.tracing.test_mode.enabled = true
91
+ settings.tracing.test_mode.async = true
92
+ settings.tracing.test_mode.trace_flush = settings.ci.trace_flush || CI::TestVisibility::Flush::Partial.new
97
93
 
98
- # configure tracing writer to send traces to CI visibility backend
99
- writer_options[:transport] = TestVisibility::Transport.new(
100
- api: test_visibility_api,
101
- serializers_factory: serializers_factory(settings),
102
- dd_env: settings.env
103
- )
104
- writer_options[:shutdown_timeout] = 60
105
- writer_options[:buffer_size] = 10_000
94
+ trace_writer_options = settings.ci.writer_options
95
+ trace_writer_options[:shutdown_timeout] = 60
96
+ trace_writer_options[:buffer_size] = 10_000
97
+ tracing_transport = build_tracing_transport(settings, test_visibility_api)
98
+ trace_writer_options[:transport] = tracing_transport if tracing_transport
106
99
 
107
- settings.tracing.test_mode.async = true
108
- else
109
- # only legacy APM protocol is supported, so no test suite level visibility
110
- settings.ci.force_test_level_visibility = true
100
+ settings.tracing.test_mode.writer_options = trace_writer_options
111
101
 
112
- # ITR is not supported with APM protocol
113
- settings.ci.itr_enabled = false
114
- end
102
+ # @type ivar @test_optimisation: Datadog::CI::TestOptimisation::Component
103
+ @test_optimisation = build_test_optimisation(settings, test_visibility_api)
115
104
 
116
- settings.tracing.test_mode.writer_options = writer_options
105
+ @test_visibility = TestVisibility::Component.new(
106
+ test_optimisation: @test_optimisation,
107
+ test_suite_level_visibility_enabled: !settings.ci.force_test_level_visibility,
108
+ remote_settings_api: build_remote_settings_client(settings, test_visibility_api),
109
+ git_tree_upload_worker: build_git_upload_worker(settings, test_visibility_api)
110
+ )
111
+ end
117
112
 
118
- custom_configuration_tags = Utils::TestRun.custom_configuration(settings.tags)
113
+ def build_test_optimisation(settings, test_visibility_api)
114
+ if settings.ci.itr_code_coverage_use_single_threaded_mode &&
115
+ settings.ci.itr_test_impact_analysis_use_allocation_tracing
116
+ Datadog.logger.warn(
117
+ "Intelligent test runner: Single threaded coverage mode is incompatible with allocation tracing. " \
118
+ "Allocation tracing will be disabled. It means that test impact analysis will not be able to detect " \
119
+ "instantiations of objects in your code, which is important for ActiveRecord models. " \
120
+ "Please add your app/model folder to the list of tracked files or disable single threaded coverage mode."
121
+ )
119
122
 
120
- remote_settings_api = Transport::RemoteSettingsApi.new(
121
- api: test_visibility_api,
122
- dd_env: settings.env,
123
- config_tags: custom_configuration_tags
124
- )
123
+ settings.ci.itr_test_impact_analysis_use_allocation_tracing = false
124
+ end
125
125
 
126
- itr = ITR::Runner.new(
126
+ if RUBY_VERSION.start_with?("3.2.") && RUBY_VERSION < "3.2.3" &&
127
+ settings.ci.itr_test_impact_analysis_use_allocation_tracing
128
+ Datadog.logger.warn(
129
+ "Intelligent test runner: Allocation tracing is not supported in Ruby versions 3.2.0, 3.2.1 and 3.2.2 and will be forcibly " \
130
+ "disabled. This is due to a VM bug that can lead to crashes (https://bugs.ruby-lang.org/issues/19482). " \
131
+ "Please update your Ruby version or add your app/model folder to the list of tracked files." \
132
+ "Set env variable DD_CIVISIBILITY_ITR_TEST_IMPACT_ANALYSIS_USE_ALLOCATION_TRACING to 0 to disable this warning."
133
+ )
134
+ settings.ci.itr_test_impact_analysis_use_allocation_tracing = false
135
+ end
136
+
137
+ TestOptimisation::Component.new(
127
138
  api: test_visibility_api,
128
139
  dd_env: settings.env,
129
- config_tags: custom_configuration_tags,
130
- coverage_writer: coverage_writer,
140
+ config_tags: custom_configuration(settings),
141
+ coverage_writer: build_coverage_writer(settings, test_visibility_api),
131
142
  enabled: settings.ci.enabled && settings.ci.itr_enabled,
132
143
  bundle_location: settings.ci.itr_code_coverage_excluded_bundle_path,
133
- use_single_threaded_coverage: settings.ci.itr_code_coverage_use_single_threaded_mode
134
- )
135
-
136
- git_tree_uploader = Git::TreeUploader.new(api: test_visibility_api)
137
- git_tree_upload_worker = if settings.ci.git_metadata_upload_enabled
138
- Worker.new do |repository_url|
139
- git_tree_uploader.call(repository_url)
140
- end
141
- else
142
- DummyWorker.new
143
- end
144
-
145
- # CI visibility recorder global instance
146
- @ci_recorder = TestVisibility::Recorder.new(
147
- test_suite_level_visibility_enabled: !settings.ci.force_test_level_visibility,
148
- itr: itr,
149
- remote_settings_api: remote_settings_api,
150
- git_tree_upload_worker: git_tree_upload_worker
144
+ use_single_threaded_coverage: settings.ci.itr_code_coverage_use_single_threaded_mode,
145
+ use_allocation_tracing: settings.ci.itr_test_impact_analysis_use_allocation_tracing
151
146
  )
152
-
153
- @itr = itr
154
147
  end
155
148
 
156
149
  def build_test_visibility_api(settings)
@@ -179,12 +172,61 @@ module Datadog
179
172
  Datadog.logger.debug(
180
173
  "Old agent version detected, no evp_proxy support. Forcing test level visibility mode"
181
174
  )
175
+
176
+ # only legacy APM protocol is supported, so no test suite level visibility
177
+ settings.ci.force_test_level_visibility = true
178
+
179
+ # ITR is not supported with APM protocol
180
+ settings.ci.itr_enabled = false
182
181
  end
183
182
  end
184
183
 
185
184
  api
186
185
  end
187
186
 
187
+ def build_tracing_transport(settings, api)
188
+ return nil if api.nil?
189
+
190
+ TestVisibility::Transport.new(
191
+ api: api,
192
+ serializers_factory: serializers_factory(settings),
193
+ dd_env: settings.env
194
+ )
195
+ end
196
+
197
+ def build_coverage_writer(settings, api)
198
+ return nil if api.nil?
199
+
200
+ TestOptimisation::Coverage::Writer.new(
201
+ transport: TestOptimisation::Coverage::Transport.new(api: api)
202
+ )
203
+ end
204
+
205
+ def build_git_upload_worker(settings, api)
206
+ if settings.ci.git_metadata_upload_enabled
207
+ git_tree_uploader = Git::TreeUploader.new(api: api)
208
+ Worker.new do |repository_url|
209
+ git_tree_uploader.call(repository_url)
210
+ end
211
+ else
212
+ DummyWorker.new
213
+ end
214
+ end
215
+
216
+ def build_remote_settings_client(settings, api)
217
+ Transport::RemoteSettingsApi.new(
218
+ api: api,
219
+ dd_env: settings.env,
220
+ config_tags: custom_configuration(settings)
221
+ )
222
+ end
223
+
224
+ # fetch custom tags provided by the user in DD_TAGS env var
225
+ # with prefix test.configuration.
226
+ def custom_configuration(settings)
227
+ @custom_configuration ||= Utils::TestRun.custom_configuration(settings.tags)
228
+ end
229
+
188
230
  def serializers_factory(settings)
189
231
  if settings.ci.force_test_level_visibility
190
232
  TestVisibility::Serializers::Factories::TestLevel
@@ -205,7 +247,7 @@ module Datadog
205
247
  end
206
248
 
207
249
  def timecop?
208
- Gem.loaded_specs.key?("timecop") || defined?(Timecop)
250
+ Gem.loaded_specs.key?("timecop") || !!defined?(Timecop)
209
251
  end
210
252
  end
211
253
  end
@@ -82,6 +82,12 @@ module Datadog
82
82
  o.default false
83
83
  end
84
84
 
85
+ option :itr_test_impact_analysis_use_allocation_tracing do |o|
86
+ o.type :bool
87
+ o.env CI::Ext::Settings::ENV_ITR_TEST_IMPACT_ANALYSIS_USE_ALLOCATION_TRACING
88
+ o.default true
89
+ end
90
+
85
91
  define_method(:instrument) do |integration_name, options = {}, &block|
86
92
  return unless enabled
87
93
 
@@ -100,7 +100,7 @@ module Datadog
100
100
  end
101
101
 
102
102
  def ci_queue?
103
- defined?(::RSpec::Queue::ExampleExtension) &&
103
+ !!defined?(::RSpec::Queue::ExampleExtension) &&
104
104
  self.class.ancestors.include?(::RSpec::Queue::ExampleExtension)
105
105
  end
106
106
  end
@@ -42,15 +42,15 @@ module Datadog
42
42
  end
43
43
 
44
44
  def ci_queue?
45
- defined?(::RSpec::Queue::Runner)
45
+ !!defined?(::RSpec::Queue::Runner)
46
46
  end
47
47
 
48
48
  def knapsack_pro?
49
49
  knapsack_version = Gem.loaded_specs["knapsack_pro"]&.version
50
50
 
51
51
  # additional instrumentation is needed for KnapsackPro version 7 and later
52
- defined?(::KnapsackPro) &&
53
- knapsack_version && knapsack_version >= Gem::Version.new("7")
52
+ !!defined?(::KnapsackPro) &&
53
+ !knapsack_version.nil? && knapsack_version >= Gem::Version.new("7")
54
54
  end
55
55
  end
56
56
  end
@@ -14,6 +14,7 @@ module Datadog
14
14
  ENV_GIT_METADATA_UPLOAD_ENABLED = "DD_CIVISIBILITY_GIT_METADATA_UPLOAD_ENABLED"
15
15
  ENV_ITR_CODE_COVERAGE_EXCLUDED_BUNDLE_PATH = "DD_CIVISIBILITY_ITR_CODE_COVERAGE_EXCLUDED_BUNDLE_PATH"
16
16
  ENV_ITR_CODE_COVERAGE_USE_SINGLE_THREADED_MODE = "DD_CIVISIBILITY_ITR_CODE_COVERAGE_USE_SINGLE_THREADED_MODE"
17
+ ENV_ITR_TEST_IMPACT_ANALYSIS_USE_ALLOCATION_TRACING = "DD_CIVISIBILITY_ITR_TEST_IMPACT_ANALYSIS_USE_ALLOCATION_TRACING"
17
18
 
18
19
  # Source: https://docs.datadoghq.com/getting_started/site/
19
20
  DD_SITE_ALLOWLIST = %w[
@@ -202,9 +202,9 @@ module Datadog
202
202
 
203
203
  private
204
204
 
205
- # provides access to global CI recorder for CI models to deactivate themselves
206
- def recorder
207
- Datadog.send(:components).ci_recorder
205
+ # provides access to the test visibility component for CI models to deactivate themselves
206
+ def test_visibility
207
+ Datadog.send(:components).test_visibility
208
208
  end
209
209
  end
210
210
  end
@@ -19,7 +19,7 @@ module Datadog
19
19
  # Finishes the current test.
20
20
  # @return [void]
21
21
  def finish
22
- recorder.deactivate_test
22
+ test_visibility.deactivate_test
23
23
 
24
24
  super
25
25
  end
@@ -14,7 +14,7 @@ module Datadog
14
14
  # Finishes this test module.
15
15
  # @return [void]
16
16
  def finish
17
- recorder.deactivate_test_module
17
+ test_visibility.deactivate_test_module
18
18
 
19
19
  super
20
20
  end
@@ -16,11 +16,11 @@ require_relative "skippable"
16
16
 
17
17
  module Datadog
18
18
  module CI
19
- module ITR
19
+ module TestOptimisation
20
20
  # Intelligent test runner implementation
21
21
  # Integrates with backend to provide test impact analysis data and
22
22
  # skip tests that are not impacted by the changes
23
- class Runner
23
+ class Component
24
24
  include Core::Utils::Forking
25
25
 
26
26
  attr_reader :correlation_id, :skippable_tests, :skipped_tests_count
@@ -32,7 +32,8 @@ module Datadog
32
32
  coverage_writer: nil,
33
33
  enabled: false,
34
34
  bundle_location: nil,
35
- use_single_threaded_coverage: false
35
+ use_single_threaded_coverage: false,
36
+ use_allocation_tracing: true
36
37
  )
37
38
  @enabled = enabled
38
39
  @api = api
@@ -45,6 +46,7 @@ module Datadog
45
46
  bundle_location
46
47
  end
47
48
  @use_single_threaded_coverage = use_single_threaded_coverage
49
+ @use_allocation_tracing = use_allocation_tracing
48
50
 
49
51
  @test_skipping_enabled = false
50
52
  @code_coverage_enabled = false
@@ -57,11 +59,11 @@ module Datadog
57
59
  @skipped_tests_count = 0
58
60
  @mutex = Mutex.new
59
61
 
60
- Datadog.logger.debug("ITR Runner initialized with enabled: #{@enabled}")
62
+ Datadog.logger.debug("TestOptimisation initialized with enabled: #{@enabled}")
61
63
  end
62
64
 
63
65
  def configure(remote_configuration, test_session:, git_tree_upload_worker:)
64
- Datadog.logger.debug("Configuring ITR Runner with remote configuration: #{remote_configuration}")
66
+ Datadog.logger.debug("Configuring TestOptimisation with remote configuration: #{remote_configuration}")
65
67
 
66
68
  @enabled = Utils::Parsing.convert_to_bool(
67
69
  remote_configuration.fetch(Ext::Transport::DD_API_SETTINGS_RESPONSE_ITR_ENABLED_KEY, false)
@@ -83,7 +85,7 @@ module Datadog
83
85
 
84
86
  load_datadog_cov! if @code_coverage_enabled
85
87
 
86
- Datadog.logger.debug("Configured ITR Runner with enabled: #{@enabled}, skipping_tests: #{@test_skipping_enabled}, code_coverage: #{@code_coverage_enabled}")
88
+ Datadog.logger.debug("Configured TestOptimisation with enabled: #{@enabled}, skipping_tests: #{@test_skipping_enabled}, code_coverage: #{@code_coverage_enabled}")
87
89
 
88
90
  fetch_skippable_tests(test_session: test_session, git_tree_upload_worker: git_tree_upload_worker)
89
91
  end
@@ -139,7 +141,7 @@ module Datadog
139
141
  skippable_test_id = Utils::TestRun.skippable_test_id(test.name, test.test_suite_name, test.parameters)
140
142
  if @skippable_tests.include?(skippable_test_id)
141
143
  if forked?
142
- Datadog.logger.warn { "ITR is not supported for forking test runners yet" }
144
+ Datadog.logger.warn { "Intelligent test runner is not supported for forking test runners yet" }
143
145
  return
144
146
  end
145
147
 
@@ -155,7 +157,7 @@ module Datadog
155
157
  return if !test.skipped? || !test.skipped_by_itr?
156
158
 
157
159
  if forked?
158
- Datadog.logger.warn { "ITR is not supported for forking test runners yet" }
160
+ Datadog.logger.warn { "Intelligent test runner is not supported for forking test runners yet" }
159
161
  return
160
162
  end
161
163
 
@@ -167,7 +169,7 @@ module Datadog
167
169
  def write_test_session_tags(test_session)
168
170
  return if !enabled?
169
171
 
170
- Datadog.logger.debug { "Finished ITR session with test skipping enabled: #{@test_skipping_enabled}" }
172
+ Datadog.logger.debug { "Finished optimised session with test skipping enabled: #{@test_skipping_enabled}" }
171
173
  Datadog.logger.debug { "#{@skipped_tests_count} tests were skipped" }
172
174
 
173
175
  test_session.set_tag(Ext::Test::TAG_ITR_TESTS_SKIPPED, @skipped_tests_count.positive?.to_s)
@@ -189,7 +191,8 @@ module Datadog
189
191
  Thread.current[:dd_coverage_collector] ||= Coverage::DDCov.new(
190
192
  root: Git::LocalRepository.root,
191
193
  ignored_path: @bundle_location,
192
- threading_mode: code_coverage_mode
194
+ threading_mode: code_coverage_mode,
195
+ use_allocation_tracing: @use_allocation_tracing
193
196
  )
194
197
  end
195
198
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Datadog
4
4
  module CI
5
- module ITR
5
+ module TestOptimisation
6
6
  module Coverage
7
7
  # Placeholder for code coverage collection
8
8
  # Implementation in ext/datadog_cov
@@ -6,7 +6,7 @@ require_relative "../../git/local_repository"
6
6
 
7
7
  module Datadog
8
8
  module CI
9
- module ITR
9
+ module TestOptimisation
10
10
  module Coverage
11
11
  class Event
12
12
  attr_reader :test_id, :test_suite_id, :test_session_id, :coverage
@@ -5,7 +5,7 @@ require_relative "../../transport/event_platform_transport"
5
5
 
6
6
  module Datadog
7
7
  module CI
8
- module ITR
8
+ module TestOptimisation
9
9
  module Coverage
10
10
  class Transport < Datadog::CI::Transport::EventPlatformTransport
11
11
  private
@@ -11,7 +11,7 @@ require "datadog/core/environment/ext"
11
11
 
12
12
  module Datadog
13
13
  module CI
14
- module ITR
14
+ module TestOptimisation
15
15
  module Coverage
16
16
  class Writer
17
17
  include Core::Workers::Queue
@@ -8,7 +8,7 @@ require_relative "../utils/test_run"
8
8
 
9
9
  module Datadog
10
10
  module CI
11
- module ITR
11
+ module TestOptimisation
12
12
  class Skippable
13
13
  class Response
14
14
  def initialize(http_response)
@@ -15,7 +15,7 @@ module Datadog
15
15
  # Finishes the current test session.
16
16
  # @return [void]
17
17
  def finish
18
- recorder.deactivate_test_session
18
+ test_visibility.deactivate_test_session
19
19
 
20
20
  super
21
21
  end
@@ -26,7 +26,7 @@ module Datadog
26
26
  # we try to derive test suite status from execution stats if no status was set explicitly
27
27
  set_status_from_stats! if undefined?
28
28
 
29
- recorder.deactivate_test_suite(name)
29
+ test_visibility.deactivate_test_suite(name)
30
30
 
31
31
  super
32
32
  end
@@ -28,11 +28,11 @@ module Datadog
28
28
  module TestVisibility
29
29
  # Common behavior for CI tests
30
30
  # Note: this class has too many responsibilities and should be split into multiple classes
31
- class Recorder
31
+ class Component
32
32
  attr_reader :environment_tags, :test_suite_level_visibility_enabled
33
33
 
34
34
  def initialize(
35
- itr:,
35
+ test_optimisation:,
36
36
  remote_settings_api:,
37
37
  git_tree_upload_worker: DummyWorker.new,
38
38
  test_suite_level_visibility_enabled: false,
@@ -46,7 +46,7 @@ module Datadog
46
46
 
47
47
  @codeowners = codeowners
48
48
 
49
- @itr = itr
49
+ @test_optimisation = test_optimisation
50
50
  @remote_settings_api = remote_settings_api
51
51
  @git_tree_upload_worker = git_tree_upload_worker
52
52
  end
@@ -210,7 +210,7 @@ module Datadog
210
210
  end
211
211
 
212
212
  def itr_enabled?
213
- @itr.enabled?
213
+ @test_optimisation.enabled?
214
214
  end
215
215
 
216
216
  private
@@ -234,7 +234,7 @@ module Datadog
234
234
  end
235
235
  end
236
236
 
237
- @itr.configure(
237
+ @test_optimisation.configure(
238
238
  remote_configuration.payload,
239
239
  test_session: test_session,
240
240
  git_tree_upload_worker: @git_tree_upload_worker
@@ -404,17 +404,17 @@ module Datadog
404
404
 
405
405
  # TODO: use kind of event system to notify about test finished?
406
406
  def on_test_finished(test)
407
- @itr.stop_coverage(test)
408
- @itr.count_skipped_test(test)
407
+ @test_optimisation.stop_coverage(test)
408
+ @test_optimisation.count_skipped_test(test)
409
409
  end
410
410
 
411
411
  def on_test_started(test)
412
- @itr.mark_if_skippable(test)
413
- @itr.start_coverage(test)
412
+ @test_optimisation.mark_if_skippable(test)
413
+ @test_optimisation.start_coverage(test)
414
414
  end
415
415
 
416
416
  def on_test_session_finished(test_session)
417
- @itr.write_test_session_tags(test_session)
417
+ @test_optimisation.write_test_session_tags(test_session)
418
418
  end
419
419
  end
420
420
  end
@@ -1,12 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "recorder"
4
-
5
3
  module Datadog
6
4
  module CI
7
5
  module TestVisibility
8
- # Special recorder that does not record anything
9
- class NullRecorder
6
+ # Special test visibility component that does not record anything
7
+ class NullComponent
10
8
  def start_test_session(service: nil, tags: {})
11
9
  skip_tracing
12
10
  end
@@ -45,6 +43,10 @@ module Datadog
45
43
  def shutdown!
46
44
  end
47
45
 
46
+ def itr_enabled?
47
+ false
48
+ end
49
+
48
50
  private
49
51
 
50
52
  def skip_tracing(block = nil)
@@ -100,7 +100,7 @@ module Datadog
100
100
  end
101
101
 
102
102
  def itr
103
- @itr ||= Datadog::CI.send(:itr_runner)
103
+ @test_optimisation ||= Datadog::CI.send(:test_optimisation)
104
104
  end
105
105
  end
106
106
  end