Class: Applitools::Selenium::VisualGridRunner
- Inherits:
-
ClassicRunner
- Object
- ClassicRunner
- Applitools::Selenium::VisualGridRunner
- Defined in:
- lib/applitools/selenium/visual_grid/visual_grid_runner.rb
Constant Summary collapse
- EMPTY_QUEUE =
rubocop:disable Style/MutableConstant
[]
Instance Attribute Summary collapse
-
#all_eyes ⇒ Object
Returns the value of attribute all_eyes.
-
#put_cache ⇒ Object
Returns the value of attribute put_cache.
-
#render_queue ⇒ Object
(also: #queue)
Returns the value of attribute render_queue.
-
#rendering_info(connector) ⇒ Object
Returns the value of attribute rendering_info.
-
#resource_cache ⇒ Object
Returns the value of attribute resource_cache.
Instance Method Summary collapse
- #enqueue_render_task(render_task) ⇒ Object
- #get_all_test_results(throw_exception = false) ⇒ Object
- #init ⇒ Object
-
#initialize(concurrent_open_sessions = 10) ⇒ VisualGridRunner
constructor
A new instance of VisualGridRunner.
- #open(eyes) ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(concurrent_open_sessions = 10) ⇒ VisualGridRunner
Returns a new instance of VisualGridRunner.
12 13 14 15 16 17 18 19 20 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_runner.rb', line 12 def initialize(concurrent_open_sessions = 10) super() self.all_eyes = [] self.render_queue = [] @thread_pool = Applitools::Selenium::VGThreadPool.new(concurrent_open_sessions) self.resource_cache = Applitools::Selenium::ResourceCache.new self.put_cache = Applitools::Selenium::ResourceCache.new init end |
Instance Attribute Details
#all_eyes ⇒ Object
Returns the value of attribute all_eyes.
7 8 9 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_runner.rb', line 7 def all_eyes @all_eyes end |
#put_cache ⇒ Object
Returns the value of attribute put_cache.
7 8 9 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_runner.rb', line 7 def put_cache @put_cache end |
#render_queue ⇒ Object Also known as: queue
Returns the value of attribute render_queue.
7 8 9 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_runner.rb', line 7 def render_queue @render_queue end |
#rendering_info(connector) ⇒ Object
Returns the value of attribute rendering_info.
7 8 9 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_runner.rb', line 7 def rendering_info @rendering_info end |
#resource_cache ⇒ Object
Returns the value of attribute resource_cache.
7 8 9 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_runner.rb', line 7 def resource_cache @resource_cache end |
Instance Method Details
#enqueue_render_task(render_task) ⇒ Object
33 34 35 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_runner.rb', line 33 def enqueue_render_task(render_task) render_queue.push render_task if render_task.is_a? Applitools::Selenium::RenderTask end |
#get_all_test_results(throw_exception = false) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_runner.rb', line 46 def get_all_test_results(throw_exception = false) all_tasks_completed = proc do all_running_tests.count == 0 || (states = all_running_tests.map(&:state_name).uniq).count == 1 && states.first == :completed end sleep 0.5 until all_tasks_completed.call failed_results = all_test_results.select { |r| !r.as_expected? } failed_results.each do |r| exception = Applitools::NewTestError.new (r), r if r.new? exception = Applitools::DiffsFoundError.new (r), r if r.unresolved? && !r.new? exception = Applitools::TestFailedError.new (r), r if r.failed? aggregate_exceptions(r, exception) end super end |
#init ⇒ Object
22 23 24 25 26 27 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_runner.rb', line 22 def init @thread_pool.on_next_task_needed do (task = get_task_queue.pop).is_a?(Applitools::Selenium::VGTask) ? task : nil end @thread_pool.start end |
#open(eyes) ⇒ Object
29 30 31 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_runner.rb', line 29 def open(eyes) all_eyes << eyes end |
#stop ⇒ Object
37 38 39 40 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_runner.rb', line 37 def stop sleep 0.5 while all_running_tests.map(&:score).reduce(0, :+) > 0 @thread_pool.stop end |