Class: Datadog::CI::TestVisibility::Component
- Inherits:
-
Object
- Object
- Datadog::CI::TestVisibility::Component
- Defined in:
- lib/datadog/ci/test_visibility/component.rb
Overview
Common behavior for CI tests
Instance Attribute Summary collapse
-
#test_suite_level_visibility_enabled ⇒ Object
readonly
Returns the value of attribute test_suite_level_visibility_enabled.
Instance Method Summary collapse
- #active_span ⇒ Object
- #active_test ⇒ Object
- #active_test_module ⇒ Object
- #active_test_session ⇒ Object
- #active_test_suite(test_suite_name) ⇒ Object
- #deactivate_test ⇒ Object
- #deactivate_test_module ⇒ Object
- #deactivate_test_session ⇒ Object
- #deactivate_test_suite(test_suite_name) ⇒ Object
-
#initialize(test_optimisation:, remote_settings_api:, git_tree_upload_worker: DummyWorker.new, test_suite_level_visibility_enabled: false, codeowners: Codeowners::Parser.new(Git::LocalRepository.root).parse) ⇒ Component
constructor
A new instance of Component.
- #itr_enabled? ⇒ Boolean
- #shutdown! ⇒ Object
- #start_test_module(test_module_name, service: nil, tags: {}) ⇒ Object
- #start_test_session(service: nil, tags: {}) ⇒ Object
- #start_test_suite(test_suite_name, service: nil, tags: {}) ⇒ Object
- #trace(span_name, type: "span", tags: {}, &block) ⇒ Object
- #trace_test(test_name, test_suite_name, service: nil, tags: {}, &block) ⇒ Object
Constructor Details
#initialize(test_optimisation:, remote_settings_api:, git_tree_upload_worker: DummyWorker.new, test_suite_level_visibility_enabled: false, codeowners: Codeowners::Parser.new(Git::LocalRepository.root).parse) ⇒ Component
Returns a new instance of Component.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/datadog/ci/test_visibility/component.rb', line 22 def initialize( test_optimisation:, remote_settings_api:, git_tree_upload_worker: DummyWorker.new, test_suite_level_visibility_enabled: false, codeowners: Codeowners::Parser.new(Git::LocalRepository.root).parse ) @test_suite_level_visibility_enabled = test_suite_level_visibility_enabled @context = Context.new @codeowners = codeowners @test_optimisation = test_optimisation @remote_settings_api = remote_settings_api @git_tree_upload_worker = git_tree_upload_worker end |
Instance Attribute Details
#test_suite_level_visibility_enabled ⇒ Object (readonly)
Returns the value of attribute test_suite_level_visibility_enabled.
20 21 22 |
# File 'lib/datadog/ci/test_visibility/component.rb', line 20 def test_suite_level_visibility_enabled @test_suite_level_visibility_enabled end |
Instance Method Details
#active_span ⇒ Object
90 91 92 |
# File 'lib/datadog/ci/test_visibility/component.rb', line 90 def active_span @context.active_span end |
#active_test ⇒ Object
94 95 96 |
# File 'lib/datadog/ci/test_visibility/component.rb', line 94 def active_test @context.active_test end |
#active_test_module ⇒ Object
102 103 104 |
# File 'lib/datadog/ci/test_visibility/component.rb', line 102 def active_test_module @context.active_test_module end |
#active_test_session ⇒ Object
98 99 100 |
# File 'lib/datadog/ci/test_visibility/component.rb', line 98 def active_test_session @context.active_test_session end |
#active_test_suite(test_suite_name) ⇒ Object
106 107 108 |
# File 'lib/datadog/ci/test_visibility/component.rb', line 106 def active_test_suite(test_suite_name) @context.active_test_suite(test_suite_name) end |
#deactivate_test ⇒ Object
110 111 112 113 114 115 |
# File 'lib/datadog/ci/test_visibility/component.rb', line 110 def deactivate_test test = active_test on_test_finished(test) if test @context.deactivate_test end |
#deactivate_test_module ⇒ Object
124 125 126 127 128 129 |
# File 'lib/datadog/ci/test_visibility/component.rb', line 124 def deactivate_test_module test_module = active_test_module on_test_module_finished(test_module) if test_module @context.deactivate_test_module end |
#deactivate_test_session ⇒ Object
117 118 119 120 121 122 |
# File 'lib/datadog/ci/test_visibility/component.rb', line 117 def deactivate_test_session test_session = active_test_session on_test_session_finished(test_session) if test_session @context.deactivate_test_session end |
#deactivate_test_suite(test_suite_name) ⇒ Object
131 132 133 134 135 136 |
# File 'lib/datadog/ci/test_visibility/component.rb', line 131 def deactivate_test_suite(test_suite_name) test_suite = active_test_suite(test_suite_name) on_test_suite_finished(test_suite) if test_suite @context.deactivate_test_suite(test_suite_name) end |
#itr_enabled? ⇒ Boolean
138 139 140 |
# File 'lib/datadog/ci/test_visibility/component.rb', line 138 def itr_enabled? @test_optimisation.enabled? end |
#shutdown! ⇒ Object
37 38 39 |
# File 'lib/datadog/ci/test_visibility/component.rb', line 37 def shutdown! @git_tree_upload_worker.stop end |
#start_test_module(test_module_name, service: nil, tags: {}) ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/datadog/ci/test_visibility/component.rb', line 49 def start_test_module(test_module_name, service: nil, tags: {}) return skip_tracing unless test_suite_level_visibility_enabled test_module = @context.start_test_module(test_module_name, service: service, tags: ) on_test_module_started(test_module) test_module end |
#start_test_session(service: nil, tags: {}) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/datadog/ci/test_visibility/component.rb', line 41 def start_test_session(service: nil, tags: {}) return skip_tracing unless test_suite_level_visibility_enabled test_session = @context.start_test_session(service: service, tags: ) on_test_session_started(test_session) test_session end |
#start_test_suite(test_suite_name, service: nil, tags: {}) ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/datadog/ci/test_visibility/component.rb', line 57 def start_test_suite(test_suite_name, service: nil, tags: {}) return skip_tracing unless test_suite_level_visibility_enabled test_suite = @context.start_test_suite(test_suite_name, service: service, tags: ) on_test_suite_started(test_suite) test_suite end |
#trace(span_name, type: "span", tags: {}, &block) ⇒ Object
80 81 82 83 84 85 86 87 88 |
# File 'lib/datadog/ci/test_visibility/component.rb', line 80 def trace(span_name, type: "span", tags: {}, &block) if block @context.trace(span_name, type: type, tags: ) do |span| block.call(span) end else @context.trace(span_name, type: type, tags: ) end end |
#trace_test(test_name, test_suite_name, service: nil, tags: {}, &block) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/datadog/ci/test_visibility/component.rb', line 65 def trace_test(test_name, test_suite_name, service: nil, tags: {}, &block) if block @context.trace_test(test_name, test_suite_name, service: service, tags: ) do |test| on_test_started(test) res = block.call(test) on_test_finished(test) res end else test = @context.trace_test(test_name, test_suite_name, service: service, tags: ) on_test_started(test) test end end |