Class: Datadog::CI::TestVisibility::Store::Process
- Inherits:
-
Object
- Object
- Datadog::CI::TestVisibility::Store::Process
- Defined in:
- lib/datadog/ci/test_visibility/store/process.rb
Overview
This context is shared between threads and represents the current test session and test module.
Instance Attribute Summary collapse
-
#readonly_test_module ⇒ Object
readonly
Returns the value of attribute readonly_test_module.
-
#readonly_test_session ⇒ Object
readonly
Returns the value of attribute readonly_test_session.
Instance Method Summary collapse
- #active_test_module ⇒ Object
- #active_test_session ⇒ Object
- #active_test_suite(test_suite_name) ⇒ Object
- #deactivate_test_module! ⇒ Object
- #deactivate_test_session! ⇒ Object
- #deactivate_test_suite!(test_suite_name) ⇒ Object
- #fetch_or_activate_test_module(&block) ⇒ Object
- #fetch_or_activate_test_session(&block) ⇒ Object
- #fetch_or_activate_test_suite(test_suite_name, &block) ⇒ Object
- #fetch_single_test_suite ⇒ Object
-
#initialize ⇒ Process
constructor
A new instance of Process.
- #set_readonly_test_module(remote_test_module) ⇒ Object
- #set_readonly_test_session(remote_test_session) ⇒ Object
- #stop_all_test_suites ⇒ Object
Constructor Details
#initialize ⇒ Process
Returns a new instance of Process.
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/datadog/ci/test_visibility/store/process.rb', line 14 def initialize # we are using Monitor instead of Mutex because it is reentrant @mutex = Monitor.new @test_session = nil @test_module = nil @test_suites = {} # small copies of id, name and some tags: store them in the current process to set session/module context # for any spans faster @readonly_test_session = nil @readonly_test_module = nil end |
Instance Attribute Details
#readonly_test_module ⇒ Object (readonly)
Returns the value of attribute readonly_test_module.
12 13 14 |
# File 'lib/datadog/ci/test_visibility/store/process.rb', line 12 def readonly_test_module @readonly_test_module end |
#readonly_test_session ⇒ Object (readonly)
Returns the value of attribute readonly_test_session.
12 13 14 |
# File 'lib/datadog/ci/test_visibility/store/process.rb', line 12 def readonly_test_session @readonly_test_session end |
Instance Method Details
#active_test_module ⇒ Object
54 55 56 |
# File 'lib/datadog/ci/test_visibility/store/process.rb', line 54 def active_test_module @test_module end |
#active_test_session ⇒ Object
58 59 60 |
# File 'lib/datadog/ci/test_visibility/store/process.rb', line 58 def active_test_session @test_session end |
#active_test_suite(test_suite_name) ⇒ Object
62 63 64 |
# File 'lib/datadog/ci/test_visibility/store/process.rb', line 62 def active_test_suite(test_suite_name) @mutex.synchronize { @test_suites[test_suite_name] } end |
#deactivate_test_module! ⇒ Object
77 78 79 |
# File 'lib/datadog/ci/test_visibility/store/process.rb', line 77 def deactivate_test_module! @mutex.synchronize { @test_module = nil } end |
#deactivate_test_session! ⇒ Object
73 74 75 |
# File 'lib/datadog/ci/test_visibility/store/process.rb', line 73 def deactivate_test_session! @mutex.synchronize { @test_session = nil } end |
#deactivate_test_suite!(test_suite_name) ⇒ Object
81 82 83 |
# File 'lib/datadog/ci/test_visibility/store/process.rb', line 81 def deactivate_test_suite!(test_suite_name) @mutex.synchronize { @test_suites.delete(test_suite_name) } end |
#fetch_or_activate_test_module(&block) ⇒ Object
42 43 44 45 46 |
# File 'lib/datadog/ci/test_visibility/store/process.rb', line 42 def fetch_or_activate_test_module(&block) @mutex.synchronize do @test_module ||= block.call end end |
#fetch_or_activate_test_session(&block) ⇒ Object
48 49 50 51 52 |
# File 'lib/datadog/ci/test_visibility/store/process.rb', line 48 def fetch_or_activate_test_session(&block) @mutex.synchronize do @test_session ||= block.call end end |
#fetch_or_activate_test_suite(test_suite_name, &block) ⇒ Object
28 29 30 31 32 |
# File 'lib/datadog/ci/test_visibility/store/process.rb', line 28 def fetch_or_activate_test_suite(test_suite_name, &block) @mutex.synchronize do @test_suites[test_suite_name] ||= block.call end end |
#fetch_single_test_suite ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/datadog/ci/test_visibility/store/process.rb', line 34 def fetch_single_test_suite @mutex.synchronize do return nil if @test_suites.empty? || @test_suites.size > 1 @test_suites.values.first end end |
#set_readonly_test_module(remote_test_module) ⇒ Object
91 92 93 94 95 |
# File 'lib/datadog/ci/test_visibility/store/process.rb', line 91 def set_readonly_test_module(remote_test_module) return if remote_test_module.nil? @readonly_test_module = Datadog::CI::ReadonlyTestModule.new(remote_test_module) end |
#set_readonly_test_session(remote_test_session) ⇒ Object
85 86 87 88 89 |
# File 'lib/datadog/ci/test_visibility/store/process.rb', line 85 def set_readonly_test_session(remote_test_session) return if remote_test_session.nil? @readonly_test_session = Datadog::CI::ReadonlyTestSession.new(remote_test_session) end |
#stop_all_test_suites ⇒ Object
66 67 68 69 70 71 |
# File 'lib/datadog/ci/test_visibility/store/process.rb', line 66 def stop_all_test_suites @mutex.synchronize do @test_suites.each_value(&:finish) @test_suites.clear end end |