Class: CemAcpt::TestRunner::Runner
- Inherits:
-
Object
- Object
- CemAcpt::TestRunner::Runner
- Includes:
- Logging
- Defined in:
- lib/cem_acpt/test_runner.rb
Overview
Holds all the Runner related code
Constant Summary
Constants included from Logging
Instance Attribute Summary collapse
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#exit_code ⇒ Object
readonly
Returns the value of attribute exit_code.
-
#run_data ⇒ Object
This is opened up mainly for windows use.
Instance Method Summary collapse
- #clean_up(trap_context = false) ⇒ Object
-
#initialize(config) ⇒ Runner
constructor
A new instance of Runner.
- #inspect ⇒ Object
- #run ⇒ Object
- #to_s ⇒ Object
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(config) ⇒ Runner
Returns a new instance of Runner.
25 26 27 28 29 30 31 32 33 |
# File 'lib/cem_acpt/test_runner.rb', line 25 def initialize(config) @config = config @run_data = {} @duration = 0 @exit_code = 0 @results = [] @http_statuses = [] @provisioned = false end |
Instance Attribute Details
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
22 23 24 |
# File 'lib/cem_acpt/test_runner.rb', line 22 def duration @duration end |
#exit_code ⇒ Object (readonly)
Returns the value of attribute exit_code.
22 23 24 |
# File 'lib/cem_acpt/test_runner.rb', line 22 def exit_code @exit_code end |
#run_data ⇒ Object
This is opened up mainly for windows use.
23 24 25 |
# File 'lib/cem_acpt/test_runner.rb', line 23 def run_data @run_data end |
Instance Method Details
#clean_up(trap_context = false) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/cem_acpt/test_runner.rb', line 94 def clean_up(trap_context = false) logger.end_ci_group kill_keep_terminal_alive unless trap_context cleanup_bucket # Clean up bucket if we're testing the cem_windows module return no_destroy if config.get('no_destroy_nodes') clean_ephemeral_ssh_keys destroy_test_nodes if @provisioned && !@destroyed rescue StandardError => e logger.verbose('CemAcpt::TestRunner') { "Error cleaning up: #{e}" } logger.verbose('CemAcpt::TestRunner') { e.backtrace.join("\n") } end |
#inspect ⇒ Object
35 36 37 |
# File 'lib/cem_acpt/test_runner.rb', line 35 def inspect to_s end |
#run ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/cem_acpt/test_runner.rb', line 43 def run @run_data = {} @start_time = Time.now module_dir = config.get('module_dir') @old_dir = Dir.pwd Dir.chdir(module_dir) logger.start_ci_group("CemAcpt v#{CemAcpt::VERSION} run started at #{@start_time}") logger.info('CemAcpt::TestRunner') { "Using module directory: #{module_dir}..." } keep_terminal_alive @run_data[:private_key], @run_data[:public_key], @run_data[:known_hosts] = new_ephemeral_ssh_keys logger.info('CemAcpt::TestRunner') { 'Created ephemeral SSH key pair...' } @run_data[:module_package_path] = build_module_package logger.info('CemAcpt::TestRunner') { "Created module package: #{@run_data[:module_package_path]}..." } @run_data[:test_data] = new_test_data logger.info('CemAcpt::TestRunner') { 'Created test data...' } logger.verbose('CemAcpt::TestRunner') { "Test data: #{@run_data[:test_data]}" } @run_data[:nodes] = new_node_data logger.info('CemAcpt::TestRunner') { 'Created node data...' } logger.verbose('CemAcpt::TestRunner') { "Node data: #{@run_data[:nodes]}" } @instance_names_ips = provision_test_nodes logger.info('CemAcpt::TestRunner') { "Instance names and IPs class: #{@instance_names_ips.class}" } @provisioned = true logger.info('CemAcpt::TestRunner') { 'Provisioned test nodes...' } logger.debug('CemAcpt::TestRunner') { "Instance names and IPs: #{@instance_names_ips}" } # Verifying that we're running on windows nodes or not if config.get('tests').first.include? 'windows' logger.info('CemAcpt') { 'Running on windows nodes...' } upload_module_to_bucket @instance_names_ips.each do |k, v| # Login_info here is basically a super charged version of a hash from # instance_names_ips. It contains the username, password, and ip of the # windows node, as well as the test name that will be run on that node. login_info = CemAcpt::Utils.get_windows_login_info(k, v) win_node = CemAcpt::Utils::WinRMRunner::WinNode.new(login_info, @run_data[:module_package_path].split('/').last) win_node.run end end @results = run_tests(@instance_names_ips.map { |_, v| v['ip'] }, config.get('actions.only'), config.get('actions.except')) rescue StandardError => e logger.error('CemAcpt::TestRunner') { 'Run failed due to error...' } @results << ActionResult.new(e) ensure clean_up process_test_results Dir.chdir(@old_dir) if @old_dir @results end |
#to_s ⇒ Object
39 40 41 |
# File 'lib/cem_acpt/test_runner.rb', line 39 def to_s "#<#{self.class.name}:0x#{object_id.to_s(16)}>" end |