Class: CemAcpt::TestRunner::RunHandler
- Inherits:
-
Object
- Object
- CemAcpt::TestRunner::RunHandler
- Includes:
- Logging
- Defined in:
- lib/cem_acpt/test_runner/run_handler.rb
Overview
RunHandler orchestrates the acceptance test suites, including creating Runner objects, handling input and output, and exception handling.
Constant Summary
Constants included from Logging
Instance Attribute Summary collapse
-
#run_context ⇒ Object
Returns the value of attribute run_context.
Instance Method Summary collapse
- #destroy_test_nodes ⇒ Object
-
#exit_code ⇒ Object
Gets the overall exit code for all runners.
-
#initialize(run_context) ⇒ RunHandler
constructor
A new instance of RunHandler.
-
#run ⇒ Object
Runs the acceptance test suites.
Methods included from Logging
current_log_config, #current_log_config, current_log_format, #current_log_format, current_log_level, #current_log_level, included, logger, #logger, new_log_config, #new_log_config, new_log_formatter, #new_log_formatter, new_log_level, #new_log_level, new_logger, #new_logger
Constructor Details
#initialize(run_context) ⇒ RunHandler
Returns a new instance of RunHandler.
27 28 29 30 31 32 |
# File 'lib/cem_acpt/test_runner/run_handler.rb', line 27 def initialize(run_context) @run_context = run_context @module_pkg_path = Concurrent::IVar.new @runners = Concurrent::Array.new @thread_pool = Concurrent::SimpleExecutorService.new end |
Instance Attribute Details
#run_context ⇒ Object
Returns the value of attribute run_context.
24 25 26 |
# File 'lib/cem_acpt/test_runner/run_handler.rb', line 24 def run_context @run_context end |
Instance Method Details
#destroy_test_nodes ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/cem_acpt/test_runner/run_handler.rb', line 55 def destroy_test_nodes return if @runners.empty? || @runners.none?(&:node_exists) @runners.each do |r| r.send(:destroy) if r.node_exists end end |
#exit_code ⇒ Object
Gets the overall exit code for all runners
35 36 37 |
# File 'lib/cem_acpt/test_runner/run_handler.rb', line 35 def exit_code @runners&.map { |r| r.run_result.exit_status }&.all?(&:zero?) ? 0 : 1 end |
#run ⇒ Object
Runs the acceptance test suites.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/cem_acpt/test_runner/run_handler.rb', line 40 def run logger.info('RUN HANDLER: Creating and starting test runners...') create_runners logger.info("RUN HANDLER: Created #{@runners.length} runners...") @runners.map { |r| @thread_pool.post { r.start } } @thread_pool.shutdown @thread_pool.wait_for_termination @thread_pool = Concurrent::SimpleExecutorService.new logger.info('Test runners have all exited...') rescue StandardError => e handle_fatal_error(e) ensure handle_test_results end |