From 2e7f0ffa94404d67a91235abaac9f90d3ac01397 Mon Sep 17 00:00:00 2001 From: Andrey Date: Tue, 2 Jul 2024 14:38:12 +0200 Subject: [PATCH 1/4] refactor library config and components building --- lib/datadog/ci/configuration/components.rb | 151 ++++++++++-------- .../ci/test_visibility/null_recorder.rb | 4 + sig/datadog/ci/configuration/components.rbs | 13 +- 3 files changed, 99 insertions(+), 69 deletions(-) diff --git a/lib/datadog/ci/configuration/components.rb b/lib/datadog/ci/configuration/components.rb index 14f787fa..24717f62 100644 --- a/lib/datadog/ci/configuration/components.rb +++ b/lib/datadog/ci/configuration/components.rb @@ -24,12 +24,12 @@ module Components attr_reader :ci_recorder, :itr def initialize(settings) + @itr = nil + @ci_recorder = TestVisibility::NullRecorder.new + # Activate CI mode if enabled if settings.ci.enabled activate_ci!(settings) - else - @itr = nil - @ci_recorder = TestVisibility::NullRecorder.new end super @@ -53,22 +53,21 @@ def activate_ci!(settings) return end - # Configure ddtrace library for CI visibility mode + # Builds test visibility API layer in agentless or EvP proxy mode + test_visibility_api = build_test_visibility_api(settings) + # bail out early if api is misconfigured + return unless settings.ci.enabled + + # Configure datadog gem for test visibility mode + # Deactivate telemetry settings.telemetry.enabled = false - # Deactivate remote configuration + # Test visibility uses its own remote settings settings.remote.enabled = false - # do not use 128-bit trace ids for CI visibility - # they are used for OTEL compatibility in Datadog tracer - settings.tracing.trace_id_128_bit_generation_enabled = false - - # Activate underlying tracing test mode - settings.tracing.test_mode.enabled = true - - # Choose user defined TraceFlush or default to CI TraceFlush - settings.tracing.test_mode.trace_flush = settings.ci.trace_flush || CI::TestVisibility::Flush::Partial.new + # startup logs are useless for test visibility and create noise + settings.diagnostics.startup_logs.enabled = false # When timecop is present, Time.now is mocked and .now_without_mock_time is added on Time to # get the current time without the mock. @@ -81,76 +80,43 @@ def activate_ci!(settings) end end - # startup logs are useless for CI visibility and create noise - settings.diagnostics.startup_logs.enabled = false - - # transport creation - writer_options = settings.ci.writer_options - coverage_writer = nil - test_visibility_api = build_test_visibility_api(settings) + # Configure Datadog::Tracing module - if test_visibility_api - # setup writer for code coverage payloads - coverage_writer = ITR::Coverage::Writer.new( - transport: ITR::Coverage::Transport.new(api: test_visibility_api) - ) - - # configure tracing writer to send traces to CI visibility backend - writer_options[:transport] = TestVisibility::Transport.new( - api: test_visibility_api, - serializers_factory: serializers_factory(settings), - dd_env: settings.env - ) - writer_options[:shutdown_timeout] = 60 - writer_options[:buffer_size] = 10_000 - - settings.tracing.test_mode.async = true - else - # only legacy APM protocol is supported, so no test suite level visibility - settings.ci.force_test_level_visibility = true - - # ITR is not supported with APM protocol - settings.ci.itr_enabled = false - end + # No need not use 128-bit trace ids for test visibility, + # they are used for OTEL compatibility in Datadog tracer + settings.tracing.trace_id_128_bit_generation_enabled = false - settings.tracing.test_mode.writer_options = writer_options + # Activate underlying tracing test mode with async worker + settings.tracing.test_mode.enabled = true + settings.tracing.test_mode.async = true + settings.tracing.test_mode.trace_flush = settings.ci.trace_flush || CI::TestVisibility::Flush::Partial.new - custom_configuration_tags = Utils::TestRun.custom_configuration(settings.tags) + trace_writer_options = settings.ci.writer_options + trace_writer_options[:shutdown_timeout] = 60 + trace_writer_options[:buffer_size] = 10_000 + tracing_transport = build_tracing_transport(settings, test_visibility_api) + trace_writer_options[:transport] = tracing_transport if tracing_transport - remote_settings_api = Transport::RemoteSettingsApi.new( - api: test_visibility_api, - dd_env: settings.env, - config_tags: custom_configuration_tags - ) + settings.tracing.test_mode.writer_options = trace_writer_options - itr = ITR::Runner.new( + # @type ivar @itr: Datadog::CI::ITR::Runner + @itr = ITR::Runner.new( api: test_visibility_api, dd_env: settings.env, - config_tags: custom_configuration_tags, - coverage_writer: coverage_writer, + config_tags: custom_configuration(settings), + coverage_writer: build_coverage_writer(settings, test_visibility_api), enabled: settings.ci.enabled && settings.ci.itr_enabled, bundle_location: settings.ci.itr_code_coverage_excluded_bundle_path, use_single_threaded_coverage: settings.ci.itr_code_coverage_use_single_threaded_mode ) - git_tree_uploader = Git::TreeUploader.new(api: test_visibility_api) - git_tree_upload_worker = if settings.ci.git_metadata_upload_enabled - Worker.new do |repository_url| - git_tree_uploader.call(repository_url) - end - else - DummyWorker.new - end - # CI visibility recorder global instance @ci_recorder = TestVisibility::Recorder.new( test_suite_level_visibility_enabled: !settings.ci.force_test_level_visibility, - itr: itr, - remote_settings_api: remote_settings_api, - git_tree_upload_worker: git_tree_upload_worker + itr: @itr, + remote_settings_api: build_remote_settings_client(settings, test_visibility_api), + git_tree_upload_worker: build_git_upload_worker(settings, test_visibility_api) ) - - @itr = itr end def build_test_visibility_api(settings) @@ -179,12 +145,61 @@ def build_test_visibility_api(settings) Datadog.logger.debug( "Old agent version detected, no evp_proxy support. Forcing test level visibility mode" ) + + # only legacy APM protocol is supported, so no test suite level visibility + settings.ci.force_test_level_visibility = true + + # ITR is not supported with APM protocol + settings.ci.itr_enabled = false end end api end + def build_tracing_transport(settings, api) + return nil if api.nil? + + TestVisibility::Transport.new( + api: api, + serializers_factory: serializers_factory(settings), + dd_env: settings.env + ) + end + + def build_coverage_writer(settings, api) + return nil if api.nil? + + ITR::Coverage::Writer.new( + transport: ITR::Coverage::Transport.new(api: api) + ) + end + + def build_git_upload_worker(settings, api) + if settings.ci.git_metadata_upload_enabled + git_tree_uploader = Git::TreeUploader.new(api: api) + Worker.new do |repository_url| + git_tree_uploader.call(repository_url) + end + else + DummyWorker.new + end + end + + def build_remote_settings_client(settings, api) + Transport::RemoteSettingsApi.new( + api: api, + dd_env: settings.env, + config_tags: custom_configuration(settings) + ) + end + + # fetch custom tags provided by the user in DD_TAGS env var + # with prefix test.configuration. + def custom_configuration(settings) + @custom_configuration ||= Utils::TestRun.custom_configuration(settings.tags) + end + def serializers_factory(settings) if settings.ci.force_test_level_visibility TestVisibility::Serializers::Factories::TestLevel diff --git a/lib/datadog/ci/test_visibility/null_recorder.rb b/lib/datadog/ci/test_visibility/null_recorder.rb index 5a83df3f..b2c05ede 100644 --- a/lib/datadog/ci/test_visibility/null_recorder.rb +++ b/lib/datadog/ci/test_visibility/null_recorder.rb @@ -45,6 +45,10 @@ def active_test_suite(test_suite_name) def shutdown! end + def itr_enabled? + false + end + private def skip_tracing(block = nil) diff --git a/sig/datadog/ci/configuration/components.rbs b/sig/datadog/ci/configuration/components.rbs index 87fd8b11..6f244df5 100644 --- a/sig/datadog/ci/configuration/components.rbs +++ b/sig/datadog/ci/configuration/components.rbs @@ -4,6 +4,7 @@ module Datadog module Components : Datadog::Core::Configuration::Components @ci_recorder: Datadog::CI::TestVisibility::Recorder | Datadog::CI::TestVisibility::NullRecorder @itr: Datadog::CI::ITR::Runner? + @custom_configuration: Hash[String, String] attr_reader ci_recorder: Datadog::CI::TestVisibility::Recorder | Datadog::CI::TestVisibility::NullRecorder attr_reader itr: Datadog::CI::ITR::Runner? @@ -18,8 +19,18 @@ module Datadog def check_dd_site: (untyped settings) -> void + def build_tracing_transport: (untyped settings, Datadog::CI::Transport::Api::Base? api) -> Datadog::CI::TestVisibility::Transport? + + def build_coverage_writer: (untyped settings, Datadog::CI::Transport::Api::Base? api) -> Datadog::CI::ITR::Coverage::Writer? + + def build_git_upload_worker: (untyped settings, Datadog::CI::Transport::Api::Base? api) -> Datadog::CI::Worker + + def build_remote_settings_client: (untyped settings, Datadog::CI::Transport::Api::Base? api) -> Datadog::CI::Transport::RemoteSettingsApi + + def custom_configuration: (untyped settings) -> Hash[String, String] + def timecop?: () -> bool end end end -end +end \ No newline at end of file From a891ebad5698501e896ac776df6bd743cf2ce059 Mon Sep 17 00:00:00 2001 From: Andrey Date: Tue, 2 Jul 2024 15:35:15 +0200 Subject: [PATCH 2/4] rename TestVisibility::Recorder to TestVisibility::Component --- lib/datadog/ci.rb | 26 ++--- lib/datadog/ci/configuration/components.rb | 13 ++- lib/datadog/ci/span.rb | 6 +- lib/datadog/ci/test.rb | 2 +- lib/datadog/ci/test_module.rb | 2 +- lib/datadog/ci/test_session.rb | 2 +- lib/datadog/ci/test_suite.rb | 2 +- .../{recorder.rb => component.rb} | 2 +- .../{null_recorder.rb => null_component.rb} | 6 +- sig/datadog/ci.rbs | 2 +- sig/datadog/ci/configuration/components.rbs | 4 +- sig/datadog/ci/span.rbs | 2 +- .../{recorder.rbs => component.rbs} | 2 +- .../{null_recorder.rbs => null_component.rbs} | 4 +- .../ci/configuration/components_spec.rb | 24 ++--- spec/datadog/ci/test_module_spec.rb | 6 +- spec/datadog/ci/test_session_spec.rb | 6 +- spec/datadog/ci/test_spec.rb | 6 +- spec/datadog/ci/test_suite_spec.rb | 12 +-- .../{recorder_spec.rb => component_spec.rb} | 98 +++++++++---------- ...ecorder_spec.rb => null_component_spec.rb} | 36 ++++--- .../serializers/factories/test_level_spec.rb | 4 +- .../factories/test_suite_level_spec.rb | 2 +- .../test_visibility/serializers/span_spec.rb | 4 +- .../serializers/test_module_spec.rb | 2 +- .../serializers/test_session_spec.rb | 2 +- .../serializers/test_suite_spec.rb | 2 +- .../serializers/test_v1_spec.rb | 4 +- .../serializers/test_v2_spec.rb | 6 +- spec/datadog/ci_spec.rb | 32 +++--- spec/support/contexts/ci_mode.rb | 6 +- 31 files changed, 165 insertions(+), 162 deletions(-) rename lib/datadog/ci/test_visibility/{recorder.rb => component.rb} (99%) rename lib/datadog/ci/test_visibility/{null_recorder.rb => null_component.rb} (90%) rename sig/datadog/ci/test_visibility/{recorder.rbs => component.rbs} (99%) rename sig/datadog/ci/test_visibility/{null_recorder.rbs => null_component.rbs} (94%) rename spec/datadog/ci/test_visibility/{recorder_spec.rb => component_spec.rb} (86%) rename spec/datadog/ci/test_visibility/{null_recorder_spec.rb => null_component_spec.rb} (62%) diff --git a/lib/datadog/ci.rb b/lib/datadog/ci.rb index d1516136..a45bdeba 100644 --- a/lib/datadog/ci.rb +++ b/lib/datadog/ci.rb @@ -39,7 +39,7 @@ class << self # @return [Datadog::CI::TestSession] the active, running {Datadog::CI::TestSession}. # @return [nil] if test suite level visibility is disabled or CI mode is disabled. def start_test_session(service: Utils::Configuration.fetch_service_name("test"), tags: {}) - recorder.start_test_session(service: service, tags: tags) + test_visibility.start_test_session(service: service, tags: tags) end # The active, unfinished test session. @@ -61,7 +61,7 @@ def start_test_session(service: Utils::Configuration.fetch_service_name("test"), # @return [Datadog::CI::TestSession] the active test session # @return [nil] if no test session is active def active_test_session - recorder.active_test_session + test_visibility.active_test_session end # Starts a {Datadog::CI::TestModule ci_test_module} that represents a single test module (for most Ruby test frameworks @@ -93,7 +93,7 @@ def active_test_session # @return [Datadog::CI::TestModule] the active, running {Datadog::CI::TestModule}. # @return [nil] if test suite level visibility is disabled or CI mode is disabled. def start_test_module(test_module_name, service: nil, tags: {}) - recorder.start_test_module(test_module_name, service: service, tags: tags) + test_visibility.start_test_module(test_module_name, service: service, tags: tags) end # The active, unfinished test module. @@ -116,7 +116,7 @@ def start_test_module(test_module_name, service: nil, tags: {}) # @return [Datadog::CI::TestModule] the active test module # @return [nil] if no test module is active def active_test_module - recorder.active_test_module + test_visibility.active_test_module end # Starts a {Datadog::CI::TestSuite ci_test_suite} that represents a single test suite. @@ -145,7 +145,7 @@ def active_test_module # @return [Datadog::CI::TestSuite] the active, running {Datadog::CI::TestSuite}. # @return [nil] if test suite level visibility is disabled or CI mode is disabled. def start_test_suite(test_suite_name, service: nil, tags: {}) - recorder.start_test_suite(test_suite_name, service: service, tags: tags) + test_visibility.start_test_suite(test_suite_name, service: service, tags: tags) end # The active, unfinished test suite. @@ -168,7 +168,7 @@ def start_test_suite(test_suite_name, service: nil, tags: {}) # @return [Datadog::CI::TestSuite] the active test suite # @return [nil] if no test suite with given name is active def active_test_suite(test_suite_name) - recorder.active_test_suite(test_suite_name) + test_visibility.active_test_suite(test_suite_name) end # Return a {Datadog::CI::Test ci_test} that will trace a test called `test_name`. @@ -222,7 +222,7 @@ def active_test_suite(test_suite_name) # @yieldparam [Datadog::CI::Test] ci_test the newly created and active [Datadog::CI::Test] # @yieldparam [nil] if CI mode is disabled def trace_test(test_name, test_suite_name, service: nil, tags: {}, &block) - recorder.trace_test(test_name, test_suite_name, service: service, tags: tags, &block) + test_visibility.trace_test(test_name, test_suite_name, service: service, tags: tags, &block) end # Same as {.trace_test} but it does not accept a block. @@ -248,7 +248,7 @@ def trace_test(test_name, test_suite_name, service: nil, tags: {}, &block) # @return [Datadog::CI::Test] the active, unfinished {Datadog::CI::Test}. # @return [nil] if CI mode is disabled. def start_test(test_name, test_suite_name, service: nil, tags: {}) - recorder.trace_test(test_name, test_suite_name, service: service, tags: tags) + test_visibility.trace_test(test_name, test_suite_name, service: service, tags: tags) end # Trace any custom span inside a test. For example, you could trace: @@ -300,7 +300,7 @@ def trace(span_name, type: "span", tags: {}, &block) ) end - recorder.trace(span_name, type: type, tags: tags, &block) + test_visibility.trace(span_name, type: type, tags: tags, &block) end # The active, unfinished custom (i.e. not test/suite/module/session) span. @@ -326,7 +326,7 @@ def trace(span_name, type: "span", tags: {}, &block) # @return [Datadog::CI::Span] the active span # @return [nil] if no span is active, or if the active span is not a custom span def active_span - span = recorder.active_span + span = test_visibility.active_span span if span && !Ext::AppTypes::CI_SPAN_TYPES.include?(span.type) end @@ -352,7 +352,7 @@ def active_span # @return [Datadog::CI::Test] the active test # @return [nil] if no test is active def active_test - recorder.active_test + test_visibility.active_test end private @@ -361,8 +361,8 @@ def components Datadog.send(:components) end - def recorder - components.ci_recorder + def test_visibility + components.test_visibility end def itr_runner diff --git a/lib/datadog/ci/configuration/components.rb b/lib/datadog/ci/configuration/components.rb index 24717f62..7dcb5559 100644 --- a/lib/datadog/ci/configuration/components.rb +++ b/lib/datadog/ci/configuration/components.rb @@ -5,9 +5,9 @@ require_relative "../itr/runner" require_relative "../itr/coverage/transport" require_relative "../itr/coverage/writer" +require_relative "../test_visibility/component" require_relative "../test_visibility/flush" -require_relative "../test_visibility/recorder" -require_relative "../test_visibility/null_recorder" +require_relative "../test_visibility/null_component" require_relative "../test_visibility/serializers/factories/test_level" require_relative "../test_visibility/serializers/factories/test_suite_level" require_relative "../test_visibility/transport" @@ -21,11 +21,11 @@ module CI module Configuration # Adds CI behavior to Datadog trace components module Components - attr_reader :ci_recorder, :itr + attr_reader :test_visibility, :itr def initialize(settings) @itr = nil - @ci_recorder = TestVisibility::NullRecorder.new + @test_visibility = TestVisibility::NullComponent.new # Activate CI mode if enabled if settings.ci.enabled @@ -38,7 +38,7 @@ def initialize(settings) def shutdown!(replacement = nil) super - @ci_recorder&.shutdown! + @test_visibility&.shutdown! @itr&.shutdown! end @@ -110,8 +110,7 @@ def activate_ci!(settings) use_single_threaded_coverage: settings.ci.itr_code_coverage_use_single_threaded_mode ) - # CI visibility recorder global instance - @ci_recorder = TestVisibility::Recorder.new( + @test_visibility = TestVisibility::Component.new( test_suite_level_visibility_enabled: !settings.ci.force_test_level_visibility, itr: @itr, remote_settings_api: build_remote_settings_client(settings, test_visibility_api), diff --git a/lib/datadog/ci/span.rb b/lib/datadog/ci/span.rb index f0bf8bc2..430e509a 100644 --- a/lib/datadog/ci/span.rb +++ b/lib/datadog/ci/span.rb @@ -202,9 +202,9 @@ def to_s private - # provides access to global CI recorder for CI models to deactivate themselves - def recorder - Datadog.send(:components).ci_recorder + # provides access to the test visibility component for CI models to deactivate themselves + def test_visibility + Datadog.send(:components).test_visibility end end end diff --git a/lib/datadog/ci/test.rb b/lib/datadog/ci/test.rb index 7c228da9..936ea9fb 100644 --- a/lib/datadog/ci/test.rb +++ b/lib/datadog/ci/test.rb @@ -19,7 +19,7 @@ def name # Finishes the current test. # @return [void] def finish - recorder.deactivate_test + test_visibility.deactivate_test super end diff --git a/lib/datadog/ci/test_module.rb b/lib/datadog/ci/test_module.rb index 5c44f0d1..1e2574fb 100644 --- a/lib/datadog/ci/test_module.rb +++ b/lib/datadog/ci/test_module.rb @@ -14,7 +14,7 @@ class TestModule < ConcurrentSpan # Finishes this test module. # @return [void] def finish - recorder.deactivate_test_module + test_visibility.deactivate_test_module super end diff --git a/lib/datadog/ci/test_session.rb b/lib/datadog/ci/test_session.rb index 125d014c..720b9cfc 100644 --- a/lib/datadog/ci/test_session.rb +++ b/lib/datadog/ci/test_session.rb @@ -15,7 +15,7 @@ class TestSession < ConcurrentSpan # Finishes the current test session. # @return [void] def finish - recorder.deactivate_test_session + test_visibility.deactivate_test_session super end diff --git a/lib/datadog/ci/test_suite.rb b/lib/datadog/ci/test_suite.rb index f5557d3d..df9e61d0 100644 --- a/lib/datadog/ci/test_suite.rb +++ b/lib/datadog/ci/test_suite.rb @@ -26,7 +26,7 @@ def finish # we try to derive test suite status from execution stats if no status was set explicitly set_status_from_stats! if undefined? - recorder.deactivate_test_suite(name) + test_visibility.deactivate_test_suite(name) super end diff --git a/lib/datadog/ci/test_visibility/recorder.rb b/lib/datadog/ci/test_visibility/component.rb similarity index 99% rename from lib/datadog/ci/test_visibility/recorder.rb rename to lib/datadog/ci/test_visibility/component.rb index ac26d4be..ca02e64a 100644 --- a/lib/datadog/ci/test_visibility/recorder.rb +++ b/lib/datadog/ci/test_visibility/component.rb @@ -28,7 +28,7 @@ module CI module TestVisibility # Common behavior for CI tests # Note: this class has too many responsibilities and should be split into multiple classes - class Recorder + class Component attr_reader :environment_tags, :test_suite_level_visibility_enabled def initialize( diff --git a/lib/datadog/ci/test_visibility/null_recorder.rb b/lib/datadog/ci/test_visibility/null_component.rb similarity index 90% rename from lib/datadog/ci/test_visibility/null_recorder.rb rename to lib/datadog/ci/test_visibility/null_component.rb index b2c05ede..59051b83 100644 --- a/lib/datadog/ci/test_visibility/null_recorder.rb +++ b/lib/datadog/ci/test_visibility/null_component.rb @@ -1,12 +1,10 @@ # frozen_string_literal: true -require_relative "recorder" - module Datadog module CI module TestVisibility - # Special recorder that does not record anything - class NullRecorder + # Special test visibility component that does not record anything + class NullComponent def start_test_session(service: nil, tags: {}) skip_tracing end diff --git a/sig/datadog/ci.rbs b/sig/datadog/ci.rbs index de8c3194..993b57cb 100644 --- a/sig/datadog/ci.rbs +++ b/sig/datadog/ci.rbs @@ -29,7 +29,7 @@ module Datadog def self.components: () -> Datadog::CI::Configuration::Components - def self.recorder: () -> (Datadog::CI::TestVisibility::Recorder | Datadog::CI::TestVisibility::NullRecorder) + def self.test_visibility: () -> (Datadog::CI::TestVisibility::Component | Datadog::CI::TestVisibility::NullComponent) def self.itr_runner: () -> Datadog::CI::ITR::Runner? end diff --git a/sig/datadog/ci/configuration/components.rbs b/sig/datadog/ci/configuration/components.rbs index 6f244df5..8845f844 100644 --- a/sig/datadog/ci/configuration/components.rbs +++ b/sig/datadog/ci/configuration/components.rbs @@ -2,11 +2,11 @@ module Datadog module CI module Configuration module Components : Datadog::Core::Configuration::Components - @ci_recorder: Datadog::CI::TestVisibility::Recorder | Datadog::CI::TestVisibility::NullRecorder + @test_visibility: Datadog::CI::TestVisibility::Component | Datadog::CI::TestVisibility::NullComponent @itr: Datadog::CI::ITR::Runner? @custom_configuration: Hash[String, String] - attr_reader ci_recorder: Datadog::CI::TestVisibility::Recorder | Datadog::CI::TestVisibility::NullRecorder + attr_reader test_visibility: Datadog::CI::TestVisibility::Component | Datadog::CI::TestVisibility::NullComponent attr_reader itr: Datadog::CI::ITR::Runner? def initialize: (untyped settings) -> void diff --git a/sig/datadog/ci/span.rbs b/sig/datadog/ci/span.rbs index cfc69a6b..53525bd5 100644 --- a/sig/datadog/ci/span.rbs +++ b/sig/datadog/ci/span.rbs @@ -67,7 +67,7 @@ module Datadog private - def recorder: () -> Datadog::CI::TestVisibility::Recorder + def test_visibility: () -> Datadog::CI::TestVisibility::Component end end end diff --git a/sig/datadog/ci/test_visibility/recorder.rbs b/sig/datadog/ci/test_visibility/component.rbs similarity index 99% rename from sig/datadog/ci/test_visibility/recorder.rbs rename to sig/datadog/ci/test_visibility/component.rbs index f7bf5c54..0193bbda 100644 --- a/sig/datadog/ci/test_visibility/recorder.rbs +++ b/sig/datadog/ci/test_visibility/component.rbs @@ -1,7 +1,7 @@ module Datadog module CI module TestVisibility - class Recorder + class Component @test_suite_level_visibility_enabled: bool @environment_tags: Hash[String, String] diff --git a/sig/datadog/ci/test_visibility/null_recorder.rbs b/sig/datadog/ci/test_visibility/null_component.rbs similarity index 94% rename from sig/datadog/ci/test_visibility/null_recorder.rbs rename to sig/datadog/ci/test_visibility/null_component.rbs index a9132de0..bb427d71 100644 --- a/sig/datadog/ci/test_visibility/null_recorder.rbs +++ b/sig/datadog/ci/test_visibility/null_component.rbs @@ -1,7 +1,7 @@ module Datadog module CI module TestVisibility - class NullRecorder + class NullComponent def initialize: (?untyped args) -> void def trace_test: (String span_name, String test_suite_name, ?service: String?, ?tags: Hash[untyped, untyped]) ?{ (nil span) -> untyped } -> untyped @@ -26,6 +26,8 @@ module Datadog def shutdown!: () -> nil + def itr_enabled?: () -> bool + private def skip_tracing: (?untyped block) -> nil diff --git a/spec/datadog/ci/configuration/components_spec.rb b/spec/datadog/ci/configuration/components_spec.rb index ff9e2e36..7b077a9b 100644 --- a/spec/datadog/ci/configuration/components_spec.rb +++ b/spec/datadog/ci/configuration/components_spec.rb @@ -119,18 +119,18 @@ let(:evp_proxy_v2_supported) { true } context "is false" do - it "creates a CI recorder with test_suite_level_visibility_enabled=true" do - expect(components.ci_recorder).to be_kind_of(Datadog::CI::TestVisibility::Recorder) - expect(components.ci_recorder.test_suite_level_visibility_enabled).to eq(true) + it "creates test visibility component with test_suite_level_visibility_enabled=true" do + expect(components.test_visibility).to be_kind_of(Datadog::CI::TestVisibility::Component) + expect(components.test_visibility.test_suite_level_visibility_enabled).to eq(true) end end context "is true" do let(:force_test_level_visibility) { true } - it "creates a CI recorder with test_suite_level_visibility_enabled=false" do - expect(components.ci_recorder).to be_kind_of(Datadog::CI::TestVisibility::Recorder) - expect(components.ci_recorder.test_suite_level_visibility_enabled).to eq(false) + it "creates test visibility component with test_suite_level_visibility_enabled=false" do + expect(components.test_visibility).to be_kind_of(Datadog::CI::TestVisibility::Component) + expect(components.test_visibility.test_suite_level_visibility_enabled).to eq(false) end end end @@ -190,7 +190,7 @@ expect(options[:transport]).to be_nil end - expect(components.ci_recorder.itr_enabled?).to eq(false) + expect(components.test_visibility.itr_enabled?).to eq(false) end end end @@ -239,16 +239,16 @@ context "when ITR is disabled" do let(:itr_enabled) { false } - it "creates a CI recorder with ITR disabled" do - expect(components.ci_recorder.itr_enabled?).to eq(false) + it "creates test visibility component with ITR disabled" do + expect(components.test_visibility.itr_enabled?).to eq(false) end end context "when ITR is enabled" do let(:itr_enabled) { true } - it "creates a CI recorder with ITR enabled" do - expect(components.ci_recorder.itr_enabled?).to eq(true) + it "creates test visibility component with ITR enabled" do + expect(components.test_visibility.itr_enabled?).to eq(true) end end end @@ -261,7 +261,7 @@ expect(Datadog.logger).to have_received(:error) expect(settings.ci.enabled).to eq(false) - expect(components.ci_recorder.itr_enabled?).to eq(false) + expect(components.test_visibility.itr_enabled?).to eq(false) end end end diff --git a/spec/datadog/ci/test_module_spec.rb b/spec/datadog/ci/test_module_spec.rb index 9b4d97ff..a2733e11 100644 --- a/spec/datadog/ci/test_module_spec.rb +++ b/spec/datadog/ci/test_module_spec.rb @@ -2,9 +2,9 @@ RSpec.describe Datadog::CI::TestModule do let(:tracer_span) { instance_double(Datadog::Tracing::SpanOperation, finish: true) } - let(:recorder) { spy("recorder") } + let(:test_visibility) { spy("test_visibility") } - before { allow_any_instance_of(described_class).to receive(:recorder).and_return(recorder) } + before { allow_any_instance_of(described_class).to receive(:test_visibility).and_return(test_visibility) } describe "#finish" do subject(:ci_test_module) { described_class.new(tracer_span) } @@ -12,7 +12,7 @@ it "deactivates the test module" do ci_test_module.finish - expect(recorder).to have_received(:deactivate_test_module) + expect(test_visibility).to have_received(:deactivate_test_module) end end end diff --git a/spec/datadog/ci/test_session_spec.rb b/spec/datadog/ci/test_session_spec.rb index c20a18ec..ae2f0642 100644 --- a/spec/datadog/ci/test_session_spec.rb +++ b/spec/datadog/ci/test_session_spec.rb @@ -2,16 +2,16 @@ RSpec.describe Datadog::CI::TestSession do let(:tracer_span) { Datadog::Tracing::SpanOperation.new("session") } - let(:recorder) { spy("recorder") } + let(:test_visibility) { spy("test_visibility") } - before { allow_any_instance_of(described_class).to receive(:recorder).and_return(recorder) } + before { allow_any_instance_of(described_class).to receive(:test_visibility).and_return(test_visibility) } subject(:ci_test_session) { described_class.new(tracer_span) } describe "#finish" do it "deactivates the test session" do ci_test_session.finish - expect(recorder).to have_received(:deactivate_test_session) + expect(test_visibility).to have_received(:deactivate_test_session) end end diff --git a/spec/datadog/ci/test_spec.rb b/spec/datadog/ci/test_spec.rb index 3372c0f2..64c6806a 100644 --- a/spec/datadog/ci/test_spec.rb +++ b/spec/datadog/ci/test_spec.rb @@ -2,10 +2,10 @@ RSpec.describe Datadog::CI::Test do let(:tracer_span) { instance_double(Datadog::Tracing::SpanOperation, finish: true) } - let(:recorder) { spy("recorder") } + let(:test_visibility) { spy("test_visibility") } subject(:ci_test) { described_class.new(tracer_span) } - before { allow_any_instance_of(described_class).to receive(:recorder).and_return(recorder) } + before { allow_any_instance_of(described_class).to receive(:test_visibility).and_return(test_visibility) } describe "#name" do subject(:name) { ci_test.name } @@ -18,7 +18,7 @@ describe "#finish" do it "deactivates the test" do ci_test.finish - expect(recorder).to have_received(:deactivate_test) + expect(test_visibility).to have_received(:deactivate_test) end end diff --git a/spec/datadog/ci/test_suite_spec.rb b/spec/datadog/ci/test_suite_spec.rb index 5a144f68..5e8c4bb2 100644 --- a/spec/datadog/ci/test_suite_spec.rb +++ b/spec/datadog/ci/test_suite_spec.rb @@ -3,9 +3,9 @@ RSpec.describe Datadog::CI::TestSuite do let(:test_suite_name) { "my.suite" } let(:tracer_span) { instance_double(Datadog::Tracing::SpanOperation, finish: true, name: test_suite_name) } - let(:recorder) { spy("recorder") } + let(:test_visibility) { spy("test_visibility") } - before { allow_any_instance_of(described_class).to receive(:recorder).and_return(recorder) } + before { allow_any_instance_of(described_class).to receive(:test_visibility).and_return(test_visibility) } subject(:ci_test_suite) { described_class.new(tracer_span) } describe "#record_test_result" do @@ -47,7 +47,7 @@ it "deactivates the test suite" do finish - expect(recorder).to have_received(:deactivate_test_suite).with(test_suite_name) + expect(test_visibility).to have_received(:deactivate_test_suite).with(test_suite_name) end end @@ -67,7 +67,7 @@ finish - expect(recorder).to have_received(:deactivate_test_suite).with(test_suite_name) + expect(test_visibility).to have_received(:deactivate_test_suite).with(test_suite_name) end end @@ -83,7 +83,7 @@ finish - expect(recorder).to have_received(:deactivate_test_suite).with(test_suite_name) + expect(test_visibility).to have_received(:deactivate_test_suite).with(test_suite_name) end end @@ -102,7 +102,7 @@ finish - expect(recorder).to have_received(:deactivate_test_suite).with(test_suite_name) + expect(test_visibility).to have_received(:deactivate_test_suite).with(test_suite_name) end end end diff --git a/spec/datadog/ci/test_visibility/recorder_spec.rb b/spec/datadog/ci/test_visibility/component_spec.rb similarity index 86% rename from spec/datadog/ci/test_visibility/recorder_spec.rb rename to spec/datadog/ci/test_visibility/component_spec.rb index 32079ba2..008a4fe2 100644 --- a/spec/datadog/ci/test_visibility/recorder_spec.rb +++ b/spec/datadog/ci/test_visibility/component_spec.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -require_relative "../../../../lib/datadog/ci/test_visibility/recorder" +require_relative "../../../../lib/datadog/ci/test_visibility/component" -RSpec.describe Datadog::CI::TestVisibility::Recorder do +RSpec.describe Datadog::CI::TestVisibility::Component do shared_examples_for "trace with ciapp-test origin" do let(:trace_under_test) { subject } @@ -57,36 +57,36 @@ end describe "#trace_test_session" do - subject { recorder.start_test_session(service: service, tags: tags) } + subject { test_visibility.start_test_session(service: service, tags: tags) } it { is_expected.to be_nil } it "does not activate session" do - expect(recorder.active_test_session).to be_nil + expect(test_visibility.active_test_session).to be_nil end end describe "#trace_test_module" do let(:module_name) { "my-module" } - subject { recorder.start_test_module(module_name, service: service, tags: tags) } + subject { test_visibility.start_test_module(module_name, service: service, tags: tags) } it { is_expected.to be_nil } it "does not activate module" do - expect(recorder.active_test_module).to be_nil + expect(test_visibility.active_test_module).to be_nil end end describe "#trace_test_suite" do let(:suite_name) { "my-module" } - subject { recorder.start_test_suite(suite_name, service: service, tags: tags) } + subject { test_visibility.start_test_suite(suite_name, service: service, tags: tags) } it { is_expected.to be_nil } it "does not activate test suite" do - expect(recorder.active_test_suite(suite_name)).to be_nil + expect(test_visibility.active_test_suite(suite_name)).to be_nil end end @@ -97,7 +97,7 @@ context "when given a block" do before do - recorder.trace(span_name, type: type, tags: tags) do |span| + test_visibility.trace(span_name, type: type, tags: tags) do |span| span.set_metric("my.metric", 42) end end @@ -122,7 +122,7 @@ context "when given a block" do before do - recorder.trace(span_name, type: type, tags: tags) do |span| + test_visibility.trace(span_name, type: type, tags: tags) do |span| span.set_metric("my.metric", 42) end end @@ -148,7 +148,7 @@ end context "without a block" do - subject { recorder.trace("my test step", type: type, tags: tags) } + subject { test_visibility.trace("my test step", type: type, tags: tags) } it "returns a new CI span" do expect(subject).to be_kind_of(Datadog::CI::Span) @@ -180,7 +180,7 @@ context "without a block" do subject do - recorder.trace_test( + test_visibility.trace_test( test_name, test_suite_name, service: test_service, @@ -228,7 +228,7 @@ let(:session_service) { "my-session-service" } let(:test_service) { nil } - let(:test_session) { recorder.start_test_session(service: session_service, tags: test_session_tags) } + let(:test_session) { test_visibility.start_test_session(service: session_service, tags: test_session_tags) } before do test_session @@ -273,7 +273,7 @@ let(:module_name) { "my-module" } let(:test_module) do - recorder.start_test_module(module_name) + test_visibility.start_test_module(module_name) end before do @@ -298,7 +298,7 @@ context "when there is an active test suite" do let(:test_suite) do - recorder.start_test_suite(test_suite_name) + test_visibility.start_test_suite(test_suite_name) end before do @@ -313,7 +313,7 @@ context "when there is a running test suite but with a different name" do let(:test_suite) do - recorder.start_test_suite("other suite") + test_visibility.start_test_suite("other suite") end before do @@ -328,8 +328,8 @@ context "when there are several running test suites with different names" do before do - recorder.start_test_suite("other suite") - recorder.start_test_suite("other other suite") + test_visibility.start_test_suite("other suite") + test_visibility.start_test_suite("other other suite") end it "does not connect test to test suite" do @@ -342,7 +342,7 @@ context "when given a block" do before do - recorder.trace_test( + test_visibility.trace_test( test_name, test_suite_name, service: test_service, @@ -384,7 +384,7 @@ let(:service) { "my-service" } let(:tags) { {"test.framework" => "my-framework", "my.tag" => "my_value"} } - subject { recorder.start_test_session(service: service, tags: tags) } + subject { test_visibility.start_test_session(service: service, tags: tags) } it "returns a new CI test_session span" do expect(subject).to be_kind_of(Datadog::CI::TestSession) @@ -436,7 +436,7 @@ let(:service) { "my-service" } let(:tags) { {"test.framework" => "my-framework", "my.tag" => "my_value"} } - subject { recorder.start_test_module(module_name, service: service, tags: tags) } + subject { test_visibility.start_test_module(module_name, service: service, tags: tags) } context "when there is no active test session" do it "returns a new CI test_module span" do @@ -479,7 +479,7 @@ let(:service) { nil } let(:session_service) { "session_service" } let(:session_tags) { {"test.framework_version" => "1.0", "my.session.tag" => "my_session_value"} } - let(:test_session) { recorder.start_test_session(service: session_service, tags: session_tags) } + let(:test_session) { test_visibility.start_test_session(service: session_service, tags: session_tags) } before do test_session @@ -513,8 +513,8 @@ let(:session_service) { "session_service" } let(:session_tags) { {"test.framework_version" => "1.0", "my.session.tag" => "my_session_value"} } - let(:test_session) { recorder.start_test_session(service: session_service, tags: session_tags) } - let(:test_module) { recorder.start_test_module(module_name) } + let(:test_session) { test_visibility.start_test_session(service: session_service, tags: session_tags) } + let(:test_module) { test_visibility.start_test_module(module_name) } before do test_session @@ -525,7 +525,7 @@ let(:suite_name) { "my-suite" } let(:tags) { {"my.tag" => "my_value"} } - subject { recorder.start_test_suite(suite_name, tags: tags) } + subject { test_visibility.start_test_suite(suite_name, tags: tags) } it "returns a new CI test_suite span" do expect(subject).to be_kind_of(Datadog::CI::TestSuite) @@ -559,13 +559,13 @@ context "when test suite with given name is already started" do let(:suite_name) { "my-suite" } let(:tags) { {"my.tag" => "my_value"} } - let(:already_running_test_suite) { recorder.start_test_suite(suite_name, tags: tags) } + let(:already_running_test_suite) { test_visibility.start_test_suite(suite_name, tags: tags) } before do already_running_test_suite end - subject { recorder.start_test_suite(suite_name) } + subject { test_visibility.start_test_suite(suite_name) } it "returns the already running test suite" do expect(subject.id).to eq(already_running_test_suite.id) @@ -575,13 +575,13 @@ end describe "#active_test_session" do - subject { recorder.active_test_session } + subject { test_visibility.active_test_session } context "when there is no active test session" do it { is_expected.to be_nil } end context "when test session is started" do - let(:test_session) { recorder.start_test_session } + let(:test_session) { test_visibility.start_test_session } before do test_session end @@ -593,13 +593,13 @@ end describe "#active_test_module" do - subject { recorder.active_test_module } + subject { test_visibility.active_test_module } context "when there is no active test module" do it { is_expected.to be_nil } end context "when test module is started" do - let(:test_module) { recorder.start_test_module("my module") } + let(:test_module) { test_visibility.start_test_module("my module") } before do test_module end @@ -611,14 +611,14 @@ end describe "#active_test" do - subject { recorder.active_test } + subject { test_visibility.active_test } context "when there is no active test" do it { is_expected.to be_nil } end context "when test is started" do - let(:ci_test) { recorder.trace_test("my test", "my suite") } + let(:ci_test) { test_visibility.trace_test("my test", "my suite") } before do ci_test @@ -631,14 +631,14 @@ end describe "#active_span" do - subject { recorder.active_span } + subject { test_visibility.active_span } context "when there is no active span" do it { is_expected.to be_nil } end context "when span is started" do - let(:ci_span) { recorder.trace("my test step", type: "step") } + let(:ci_span) { test_visibility.trace("my test step", type: "step") } before do ci_span @@ -652,7 +652,7 @@ end describe "#deactivate_test" do - subject { recorder.deactivate_test } + subject { test_visibility.deactivate_test } context "when there is no active test" do let(:ci_test) { Datadog::CI::Test.new(double("tracer span")) } @@ -661,18 +661,18 @@ end context "when deactivating the currently active test" do - let(:ci_test) { recorder.trace_test("my test", "my suite") } + let(:ci_test) { test_visibility.trace_test("my test", "my suite") } it "deactivates the test" do subject - expect(recorder.active_test).to be_nil + expect(test_visibility.active_test).to be_nil end end end describe "#deactivate_test_session" do - subject { recorder.deactivate_test_session } + subject { test_visibility.deactivate_test_session } context "when there is no active test session" do it { is_expected.to be_nil } @@ -680,19 +680,19 @@ context "when deactivating the currently active test session" do before do - recorder.start_test_session + test_visibility.start_test_session end it "deactivates the test session" do subject - expect(recorder.active_test_session).to be_nil + expect(test_visibility.active_test_session).to be_nil end end end describe "#deactivate_test_module" do - subject { recorder.deactivate_test_module } + subject { test_visibility.deactivate_test_module } context "when there is no active test module" do it { is_expected.to be_nil } @@ -700,19 +700,19 @@ context "when deactivating the currently active test module" do before do - recorder.start_test_module("my module") + test_visibility.start_test_module("my module") end it "deactivates the test module" do subject - expect(recorder.active_test_module).to be_nil + expect(test_visibility.active_test_module).to be_nil end end end describe "#deactivate_test_suite" do - subject { recorder.deactivate_test_suite("my suite") } + subject { test_visibility.deactivate_test_suite("my suite") } context "when there is no active test suite" do it { is_expected.to be_nil } @@ -720,13 +720,13 @@ context "when deactivating the currently active test suite" do before do - recorder.start_test_suite("my suite") + test_visibility.start_test_suite("my suite") end it "deactivates the test suite" do subject - expect(recorder.active_test_suite("my suite")).to be_nil + expect(test_visibility.active_test_suite("my suite")).to be_nil end end end @@ -744,7 +744,7 @@ let(:service) { "my-service" } let(:tags) { {"test.framework" => "my-framework", "my.tag" => "my_value"} } - subject { recorder.start_test_session(service: service, tags: tags) } + subject { test_visibility.start_test_session(service: service, tags: tags) } it "returns a new CI test_session span with ITR tags" do expect(subject).to be_kind_of(Datadog::CI::TestSession) @@ -768,7 +768,7 @@ let(:service) { "my-service" } let(:tags) { {"test.framework" => "my-framework", "my.tag" => "my_value"} } - subject { recorder.start_test_session(service: service, tags: tags) } + subject { test_visibility.start_test_session(service: service, tags: tags) } it { is_expected.not_to be_skipping_tests } end diff --git a/spec/datadog/ci/test_visibility/null_recorder_spec.rb b/spec/datadog/ci/test_visibility/null_component_spec.rb similarity index 62% rename from spec/datadog/ci/test_visibility/null_recorder_spec.rb rename to spec/datadog/ci/test_visibility/null_component_spec.rb index 35ede237..9ece893d 100644 --- a/spec/datadog/ci/test_visibility/null_recorder_spec.rb +++ b/spec/datadog/ci/test_visibility/null_component_spec.rb @@ -1,37 +1,41 @@ -RSpec.describe Datadog::CI::TestVisibility::NullRecorder do - let(:recorder) { described_class.new } +# frozen_string_literal: true + +require_relative "../../../../lib/datadog/ci/test_visibility/null_component" + +RSpec.describe Datadog::CI::TestVisibility::NullComponent do + let(:test_visibility) { described_class.new } describe "#start_test_session" do - subject { recorder.start_test_session } + subject { test_visibility.start_test_session } it { is_expected.to be_nil } it "does not activate session" do - expect(recorder.active_test_session).to be_nil + expect(test_visibility.active_test_session).to be_nil end end describe "#start_test_module" do let(:module_name) { "my-module" } - subject { recorder.start_test_module(module_name) } + subject { test_visibility.start_test_module(module_name) } it { is_expected.to be_nil } it "does not activate module" do - expect(recorder.active_test_module).to be_nil + expect(test_visibility.active_test_module).to be_nil end end describe "#start_test_suite" do let(:suite_name) { "my-module" } - subject { recorder.start_test_suite(suite_name) } + subject { test_visibility.start_test_suite(suite_name) } it { is_expected.to be_nil } it "does not activate test suite" do - expect(recorder.active_test_suite(suite_name)).to be_nil + expect(test_visibility.active_test_suite(suite_name)).to be_nil end end @@ -40,7 +44,7 @@ let(:spy_under_test) { spy("spy") } before do - recorder.trace_test("my test", "my suite") do |test_span| + test_visibility.trace_test("my test", "my suite") do |test_span| spy_under_test.call test_span&.passed! @@ -57,7 +61,7 @@ end context "without a block" do - subject { recorder.trace_test("my test", "my suite") } + subject { test_visibility.trace_test("my test", "my suite") } it { is_expected.to be_nil } end @@ -68,7 +72,7 @@ let(:spy_under_test) { spy("spy") } before do - recorder.trace("my step", type: "step") do |span| + test_visibility.trace("my step", type: "step") do |span| spy_under_test.call span&.set_metric("my.metric", 42) @@ -85,31 +89,31 @@ end context "without a block" do - subject { recorder.trace("my step", type: "step") } + subject { test_visibility.trace("my step", type: "step") } it { is_expected.to be_nil } end end describe "#active_test_session" do - subject { recorder.active_test_session } + subject { test_visibility.active_test_session } it { is_expected.to be_nil } end describe "#active_test_module" do - subject { recorder.active_test_module } + subject { test_visibility.active_test_module } it { is_expected.to be_nil } end describe "#active_test" do - subject { recorder.active_test } + subject { test_visibility.active_test } it { is_expected.to be_nil } end describe "#active_span" do - subject { recorder.active_span } + subject { test_visibility.active_span } it { is_expected.to be_nil } end diff --git a/spec/datadog/ci/test_visibility/serializers/factories/test_level_spec.rb b/spec/datadog/ci/test_visibility/serializers/factories/test_level_spec.rb index 4158a1a5..63e59b9a 100644 --- a/spec/datadog/ci/test_visibility/serializers/factories/test_level_spec.rb +++ b/spec/datadog/ci/test_visibility/serializers/factories/test_level_spec.rb @@ -1,6 +1,6 @@ require_relative "../../../../../../lib/datadog/ci/test_visibility/serializers/factories/test_level" require_relative "../../../../../../lib/datadog/ci/test_visibility/serializers/test_v1" -require_relative "../../../../../../lib/datadog/ci/test_visibility/recorder" +require_relative "../../../../../../lib/datadog/ci/test_visibility/component" RSpec.describe Datadog::CI::TestVisibility::Serializers::Factories::TestLevel do include_context "CI mode activated" do @@ -10,7 +10,7 @@ subject { described_class.serializer(trace_for_span(span), span) } describe ".convert_trace_to_serializable_events" do - context "traced a single test execution with Recorder" do + context "traced a single test execution with test visibility" do before do produce_test_trace end diff --git a/spec/datadog/ci/test_visibility/serializers/factories/test_suite_level_spec.rb b/spec/datadog/ci/test_visibility/serializers/factories/test_suite_level_spec.rb index 42d155be..dbeffbee 100644 --- a/spec/datadog/ci/test_visibility/serializers/factories/test_suite_level_spec.rb +++ b/spec/datadog/ci/test_visibility/serializers/factories/test_suite_level_spec.rb @@ -1,7 +1,7 @@ require_relative "../../../../../../lib/datadog/ci/test_visibility/serializers/factories/test_suite_level" require_relative "../../../../../../lib/datadog/ci/test_visibility/serializers/test_v2" require_relative "../../../../../../lib/datadog/ci/test_visibility/serializers/test_session" -require_relative "../../../../../../lib/datadog/ci/test_visibility/recorder" +require_relative "../../../../../../lib/datadog/ci/test_visibility/component" RSpec.describe Datadog::CI::TestVisibility::Serializers::Factories::TestSuiteLevel do include_context "CI mode activated" do diff --git a/spec/datadog/ci/test_visibility/serializers/span_spec.rb b/spec/datadog/ci/test_visibility/serializers/span_spec.rb index 7041ad39..806ae859 100644 --- a/spec/datadog/ci/test_visibility/serializers/span_spec.rb +++ b/spec/datadog/ci/test_visibility/serializers/span_spec.rb @@ -1,5 +1,5 @@ require_relative "../../../../../lib/datadog/ci/test_visibility/serializers/span" -require_relative "../../../../../lib/datadog/ci/test_visibility/recorder" +require_relative "../../../../../lib/datadog/ci/test_visibility/component" RSpec.describe Datadog::CI::TestVisibility::Serializers::Span do include_context "CI mode activated" do @@ -11,7 +11,7 @@ end describe "#to_msgpack" do - context "traced a single test execution with Recorder" do + context "traced a single test execution with test visibility" do before do produce_test_trace(with_http_span: true) end diff --git a/spec/datadog/ci/test_visibility/serializers/test_module_spec.rb b/spec/datadog/ci/test_visibility/serializers/test_module_spec.rb index d27939d2..fd523188 100644 --- a/spec/datadog/ci/test_visibility/serializers/test_module_spec.rb +++ b/spec/datadog/ci/test_visibility/serializers/test_module_spec.rb @@ -8,7 +8,7 @@ end describe "#to_msgpack" do - context "traced a single test execution with Recorder" do + context "traced a single test execution with test visibility" do before do produce_test_session_trace end diff --git a/spec/datadog/ci/test_visibility/serializers/test_session_spec.rb b/spec/datadog/ci/test_visibility/serializers/test_session_spec.rb index 70cb3196..1ce055a9 100644 --- a/spec/datadog/ci/test_visibility/serializers/test_session_spec.rb +++ b/spec/datadog/ci/test_visibility/serializers/test_session_spec.rb @@ -8,7 +8,7 @@ end describe "#to_msgpack" do - context "traced a single test execution with Recorder" do + context "traced a single test execution with test visibility" do before do produce_test_session_trace end diff --git a/spec/datadog/ci/test_visibility/serializers/test_suite_spec.rb b/spec/datadog/ci/test_visibility/serializers/test_suite_spec.rb index a853c009..2f31b2c4 100644 --- a/spec/datadog/ci/test_visibility/serializers/test_suite_spec.rb +++ b/spec/datadog/ci/test_visibility/serializers/test_suite_spec.rb @@ -8,7 +8,7 @@ end describe "#to_msgpack" do - context "traced a single test execution with Recorder" do + context "traced a single test execution with test visibility" do before do produce_test_session_trace end diff --git a/spec/datadog/ci/test_visibility/serializers/test_v1_spec.rb b/spec/datadog/ci/test_visibility/serializers/test_v1_spec.rb index fdb66f10..2c7ddeb9 100644 --- a/spec/datadog/ci/test_visibility/serializers/test_v1_spec.rb +++ b/spec/datadog/ci/test_visibility/serializers/test_v1_spec.rb @@ -1,5 +1,5 @@ require_relative "../../../../../lib/datadog/ci/test_visibility/serializers/test_v1" -require_relative "../../../../../lib/datadog/ci/test_visibility/recorder" +require_relative "../../../../../lib/datadog/ci/test_visibility/component" RSpec.describe Datadog::CI::TestVisibility::Serializers::TestV1 do include_context "CI mode activated" do @@ -11,7 +11,7 @@ end describe "#to_msgpack" do - context "traced a single test execution with Recorder" do + context "traced a single test execution with test visibility" do before do produce_test_trace end diff --git a/spec/datadog/ci/test_visibility/serializers/test_v2_spec.rb b/spec/datadog/ci/test_visibility/serializers/test_v2_spec.rb index e1ea14f8..5577110b 100644 --- a/spec/datadog/ci/test_visibility/serializers/test_v2_spec.rb +++ b/spec/datadog/ci/test_visibility/serializers/test_v2_spec.rb @@ -1,5 +1,5 @@ require_relative "../../../../../lib/datadog/ci/test_visibility/serializers/test_v2" -require_relative "../../../../../lib/datadog/ci/test_visibility/recorder" +require_relative "../../../../../lib/datadog/ci/test_visibility/component" RSpec.describe Datadog::CI::TestVisibility::Serializers::TestV2 do include_context "CI mode activated" do @@ -12,7 +12,7 @@ end describe "#to_msgpack" do - context "traced a single test execution with Recorder" do + context "traced a single test execution with test visibility" do before do produce_test_session_trace end @@ -53,7 +53,7 @@ end end - context "trace several tests executions with Recorder" do + context "trace several tests executions with test visibility" do let(:test_spans) { spans.select { |span| span.type == "test" } } subject { test_spans.map { |span| described_class.new(trace_for_span(span), span) } } diff --git a/spec/datadog/ci_spec.rb b/spec/datadog/ci_spec.rb index 33b596fe..81468f02 100644 --- a/spec/datadog/ci_spec.rb +++ b/spec/datadog/ci_spec.rb @@ -1,9 +1,9 @@ RSpec.describe Datadog::CI do - context "with recorder stubbed" do - let(:recorder) { instance_double(Datadog::CI::TestVisibility::Recorder) } + context "with test visibility stubbed" do + let(:test_visibility) { instance_double(Datadog::CI::TestVisibility::Component) } before do - allow(Datadog::CI).to receive(:recorder).and_return(recorder) + allow(Datadog::CI).to receive(:test_visibility).and_return(test_visibility) end describe "::trace_test" do @@ -22,7 +22,7 @@ let(:ci_test) { instance_double(Datadog::CI::Test) } before do - allow(recorder).to receive(:trace_test).with(test_name, test_suite_name, **options, &block).and_return(ci_test) + allow(test_visibility).to receive(:trace_test).with(test_name, test_suite_name, **options, &block).and_return(ci_test) end it { is_expected.to be(ci_test) } @@ -43,7 +43,7 @@ let(:ci_test) { instance_double(Datadog::CI::Test) } before do - allow(recorder).to receive(:trace_test).with(test_name, test_suite_name, **options).and_return(ci_test) + allow(test_visibility).to receive(:trace_test).with(test_name, test_suite_name, **options).and_return(ci_test) end it { is_expected.to be(ci_test) } @@ -60,7 +60,7 @@ let(:ci_span) { instance_double(Datadog::CI::Span) } before do - allow(recorder).to receive(:trace).with(span_name, type: type, **options, &block).and_return(ci_span) + allow(test_visibility).to receive(:trace).with(span_name, type: type, **options, &block).and_return(ci_span) end it { is_expected.to be(ci_span) } @@ -83,7 +83,7 @@ let(:ci_span) { instance_double(Datadog::CI::Span, type: type) } before do - allow(recorder).to receive(:active_span).and_return(ci_span) + allow(test_visibility).to receive(:active_span).and_return(ci_span) end it { is_expected.to be(ci_span) } @@ -93,7 +93,7 @@ let(:ci_span) { instance_double(Datadog::CI::Span, type: "test") } before do - allow(recorder).to receive(:active_span).and_return(ci_span) + allow(test_visibility).to receive(:active_span).and_return(ci_span) end it { is_expected.to be_nil } @@ -101,7 +101,7 @@ context "when no active span" do before do - allow(recorder).to receive(:active_span).and_return(nil) + allow(test_visibility).to receive(:active_span).and_return(nil) end it { is_expected.to be_nil } @@ -116,7 +116,7 @@ subject(:start_test_session) { described_class.start_test_session(service: service) } before do - allow(recorder).to receive(:start_test_session).with(service: service, tags: {}).and_return(ci_test_session) + allow(test_visibility).to receive(:start_test_session).with(service: service, tags: {}).and_return(ci_test_session) end it { is_expected.to be(ci_test_session) } @@ -128,7 +128,7 @@ context "when service is configured on library level" do before do allow(Datadog.configuration).to receive(:service_without_fallback).and_return("configured-service") - allow(recorder).to receive(:start_test_session).with( + allow(test_visibility).to receive(:start_test_session).with( service: "configured-service", tags: {} ).and_return(ci_test_session) end @@ -144,7 +144,7 @@ let(:ci_test_session) { instance_double(Datadog::CI::TestSession) } before do - allow(recorder).to receive(:active_test_session).and_return(ci_test_session) + allow(test_visibility).to receive(:active_test_session).and_return(ci_test_session) end it { is_expected.to be(ci_test_session) } @@ -156,7 +156,7 @@ let(:ci_test_module) { instance_double(Datadog::CI::TestModule) } before do - allow(recorder).to( + allow(test_visibility).to( receive(:start_test_module).with("my-module", service: nil, tags: {}).and_return(ci_test_module) ) end @@ -170,7 +170,7 @@ let(:ci_test_module) { instance_double(Datadog::CI::TestModule) } before do - allow(recorder).to receive(:active_test_module).and_return(ci_test_module) + allow(test_visibility).to receive(:active_test_module).and_return(ci_test_module) end it { is_expected.to be(ci_test_module) } @@ -182,7 +182,7 @@ let(:ci_test_suite) { instance_double(Datadog::CI::TestSuite) } before do - allow(recorder).to( + allow(test_visibility).to( receive(:start_test_suite).with("my-suite", service: nil, tags: {}).and_return(ci_test_suite) ) end @@ -197,7 +197,7 @@ let(:ci_test_suite) { instance_double(Datadog::CI::TestSuite) } before do - allow(recorder).to receive(:active_test_suite).with(test_suite_name).and_return(ci_test_suite) + allow(test_visibility).to receive(:active_test_suite).with(test_suite_name).and_return(ci_test_suite) end it { is_expected.to be(ci_test_suite) } diff --git a/spec/support/contexts/ci_mode.rb b/spec/support/contexts/ci_mode.rb index 2b830136..611b9aca 100644 --- a/spec/support/contexts/ci_mode.rb +++ b/spec/support/contexts/ci_mode.rb @@ -1,4 +1,4 @@ -# CI mode shared context sets up the CI recorder and configures the CI mode for tracer like customers do. +# CI mode shared context sets up the CI test_visibility and configures the CI mode for tracer like customers do. # Example usage: # # include_context "CI mode activated" do @@ -37,7 +37,7 @@ ) end - let(:recorder) { Datadog.send(:components).ci_recorder } + let(:test_visibility) { Datadog.send(:components).test_visibility } before do setup_test_coverage_writer! @@ -89,7 +89,7 @@ ::Datadog::Tracing.shutdown! Datadog::CI.send(:itr_runner)&.shutdown! - Datadog::CI.send(:recorder)&.shutdown! + Datadog::CI.send(:test_visibility)&.shutdown! Datadog.configure do |c| c.ci.enabled = false From c6b9e3846524b386609feede2ad7e7a1b7068c84 Mon Sep 17 00:00:00 2001 From: Andrey Date: Tue, 2 Jul 2024 16:00:08 +0200 Subject: [PATCH 3/4] Rename ITR module to TestOptimisation and ITR::Runner to TestOptimisation::Component --- ext/datadog_cov/datadog_cov.c | 4 ++-- lib/datadog/ci.rb | 4 ++-- lib/datadog/ci/configuration/components.rb | 22 +++++++++---------- .../component.rb} | 16 +++++++------- .../coverage/ddcov.rb | 2 +- .../coverage/event.rb | 2 +- .../coverage/transport.rb | 2 +- .../coverage/writer.rb | 2 +- .../{itr => test_optimisation}/skippable.rb | 2 +- lib/datadog/ci/test_visibility/component.rb | 18 +++++++-------- lib/datadog/ci/test_visibility/transport.rb | 2 +- sig/datadog/ci.rbs | 2 +- sig/datadog/ci/configuration/components.rbs | 6 ++--- .../coverage/ddcov.rbs | 2 +- .../coverage/event.rbs | 2 +- .../coverage/transport.rbs | 6 ++--- .../coverage/writer.rbs | 16 +++++++------- .../ci/{itr => test_optimisation}/runner.rbs | 16 +++++++------- .../{itr => test_optimisation}/skippable.rbs | 2 +- sig/datadog/ci/test_visibility/component.rbs | 4 ++-- sig/datadog/ci/test_visibility/transport.rbs | 4 ++-- .../contrib/cucumber/instrumentation_spec.rb | 1 - .../contrib/minitest/instrumentation_spec.rb | 5 ++--- .../coverage/event_spec.rb | 6 ++--- .../coverage/transport_spec.rb | 14 ++++++------ .../coverage/writer_spec.rb | 8 +++---- .../{itr => test_optimisation}/runner_spec.rb | 22 +++++++++---------- .../skippable_spec.rb | 4 ++-- .../ci/test_visibility/component_spec.rb | 6 ++--- .../ci/test_visibility/transport_spec.rb | 2 +- spec/ddcov/ddcov_spec.rb | 2 +- spec/ddcov/ddcov_with_symlinks_spec.rb | 2 +- spec/support/contexts/ci_mode.rb | 8 +++---- spec/support/coverage_helpers.rb | 4 ++-- 34 files changed, 109 insertions(+), 111 deletions(-) rename lib/datadog/ci/{itr/runner.rb => test_optimisation/component.rb} (90%) rename lib/datadog/ci/{itr => test_optimisation}/coverage/ddcov.rb (89%) rename lib/datadog/ci/{itr => test_optimisation}/coverage/event.rb (98%) rename lib/datadog/ci/{itr => test_optimisation}/coverage/transport.rb (97%) rename lib/datadog/ci/{itr => test_optimisation}/coverage/writer.rb (99%) rename lib/datadog/ci/{itr => test_optimisation}/skippable.rb (99%) rename sig/datadog/ci/{itr => test_optimisation}/coverage/ddcov.rbs (92%) rename sig/datadog/ci/{itr => test_optimisation}/coverage/event.rbs (96%) rename sig/datadog/ci/{itr => test_optimisation}/coverage/transport.rbs (57%) rename sig/datadog/ci/{itr => test_optimisation}/coverage/writer.rbs (52%) rename sig/datadog/ci/{itr => test_optimisation}/runner.rbs (73%) rename sig/datadog/ci/{itr => test_optimisation}/skippable.rbs (97%) rename spec/datadog/ci/{itr => test_optimisation}/coverage/event_spec.rb (93%) rename spec/datadog/ci/{itr => test_optimisation}/coverage/transport_spec.rb (90%) rename spec/datadog/ci/{itr => test_optimisation}/coverage/writer_spec.rb (96%) rename spec/datadog/ci/{itr => test_optimisation}/runner_spec.rb (94%) rename spec/datadog/ci/{itr => test_optimisation}/skippable_spec.rb (97%) diff --git a/ext/datadog_cov/datadog_cov.c b/ext/datadog_cov/datadog_cov.c index aa32c426..db76d28d 100644 --- a/ext/datadog_cov/datadog_cov.c +++ b/ext/datadog_cov/datadog_cov.c @@ -236,8 +236,8 @@ void Init_datadog_cov(void) { VALUE mDatadog = rb_define_module("Datadog"); VALUE mCI = rb_define_module_under(mDatadog, "CI"); - VALUE mITR = rb_define_module_under(mCI, "ITR"); - VALUE mCoverage = rb_define_module_under(mITR, "Coverage"); + VALUE mTestOptimisation = rb_define_module_under(mCI, "TestOptimisation"); + VALUE mCoverage = rb_define_module_under(mTestOptimisation, "Coverage"); VALUE cDatadogCov = rb_define_class_under(mCoverage, "DDCov", rb_cObject); rb_define_alloc_func(cDatadogCov, dd_cov_allocate); diff --git a/lib/datadog/ci.rb b/lib/datadog/ci.rb index a45bdeba..6c7302cf 100644 --- a/lib/datadog/ci.rb +++ b/lib/datadog/ci.rb @@ -365,8 +365,8 @@ def test_visibility components.test_visibility end - def itr_runner - components.itr + def test_optimisation + components.test_optimisation end end end diff --git a/lib/datadog/ci/configuration/components.rb b/lib/datadog/ci/configuration/components.rb index 7dcb5559..26559b0f 100644 --- a/lib/datadog/ci/configuration/components.rb +++ b/lib/datadog/ci/configuration/components.rb @@ -2,9 +2,9 @@ require_relative "../ext/settings" require_relative "../git/tree_uploader" -require_relative "../itr/runner" -require_relative "../itr/coverage/transport" -require_relative "../itr/coverage/writer" +require_relative "../test_optimisation/component" +require_relative "../test_optimisation/coverage/transport" +require_relative "../test_optimisation/coverage/writer" require_relative "../test_visibility/component" require_relative "../test_visibility/flush" require_relative "../test_visibility/null_component" @@ -21,10 +21,10 @@ module CI module Configuration # Adds CI behavior to Datadog trace components module Components - attr_reader :test_visibility, :itr + attr_reader :test_visibility, :test_optimisation def initialize(settings) - @itr = nil + @test_optimisation = nil @test_visibility = TestVisibility::NullComponent.new # Activate CI mode if enabled @@ -39,7 +39,7 @@ def shutdown!(replacement = nil) super @test_visibility&.shutdown! - @itr&.shutdown! + @test_optimisation&.shutdown! end def activate_ci!(settings) @@ -99,8 +99,8 @@ def activate_ci!(settings) settings.tracing.test_mode.writer_options = trace_writer_options - # @type ivar @itr: Datadog::CI::ITR::Runner - @itr = ITR::Runner.new( + # @type ivar @test_optimisation: Datadog::CI::TestOptimisation::Component + @test_optimisation = TestOptimisation::Component.new( api: test_visibility_api, dd_env: settings.env, config_tags: custom_configuration(settings), @@ -111,8 +111,8 @@ def activate_ci!(settings) ) @test_visibility = TestVisibility::Component.new( + test_optimisation: @test_optimisation, test_suite_level_visibility_enabled: !settings.ci.force_test_level_visibility, - itr: @itr, remote_settings_api: build_remote_settings_client(settings, test_visibility_api), git_tree_upload_worker: build_git_upload_worker(settings, test_visibility_api) ) @@ -169,8 +169,8 @@ def build_tracing_transport(settings, api) def build_coverage_writer(settings, api) return nil if api.nil? - ITR::Coverage::Writer.new( - transport: ITR::Coverage::Transport.new(api: api) + TestOptimisation::Coverage::Writer.new( + transport: TestOptimisation::Coverage::Transport.new(api: api) ) end diff --git a/lib/datadog/ci/itr/runner.rb b/lib/datadog/ci/test_optimisation/component.rb similarity index 90% rename from lib/datadog/ci/itr/runner.rb rename to lib/datadog/ci/test_optimisation/component.rb index b1ccfa31..f70c1e47 100644 --- a/lib/datadog/ci/itr/runner.rb +++ b/lib/datadog/ci/test_optimisation/component.rb @@ -16,11 +16,11 @@ module Datadog module CI - module ITR + module TestOptimisation # Intelligent test runner implementation # Integrates with backend to provide test impact analysis data and # skip tests that are not impacted by the changes - class Runner + class Component include Core::Utils::Forking attr_reader :correlation_id, :skippable_tests, :skipped_tests_count @@ -57,11 +57,11 @@ def initialize( @skipped_tests_count = 0 @mutex = Mutex.new - Datadog.logger.debug("ITR Runner initialized with enabled: #{@enabled}") + Datadog.logger.debug("TestOptimisation initialized with enabled: #{@enabled}") end def configure(remote_configuration, test_session:, git_tree_upload_worker:) - Datadog.logger.debug("Configuring ITR Runner with remote configuration: #{remote_configuration}") + Datadog.logger.debug("Configuring TestOptimisation with remote configuration: #{remote_configuration}") @enabled = Utils::Parsing.convert_to_bool( remote_configuration.fetch(Ext::Transport::DD_API_SETTINGS_RESPONSE_ITR_ENABLED_KEY, false) @@ -83,7 +83,7 @@ def configure(remote_configuration, test_session:, git_tree_upload_worker:) load_datadog_cov! if @code_coverage_enabled - Datadog.logger.debug("Configured ITR Runner with enabled: #{@enabled}, skipping_tests: #{@test_skipping_enabled}, code_coverage: #{@code_coverage_enabled}") + Datadog.logger.debug("Configured TestOptimisation with enabled: #{@enabled}, skipping_tests: #{@test_skipping_enabled}, code_coverage: #{@code_coverage_enabled}") fetch_skippable_tests(test_session: test_session, git_tree_upload_worker: git_tree_upload_worker) end @@ -139,7 +139,7 @@ def mark_if_skippable(test) skippable_test_id = Utils::TestRun.skippable_test_id(test.name, test.test_suite_name, test.parameters) if @skippable_tests.include?(skippable_test_id) if forked? - Datadog.logger.warn { "ITR is not supported for forking test runners yet" } + Datadog.logger.warn { "Intelligent test runner is not supported for forking test runners yet" } return end @@ -155,7 +155,7 @@ def count_skipped_test(test) return if !test.skipped? || !test.skipped_by_itr? if forked? - Datadog.logger.warn { "ITR is not supported for forking test runners yet" } + Datadog.logger.warn { "Intelligent test runner is not supported for forking test runners yet" } return end @@ -167,7 +167,7 @@ def count_skipped_test(test) def write_test_session_tags(test_session) return if !enabled? - Datadog.logger.debug { "Finished ITR session with test skipping enabled: #{@test_skipping_enabled}" } + Datadog.logger.debug { "Finished optimised session with test skipping enabled: #{@test_skipping_enabled}" } Datadog.logger.debug { "#{@skipped_tests_count} tests were skipped" } test_session.set_tag(Ext::Test::TAG_ITR_TESTS_SKIPPED, @skipped_tests_count.positive?.to_s) diff --git a/lib/datadog/ci/itr/coverage/ddcov.rb b/lib/datadog/ci/test_optimisation/coverage/ddcov.rb similarity index 89% rename from lib/datadog/ci/itr/coverage/ddcov.rb rename to lib/datadog/ci/test_optimisation/coverage/ddcov.rb index 65efda1d..51bb4bd1 100644 --- a/lib/datadog/ci/itr/coverage/ddcov.rb +++ b/lib/datadog/ci/test_optimisation/coverage/ddcov.rb @@ -2,7 +2,7 @@ module Datadog module CI - module ITR + module TestOptimisation module Coverage # Placeholder for code coverage collection # Implementation in ext/datadog_cov diff --git a/lib/datadog/ci/itr/coverage/event.rb b/lib/datadog/ci/test_optimisation/coverage/event.rb similarity index 98% rename from lib/datadog/ci/itr/coverage/event.rb rename to lib/datadog/ci/test_optimisation/coverage/event.rb index 1e4815ea..7d80f141 100644 --- a/lib/datadog/ci/itr/coverage/event.rb +++ b/lib/datadog/ci/test_optimisation/coverage/event.rb @@ -6,7 +6,7 @@ module Datadog module CI - module ITR + module TestOptimisation module Coverage class Event attr_reader :test_id, :test_suite_id, :test_session_id, :coverage diff --git a/lib/datadog/ci/itr/coverage/transport.rb b/lib/datadog/ci/test_optimisation/coverage/transport.rb similarity index 97% rename from lib/datadog/ci/itr/coverage/transport.rb rename to lib/datadog/ci/test_optimisation/coverage/transport.rb index e89cd906..9a5da41b 100644 --- a/lib/datadog/ci/itr/coverage/transport.rb +++ b/lib/datadog/ci/test_optimisation/coverage/transport.rb @@ -5,7 +5,7 @@ module Datadog module CI - module ITR + module TestOptimisation module Coverage class Transport < Datadog::CI::Transport::EventPlatformTransport private diff --git a/lib/datadog/ci/itr/coverage/writer.rb b/lib/datadog/ci/test_optimisation/coverage/writer.rb similarity index 99% rename from lib/datadog/ci/itr/coverage/writer.rb rename to lib/datadog/ci/test_optimisation/coverage/writer.rb index f5482177..dbeeebef 100644 --- a/lib/datadog/ci/itr/coverage/writer.rb +++ b/lib/datadog/ci/test_optimisation/coverage/writer.rb @@ -11,7 +11,7 @@ module Datadog module CI - module ITR + module TestOptimisation module Coverage class Writer include Core::Workers::Queue diff --git a/lib/datadog/ci/itr/skippable.rb b/lib/datadog/ci/test_optimisation/skippable.rb similarity index 99% rename from lib/datadog/ci/itr/skippable.rb rename to lib/datadog/ci/test_optimisation/skippable.rb index c0bcbb27..8cd4b660 100644 --- a/lib/datadog/ci/itr/skippable.rb +++ b/lib/datadog/ci/test_optimisation/skippable.rb @@ -8,7 +8,7 @@ module Datadog module CI - module ITR + module TestOptimisation class Skippable class Response def initialize(http_response) diff --git a/lib/datadog/ci/test_visibility/component.rb b/lib/datadog/ci/test_visibility/component.rb index ca02e64a..7d6d306a 100644 --- a/lib/datadog/ci/test_visibility/component.rb +++ b/lib/datadog/ci/test_visibility/component.rb @@ -32,7 +32,7 @@ class Component attr_reader :environment_tags, :test_suite_level_visibility_enabled def initialize( - itr:, + test_optimisation:, remote_settings_api:, git_tree_upload_worker: DummyWorker.new, test_suite_level_visibility_enabled: false, @@ -46,7 +46,7 @@ def initialize( @codeowners = codeowners - @itr = itr + @test_optimisation = test_optimisation @remote_settings_api = remote_settings_api @git_tree_upload_worker = git_tree_upload_worker end @@ -210,7 +210,7 @@ def deactivate_test_suite(test_suite_name) end def itr_enabled? - @itr.enabled? + @test_optimisation.enabled? end private @@ -234,7 +234,7 @@ def configure_library(test_session) end end - @itr.configure( + @test_optimisation.configure( remote_configuration.payload, test_session: test_session, git_tree_upload_worker: @git_tree_upload_worker @@ -404,17 +404,17 @@ def validate_test_suite_level_visibility_correctness(test) # TODO: use kind of event system to notify about test finished? def on_test_finished(test) - @itr.stop_coverage(test) - @itr.count_skipped_test(test) + @test_optimisation.stop_coverage(test) + @test_optimisation.count_skipped_test(test) end def on_test_started(test) - @itr.mark_if_skippable(test) - @itr.start_coverage(test) + @test_optimisation.mark_if_skippable(test) + @test_optimisation.start_coverage(test) end def on_test_session_finished(test_session) - @itr.write_test_session_tags(test_session) + @test_optimisation.write_test_session_tags(test_session) end end end diff --git a/lib/datadog/ci/test_visibility/transport.rb b/lib/datadog/ci/test_visibility/transport.rb index ace6870d..ab8c76ee 100644 --- a/lib/datadog/ci/test_visibility/transport.rb +++ b/lib/datadog/ci/test_visibility/transport.rb @@ -100,7 +100,7 @@ def write_payload_header(packer) end def itr - @itr ||= Datadog::CI.send(:itr_runner) + @test_optimisation ||= Datadog::CI.send(:test_optimisation) end end end diff --git a/sig/datadog/ci.rbs b/sig/datadog/ci.rbs index 993b57cb..3cd1624c 100644 --- a/sig/datadog/ci.rbs +++ b/sig/datadog/ci.rbs @@ -31,6 +31,6 @@ module Datadog def self.test_visibility: () -> (Datadog::CI::TestVisibility::Component | Datadog::CI::TestVisibility::NullComponent) - def self.itr_runner: () -> Datadog::CI::ITR::Runner? + def self.test_optimisation: () -> Datadog::CI::TestOptimisation::Component? end end diff --git a/sig/datadog/ci/configuration/components.rbs b/sig/datadog/ci/configuration/components.rbs index 8845f844..4b7d014d 100644 --- a/sig/datadog/ci/configuration/components.rbs +++ b/sig/datadog/ci/configuration/components.rbs @@ -3,11 +3,11 @@ module Datadog module Configuration module Components : Datadog::Core::Configuration::Components @test_visibility: Datadog::CI::TestVisibility::Component | Datadog::CI::TestVisibility::NullComponent - @itr: Datadog::CI::ITR::Runner? + @test_optimisation: Datadog::CI::TestOptimisation::Component? @custom_configuration: Hash[String, String] attr_reader test_visibility: Datadog::CI::TestVisibility::Component | Datadog::CI::TestVisibility::NullComponent - attr_reader itr: Datadog::CI::ITR::Runner? + attr_reader test_optimisation: Datadog::CI::TestOptimisation::Component? def initialize: (untyped settings) -> void @@ -21,7 +21,7 @@ module Datadog def build_tracing_transport: (untyped settings, Datadog::CI::Transport::Api::Base? api) -> Datadog::CI::TestVisibility::Transport? - def build_coverage_writer: (untyped settings, Datadog::CI::Transport::Api::Base? api) -> Datadog::CI::ITR::Coverage::Writer? + def build_coverage_writer: (untyped settings, Datadog::CI::Transport::Api::Base? api) -> Datadog::CI::TestOptimisation::Coverage::Writer? def build_git_upload_worker: (untyped settings, Datadog::CI::Transport::Api::Base? api) -> Datadog::CI::Worker diff --git a/sig/datadog/ci/itr/coverage/ddcov.rbs b/sig/datadog/ci/test_optimisation/coverage/ddcov.rbs similarity index 92% rename from sig/datadog/ci/itr/coverage/ddcov.rbs rename to sig/datadog/ci/test_optimisation/coverage/ddcov.rbs index 156789ff..0b5c9c56 100644 --- a/sig/datadog/ci/itr/coverage/ddcov.rbs +++ b/sig/datadog/ci/test_optimisation/coverage/ddcov.rbs @@ -1,6 +1,6 @@ module Datadog module CI - module ITR + module TestOptimisation module Coverage class DDCov type threading_mode = :multi | :single diff --git a/sig/datadog/ci/itr/coverage/event.rbs b/sig/datadog/ci/test_optimisation/coverage/event.rbs similarity index 96% rename from sig/datadog/ci/itr/coverage/event.rbs rename to sig/datadog/ci/test_optimisation/coverage/event.rbs index 0e868934..d3a27237 100644 --- a/sig/datadog/ci/itr/coverage/event.rbs +++ b/sig/datadog/ci/test_optimisation/coverage/event.rbs @@ -1,6 +1,6 @@ module Datadog module CI - module ITR + module TestOptimisation module Coverage class Event @test_id: String diff --git a/sig/datadog/ci/itr/coverage/transport.rbs b/sig/datadog/ci/test_optimisation/coverage/transport.rbs similarity index 57% rename from sig/datadog/ci/itr/coverage/transport.rbs rename to sig/datadog/ci/test_optimisation/coverage/transport.rbs index b289d440..0dc69c5a 100644 --- a/sig/datadog/ci/itr/coverage/transport.rbs +++ b/sig/datadog/ci/test_optimisation/coverage/transport.rbs @@ -1,17 +1,17 @@ module Datadog module CI - module ITR + module TestOptimisation module Coverage class Transport < Datadog::CI::Transport::EventPlatformTransport private def send_payload: (String payload) -> ::Datadog::CI::Transport::HTTP::ResponseDecorator - def encode_events: (Array[Datadog::CI::ITR::Coverage::Event] events) -> ::Array[String] + def encode_events: (Array[Datadog::CI::TestOptimisation::Coverage::Event] events) -> ::Array[String] def pack_events: (Array[String] encoded_events) -> String - def event_too_large?: (Datadog::CI::ITR::Coverage::Event event, String encoded_event) -> bool + def event_too_large?: (Datadog::CI::TestOptimisation::Coverage::Event event, String encoded_event) -> bool end end end diff --git a/sig/datadog/ci/itr/coverage/writer.rbs b/sig/datadog/ci/test_optimisation/coverage/writer.rbs similarity index 52% rename from sig/datadog/ci/itr/coverage/writer.rbs rename to sig/datadog/ci/test_optimisation/coverage/writer.rbs index ae9e0438..cbabde7a 100644 --- a/sig/datadog/ci/itr/coverage/writer.rbs +++ b/sig/datadog/ci/test_optimisation/coverage/writer.rbs @@ -1,6 +1,6 @@ module Datadog module CI - module ITR + module TestOptimisation module Coverage class Writer include Datadog::Core::Workers::Async::Thread @@ -8,7 +8,7 @@ module Datadog include Datadog::Core::Workers::Queue include Datadog::Core::Workers::IntervalLoop - @transport: Datadog::CI::ITR::Coverage::Transport + @transport: Datadog::CI::TestOptimisation::Coverage::Transport @buffer_size: Integer @@ -16,7 +16,7 @@ module Datadog @stopped: bool - attr_reader transport: Datadog::CI::ITR::Coverage::Transport + attr_reader transport: Datadog::CI::TestOptimisation::Coverage::Transport DEFAULT_BUFFER_MAX_SIZE: 10000 @@ -24,17 +24,17 @@ module Datadog DEFAULT_INTERVAL: 3 - def initialize: (transport: Datadog::CI::ITR::Coverage::Transport, ?options: ::Hash[untyped, untyped]) -> void + def initialize: (transport: Datadog::CI::TestOptimisation::Coverage::Transport, ?options: ::Hash[untyped, untyped]) -> void - def write: (Datadog::CI::ITR::Coverage::Event event) -> untyped + def write: (Datadog::CI::TestOptimisation::Coverage::Event event) -> untyped - def perform: (*Datadog::CI::ITR::Coverage::Event events) -> nil + def perform: (*Datadog::CI::TestOptimisation::Coverage::Event events) -> nil def stop: (?bool force_stop, ?Integer timeout) -> untyped - def enqueue: (Datadog::CI::ITR::Coverage::Event event) -> untyped + def enqueue: (Datadog::CI::TestOptimisation::Coverage::Event event) -> untyped - def dequeue: () -> ::Array[Datadog::CI::ITR::Coverage::Event] + def dequeue: () -> ::Array[Datadog::CI::TestOptimisation::Coverage::Event] def async?: () -> true diff --git a/sig/datadog/ci/itr/runner.rbs b/sig/datadog/ci/test_optimisation/runner.rbs similarity index 73% rename from sig/datadog/ci/itr/runner.rbs rename to sig/datadog/ci/test_optimisation/runner.rbs index 7c4daae4..a9e016ab 100644 --- a/sig/datadog/ci/itr/runner.rbs +++ b/sig/datadog/ci/test_optimisation/runner.rbs @@ -1,7 +1,7 @@ module Datadog module CI - module ITR - class Runner + module TestOptimisation + class Component include Datadog::Core::Utils::Forking @enabled: bool @@ -9,7 +9,7 @@ module Datadog @code_coverage_enabled: bool @correlation_id: String? @skippable_tests: Set[String] - @coverage_writer: Datadog::CI::ITR::Coverage::Writer? + @coverage_writer: Datadog::CI::TestOptimisation::Coverage::Writer? @api: Datadog::CI::Transport::Api::Base? @dd_env: String? @@ -24,7 +24,7 @@ module Datadog attr_reader skipped_tests_count: Integer attr_reader correlation_id: String? - def initialize: (dd_env: String?, ?enabled: bool, ?coverage_writer: Datadog::CI::ITR::Coverage::Writer?, ?api: Datadog::CI::Transport::Api::Base?, ?config_tags: Hash[String, String]?, ?bundle_location: String?, ?use_single_threaded_coverage: bool) -> void + def initialize: (dd_env: String?, ?enabled: bool, ?coverage_writer: Datadog::CI::TestOptimisation::Coverage::Writer?, ?api: Datadog::CI::Transport::Api::Base?, ?config_tags: Hash[String, String]?, ?bundle_location: String?, ?use_single_threaded_coverage: bool) -> void def configure: (Hash[String, untyped] remote_configuration, test_session: Datadog::CI::TestSession, git_tree_upload_worker: Datadog::CI::Worker) -> void @@ -36,7 +36,7 @@ module Datadog def start_coverage: (Datadog::CI::Test test) -> void - def stop_coverage: (Datadog::CI::Test test) -> Datadog::CI::ITR::Coverage::Event? + def stop_coverage: (Datadog::CI::Test test) -> Datadog::CI::TestOptimisation::Coverage::Event? def mark_if_skippable: (Datadog::CI::Test test) -> void @@ -48,11 +48,11 @@ module Datadog private - def coverage_collector: () -> Datadog::CI::ITR::Coverage::DDCov? + def coverage_collector: () -> Datadog::CI::TestOptimisation::Coverage::DDCov? def load_datadog_cov!: () -> void - def write: (Datadog::CI::ITR::Coverage::Event event) -> void + def write: (Datadog::CI::TestOptimisation::Coverage::Event event) -> void def ensure_test_source_covered: (String test_source_file, Hash[String, untyped] coverage) -> void @@ -60,7 +60,7 @@ module Datadog def increment_skipped_tests_counter: () -> void - def code_coverage_mode: () -> Datadog::CI::ITR::Coverage::DDCov::threading_mode + def code_coverage_mode: () -> Datadog::CI::TestOptimisation::Coverage::DDCov::threading_mode end end end diff --git a/sig/datadog/ci/itr/skippable.rbs b/sig/datadog/ci/test_optimisation/skippable.rbs similarity index 97% rename from sig/datadog/ci/itr/skippable.rbs rename to sig/datadog/ci/test_optimisation/skippable.rbs index f29e893c..4c704ea5 100644 --- a/sig/datadog/ci/itr/skippable.rbs +++ b/sig/datadog/ci/test_optimisation/skippable.rbs @@ -1,6 +1,6 @@ module Datadog module CI - module ITR + module TestOptimisation class Skippable @api: Datadog::CI::Transport::Api::Base? @dd_env: String? diff --git a/sig/datadog/ci/test_visibility/component.rbs b/sig/datadog/ci/test_visibility/component.rbs index 0193bbda..aa0b4870 100644 --- a/sig/datadog/ci/test_visibility/component.rbs +++ b/sig/datadog/ci/test_visibility/component.rbs @@ -7,7 +7,7 @@ module Datadog @environment_tags: Hash[String, String] @local_context: Datadog::CI::TestVisibility::Context::Local @global_context: Datadog::CI::TestVisibility::Context::Global - @itr: Datadog::CI::ITR::Runner + @test_optimisation: Datadog::CI::TestOptimisation::Component @remote_settings_api: Datadog::CI::Transport::RemoteSettingsApi @codeowners: Datadog::CI::Codeowners::Matcher @git_tree_upload_worker: Datadog::CI::Worker @@ -15,7 +15,7 @@ module Datadog attr_reader environment_tags: Hash[String, String] attr_reader test_suite_level_visibility_enabled: bool - def initialize: (?test_suite_level_visibility_enabled: bool, ?codeowners: Datadog::CI::Codeowners::Matcher, itr: Datadog::CI::ITR::Runner, remote_settings_api: Datadog::CI::Transport::RemoteSettingsApi, ?git_tree_upload_worker: Datadog::CI::Worker) -> void + def initialize: (?test_suite_level_visibility_enabled: bool, ?codeowners: Datadog::CI::Codeowners::Matcher, test_optimisation: Datadog::CI::TestOptimisation::Component, remote_settings_api: Datadog::CI::Transport::RemoteSettingsApi, ?git_tree_upload_worker: Datadog::CI::Worker) -> void def trace_test: (String span_name, String test_suite_name, ?service: String?, ?tags: Hash[untyped, untyped]) ?{ (Datadog::CI::Test span) -> untyped } -> untyped diff --git a/sig/datadog/ci/test_visibility/transport.rbs b/sig/datadog/ci/test_visibility/transport.rbs index ee7e0f79..4c00fecb 100644 --- a/sig/datadog/ci/test_visibility/transport.rbs +++ b/sig/datadog/ci/test_visibility/transport.rbs @@ -7,7 +7,7 @@ module Datadog @dd_env: String? @serializers_factory: singleton(Datadog::CI::TestVisibility::Serializers::Factories::TestLevel) | singleton(Datadog::CI::TestVisibility::Serializers::Factories::TestSuiteLevel) - @itr: Datadog::CI::ITR::Runner? + @test_optimisation: Datadog::CI::TestOptimisation::Component? def initialize: ( api: Datadog::CI::Transport::Api::Base, @@ -21,7 +21,7 @@ module Datadog def send_payload: (String encoded_payload) -> Datadog::CI::Transport::HTTP::ResponseDecorator def encode_events: (Array[Datadog::Tracing::TraceSegment] traces) -> ::Array[String] def encode_span: (Datadog::Tracing::TraceSegment trace, Datadog::Tracing::Span span) -> String? - def itr: () -> Datadog::CI::ITR::Runner? + def itr: () -> Datadog::CI::TestOptimisation::Component? end end end diff --git a/spec/datadog/ci/contrib/cucumber/instrumentation_spec.rb b/spec/datadog/ci/contrib/cucumber/instrumentation_spec.rb index 8ff61f98..af96fdc2 100644 --- a/spec/datadog/ci/contrib/cucumber/instrumentation_spec.rb +++ b/spec/datadog/ci/contrib/cucumber/instrumentation_spec.rb @@ -154,7 +154,6 @@ ) expect(test_session_span).to have_pass_status - # ITR expect(test_session_span).to have_test_tag(:itr_test_skipping_enabled, "true") expect(test_session_span).to have_test_tag(:itr_test_skipping_type, "test") expect(test_session_span).to have_test_tag(:itr_tests_skipped, "false") diff --git a/spec/datadog/ci/contrib/minitest/instrumentation_spec.rb b/spec/datadog/ci/contrib/minitest/instrumentation_spec.rb index 8bbe37ed..1d79f697 100644 --- a/spec/datadog/ci/contrib/minitest/instrumentation_spec.rb +++ b/spec/datadog/ci/contrib/minitest/instrumentation_spec.rb @@ -429,7 +429,6 @@ def test_pass_other Datadog::CI::Contrib::Minitest::Integration.version.to_s ) - # ITR expect(test_session_span).to have_test_tag(:itr_test_skipping_enabled, "true") expect(test_session_span).to have_test_tag(:itr_test_skipping_type, "test") expect(test_session_span).to have_test_tag(:itr_tests_skipped, "false") @@ -507,7 +506,7 @@ def test_pass_other expect(cov_event.coverage.keys).to include(absolute_path("helpers/addition_helper.rb")) end - context "when ITR skips tests" do + context "when test optimisation skips tests" do context "single skipped test" do let(:itr_skippable_tests) do Set.new(["SomeTest at spec/datadog/ci/contrib/minitest/instrumentation_spec.rb.test_pass."]) @@ -717,7 +716,7 @@ def test_b_2 expect_non_empty_coverages end - context "when ITR skips tests" do + context "when test optimisation skips tests" do let(:itr_skippable_tests) do Set.new( [ diff --git a/spec/datadog/ci/itr/coverage/event_spec.rb b/spec/datadog/ci/test_optimisation/coverage/event_spec.rb similarity index 93% rename from spec/datadog/ci/itr/coverage/event_spec.rb rename to spec/datadog/ci/test_optimisation/coverage/event_spec.rb index ad17bef6..094cbb58 100644 --- a/spec/datadog/ci/itr/coverage/event_spec.rb +++ b/spec/datadog/ci/test_optimisation/coverage/event_spec.rb @@ -2,9 +2,9 @@ require "pp" -require_relative "../../../../../lib/datadog/ci/itr/coverage/event" +require_relative "../../../../../lib/datadog/ci/test_optimisation/coverage/event" -RSpec.describe Datadog::CI::ITR::Coverage::Event do +RSpec.describe Datadog::CI::TestOptimisation::Coverage::Event do subject do described_class.new( test_id: test_id, @@ -97,7 +97,7 @@ "test_suite_id" => 2, "span_id" => 1, "files" => [ - {"filename" => "spec/datadog/ci/itr/coverage/project/file.rb"} + {"filename" => "spec/datadog/ci/test_optimisation/coverage/project/file.rb"} ] } ) diff --git a/spec/datadog/ci/itr/coverage/transport_spec.rb b/spec/datadog/ci/test_optimisation/coverage/transport_spec.rb similarity index 90% rename from spec/datadog/ci/itr/coverage/transport_spec.rb rename to spec/datadog/ci/test_optimisation/coverage/transport_spec.rb index 31a231c4..70524a21 100644 --- a/spec/datadog/ci/itr/coverage/transport_spec.rb +++ b/spec/datadog/ci/test_optimisation/coverage/transport_spec.rb @@ -1,6 +1,6 @@ -require_relative "../../../../../lib/datadog/ci/itr/coverage/transport" +require_relative "../../../../../lib/datadog/ci/test_optimisation/coverage/transport" -RSpec.describe Datadog::CI::ITR::Coverage::Transport do +RSpec.describe Datadog::CI::TestOptimisation::Coverage::Transport do subject do described_class.new( api: api, @@ -16,7 +16,7 @@ let(:api) { spy(:api) } let(:event) do - Datadog::CI::ITR::Coverage::Event.new( + Datadog::CI::TestOptimisation::Coverage::Event.new( test_id: "1", test_suite_id: "2", test_session_id: "3", @@ -49,7 +49,7 @@ let(:events) do [ event, - Datadog::CI::ITR::Coverage::Event.new( + Datadog::CI::TestOptimisation::Coverage::Event.new( test_id: "4", test_suite_id: "5", test_session_id: "6", @@ -78,7 +78,7 @@ let(:events) do [ event, - Datadog::CI::ITR::Coverage::Event.new( + Datadog::CI::TestOptimisation::Coverage::Event.new( test_id: "4", test_suite_id: nil, test_session_id: "6", @@ -135,13 +135,13 @@ context "when all events are invalid" do let(:events) do [ - Datadog::CI::ITR::Coverage::Event.new( + Datadog::CI::TestOptimisation::Coverage::Event.new( test_id: "4", test_suite_id: "5", test_session_id: nil, coverage: {"file.rb" => true, "file2.rb" => true} ), - Datadog::CI::ITR::Coverage::Event.new( + Datadog::CI::TestOptimisation::Coverage::Event.new( test_id: "8", test_suite_id: nil, test_session_id: "6", diff --git a/spec/datadog/ci/itr/coverage/writer_spec.rb b/spec/datadog/ci/test_optimisation/coverage/writer_spec.rb similarity index 96% rename from spec/datadog/ci/itr/coverage/writer_spec.rb rename to spec/datadog/ci/test_optimisation/coverage/writer_spec.rb index ec19d9d8..0061ee3a 100644 --- a/spec/datadog/ci/itr/coverage/writer_spec.rb +++ b/spec/datadog/ci/test_optimisation/coverage/writer_spec.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true -require_relative "../../../../../lib/datadog/ci/itr/coverage/writer" -require_relative "../../../../../lib/datadog/ci/itr/coverage/transport" +require_relative "../../../../../lib/datadog/ci/test_optimisation/coverage/writer" +require_relative "../../../../../lib/datadog/ci/test_optimisation/coverage/transport" -RSpec.describe Datadog::CI::ITR::Coverage::Writer do +RSpec.describe Datadog::CI::TestOptimisation::Coverage::Writer do subject(:writer) { described_class.new(transport: transport, options: options) } let(:options) { {} } - let(:transport) { instance_double(Datadog::CI::ITR::Coverage::Transport) } + let(:transport) { instance_double(Datadog::CI::TestOptimisation::Coverage::Transport) } before do allow(transport).to receive(:send_events).and_return([]) end diff --git a/spec/datadog/ci/itr/runner_spec.rb b/spec/datadog/ci/test_optimisation/runner_spec.rb similarity index 94% rename from spec/datadog/ci/itr/runner_spec.rb rename to spec/datadog/ci/test_optimisation/runner_spec.rb index 897f7416..37c820bc 100644 --- a/spec/datadog/ci/itr/runner_spec.rb +++ b/spec/datadog/ci/test_optimisation/runner_spec.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -require_relative "../../../../lib/datadog/ci/itr/runner" +require_relative "../../../../lib/datadog/ci/test_optimisation/component" -RSpec.describe Datadog::CI::ITR::Runner do +RSpec.describe Datadog::CI::TestOptimisation::Component do let(:itr_enabled) { true } let(:api) { double("api") } @@ -58,9 +58,9 @@ let(:remote_configuration) { {"itr_enabled" => true, "code_coverage" => true, "tests_skipping" => true} } let(:skippable) do instance_double( - Datadog::CI::ITR::Skippable, + Datadog::CI::TestOptimisation::Skippable, fetch_skippable_tests: instance_double( - Datadog::CI::ITR::Skippable::Response, + Datadog::CI::TestOptimisation::Skippable::Response, correlation_id: "42", tests: Set.new(["suite.test."]) ) @@ -68,7 +68,7 @@ end before do - expect(Datadog::CI::ITR::Skippable).to receive(:new).and_return(skippable) + expect(Datadog::CI::TestOptimisation::Skippable).to receive(:new).and_return(skippable) configure end @@ -127,7 +127,7 @@ end end - context "when ITR is disabled" do + context "when TestOptimisation is disabled" do let(:remote_configuration) { {"itr_enabled" => false, "code_coverage" => false, "tests_skipping" => false} } it "does not start coverage" do @@ -229,9 +229,9 @@ let(:remote_configuration) { {"itr_enabled" => true, "code_coverage" => true, "tests_skipping" => true} } let(:skippable) do instance_double( - Datadog::CI::ITR::Skippable, + Datadog::CI::TestOptimisation::Skippable, fetch_skippable_tests: instance_double( - Datadog::CI::ITR::Skippable::Response, + Datadog::CI::TestOptimisation::Skippable::Response, correlation_id: "42", tests: Set.new(["suite.test.", "suite2.test.", "suite.test3."]) ) @@ -239,7 +239,7 @@ end before do - expect(Datadog::CI::ITR::Skippable).to receive(:new).and_return(skippable) + expect(Datadog::CI::TestOptimisation::Skippable).to receive(:new).and_return(skippable) configure end @@ -383,10 +383,10 @@ end end - context "when ITR is disabled" do + context "when TestOptimisation is disabled" do let(:itr_enabled) { false } - it "does not add ITR tags to the session" do + it "does not add ITR/TestOptimisation tags to the session" do subject expect(test_session_span.get_tag(Datadog::CI::Ext::Test::TAG_ITR_TESTS_SKIPPED)).to be_nil diff --git a/spec/datadog/ci/itr/skippable_spec.rb b/spec/datadog/ci/test_optimisation/skippable_spec.rb similarity index 97% rename from spec/datadog/ci/itr/skippable_spec.rb rename to spec/datadog/ci/test_optimisation/skippable_spec.rb index 4cdf7982..d9699f79 100644 --- a/spec/datadog/ci/itr/skippable_spec.rb +++ b/spec/datadog/ci/test_optimisation/skippable_spec.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -require_relative "../../../../lib/datadog/ci/itr/skippable" +require_relative "../../../../lib/datadog/ci/test_optimisation/skippable" -RSpec.describe Datadog::CI::ITR::Skippable do +RSpec.describe Datadog::CI::TestOptimisation::Skippable do let(:api) { spy("api") } let(:dd_env) { "ci" } let(:config_tags) { {} } diff --git a/spec/datadog/ci/test_visibility/component_spec.rb b/spec/datadog/ci/test_visibility/component_spec.rb index 008a4fe2..2b2d8d41 100644 --- a/spec/datadog/ci/test_visibility/component_spec.rb +++ b/spec/datadog/ci/test_visibility/component_spec.rb @@ -112,7 +112,7 @@ end context "when test suite level visibility is enabled" do - context "without ITR" do + context "without TestOptimisation" do include_context "CI mode activated" describe "#trace" do @@ -732,7 +732,7 @@ end end - context "with ITR" do + context "with TestOptimisation" do context "without require_git in settings response" do include_context "CI mode activated" do let(:itr_enabled) { true } @@ -746,7 +746,7 @@ subject { test_visibility.start_test_session(service: service, tags: tags) } - it "returns a new CI test_session span with ITR tags" do + it "returns a new CI test_session span with ITR/TestOptimisation tags" do expect(subject).to be_kind_of(Datadog::CI::TestSession) expect(subject.service).to eq(service) diff --git a/spec/datadog/ci/test_visibility/transport_spec.rb b/spec/datadog/ci/test_visibility/transport_spec.rb index 2ef48da8..15fb0e4c 100644 --- a/spec/datadog/ci/test_visibility/transport_spec.rb +++ b/spec/datadog/ci/test_visibility/transport_spec.rb @@ -82,7 +82,7 @@ let(:serializers_factory) { Datadog::CI::TestVisibility::Serializers::Factories::TestSuiteLevel } before do - allow_any_instance_of(Datadog::CI::ITR::Runner).to receive(:correlation_id).and_return("correlation-id") + allow_any_instance_of(Datadog::CI::TestOptimisation::Component).to receive(:correlation_id).and_return("correlation-id") produce_test_session_trace end diff --git a/spec/ddcov/ddcov_spec.rb b/spec/ddcov/ddcov_spec.rb index 4f0cc68a..98b79313 100644 --- a/spec/ddcov/ddcov_spec.rb +++ b/spec/ddcov/ddcov_spec.rb @@ -5,7 +5,7 @@ require_relative "calculator/calculator" require_relative "calculator/code_with_❤️" -RSpec.describe Datadog::CI::ITR::Coverage::DDCov do +RSpec.describe Datadog::CI::TestOptimisation::Coverage::DDCov do let(:ignored_path) { nil } let(:threading_mode) { :multi } subject { described_class.new(root: root, ignored_path: ignored_path, threading_mode: threading_mode) } diff --git a/spec/ddcov/ddcov_with_symlinks_spec.rb b/spec/ddcov/ddcov_with_symlinks_spec.rb index 3b382216..ce1915e3 100644 --- a/spec/ddcov/ddcov_with_symlinks_spec.rb +++ b/spec/ddcov/ddcov_with_symlinks_spec.rb @@ -4,7 +4,7 @@ require "datadog_cov.#{RUBY_VERSION}_#{RUBY_PLATFORM}" -RSpec.describe Datadog::CI::ITR::Coverage::DDCov do +RSpec.describe Datadog::CI::TestOptimisation::Coverage::DDCov do before do # create a symlink to the calculator_with_symlinks/operations folder in vendor/gems FileUtils.ln_s( diff --git a/spec/support/contexts/ci_mode.rb b/spec/support/contexts/ci_mode.rb index 611b9aca..862ff263 100644 --- a/spec/support/contexts/ci_mode.rb +++ b/spec/support/contexts/ci_mode.rb @@ -30,7 +30,7 @@ let(:skippable_tests_response) do instance_double( - Datadog::CI::ITR::Skippable::Response, + Datadog::CI::TestOptimisation::Skippable::Response, ok?: true, correlation_id: itr_correlation_id, tests: itr_skippable_tests @@ -69,8 +69,8 @@ require_git?: !require_git ) ) - allow_any_instance_of(Datadog::CI::ITR::Skippable).to receive(:fetch_skippable_tests).and_return(skippable_tests_response) - allow_any_instance_of(Datadog::CI::ITR::Coverage::Transport).to receive(:send_events).and_return([]) + allow_any_instance_of(Datadog::CI::TestOptimisation::Skippable).to receive(:fetch_skippable_tests).and_return(skippable_tests_response) + allow_any_instance_of(Datadog::CI::TestOptimisation::Coverage::Transport).to receive(:send_events).and_return([]) Datadog.configure do |c| c.ci.enabled = ci_enabled @@ -88,7 +88,7 @@ after do ::Datadog::Tracing.shutdown! - Datadog::CI.send(:itr_runner)&.shutdown! + Datadog::CI.send(:test_optimisation)&.shutdown! Datadog::CI.send(:test_visibility)&.shutdown! Datadog.configure do |c| diff --git a/spec/support/coverage_helpers.rb b/spec/support/coverage_helpers.rb index f74d3de1..b73cd3fc 100644 --- a/spec/support/coverage_helpers.rb +++ b/spec/support/coverage_helpers.rb @@ -26,7 +26,7 @@ def clear_coverage_events! def setup_test_coverage_writer! # DEV `*_any_instance_of` has concurrency issues when running with parallelism (e.g. JRuby). # DEV Single object `allow` and `expect` work as intended with parallelism. - allow(Datadog::CI::ITR::Runner).to receive(:new).and_wrap_original do |method, **args, &block| + allow(Datadog::CI::TestOptimisation::Component).to receive(:new).and_wrap_original do |method, **args, &block| instance = method.call(**args, &block) write_lock = Mutex.new @@ -44,7 +44,7 @@ def setup_test_coverage_writer! end def runner - Datadog::CI.send(:itr_runner) + Datadog::CI.send(:test_optimisation) end def expect_coverage_events_belong_to_session(test_session_span) From f8f603b630bc675ae5c6c020d52c2fceffbef617 Mon Sep 17 00:00:00 2001 From: Andrey Date: Tue, 2 Jul 2024 16:15:23 +0200 Subject: [PATCH 4/4] rename signature file as well --- sig/datadog/ci/test_optimisation/{runner.rbs => component.rbs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sig/datadog/ci/test_optimisation/{runner.rbs => component.rbs} (100%) diff --git a/sig/datadog/ci/test_optimisation/runner.rbs b/sig/datadog/ci/test_optimisation/component.rbs similarity index 100% rename from sig/datadog/ci/test_optimisation/runner.rbs rename to sig/datadog/ci/test_optimisation/component.rbs