Class: Datadog::CI::TestManagement::Component
- Inherits:
-
Object
- Object
- Datadog::CI::TestManagement::Component
- Defined in:
- lib/datadog/ci/test_management/component.rb
Overview
Test management is a feature that lets people manage their flaky tests in Datadog. It includes:
-
marking test as quarantined causes test to continue running but not failing the build
-
marking test as disabled causes test to be skipped
-
marking test as “attempted to fix” causes test to be retried many times to confirm that fix worked
Instance Attribute Summary collapse
-
#enabled ⇒ Object
readonly
Returns the value of attribute enabled.
-
#tests_properties ⇒ Object
readonly
Returns the value of attribute tests_properties.
Instance Method Summary collapse
- #configure(library_settings, test_session) ⇒ Object
-
#initialize(enabled:, tests_properties_client:) ⇒ Component
constructor
A new instance of Component.
- #tag_test_from_properties(test_span) ⇒ Object
Constructor Details
#initialize(enabled:, tests_properties_client:) ⇒ Component
Returns a new instance of Component.
19 20 21 22 23 24 |
# File 'lib/datadog/ci/test_management/component.rb', line 19 def initialize(enabled:, tests_properties_client:) @enabled = enabled @tests_properties_client = tests_properties_client @tests_properties = {} end |
Instance Attribute Details
#enabled ⇒ Object (readonly)
Returns the value of attribute enabled.
17 18 19 |
# File 'lib/datadog/ci/test_management/component.rb', line 17 def enabled @enabled end |
#tests_properties ⇒ Object (readonly)
Returns the value of attribute tests_properties.
17 18 19 |
# File 'lib/datadog/ci/test_management/component.rb', line 17 def tests_properties @tests_properties end |
Instance Method Details
#configure(library_settings, test_session) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/datadog/ci/test_management/component.rb', line 26 def configure(library_settings, test_session) @enabled &&= library_settings.test_management_enabled? return unless @enabled test_session.set_tag(Ext::Test::TAG_TEST_MANAGEMENT_ENABLED, "true") @tests_properties = @tests_properties_client.fetch(test_session) Utils::Telemetry.distribution( Ext::Telemetry::METRIC_TEST_MANAGEMENT_TESTS_RESPONSE_TESTS, @tests_properties.count.to_f ) end |
#tag_test_from_properties(test_span) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/datadog/ci/test_management/component.rb', line 41 def tag_test_from_properties(test_span) return unless @enabled datadog_test_id = Utils::TestRun.datadog_test_id(test_span.name, test_span.test_suite_name) test_properties = @tests_properties[datadog_test_id] if test_properties.nil? Datadog.logger.debug { "Test properties not found for test: #{datadog_test_id}" } return end Datadog.logger.debug { "Test properties for test #{datadog_test_id} are: [#{test_properties}]" } test_span.set_tag(Ext::Test::TAG_IS_QUARANTINED, "true") if test_properties["quarantined"] test_span.set_tag(Ext::Test::TAG_IS_TEST_DISABLED, "true") if test_properties["disabled"] test_span.set_tag(Ext::Test::TAG_IS_ATTEMPT_TO_FIX, "true") if test_properties["attempt_to_fix"] end |