Class: Beaker::CLI
- Inherits:
-
Object
- Object
- Beaker::CLI
- Defined in:
- lib/beaker/cli.rb
Constant Summary collapse
- GEMSPEC =
File.join(File.(File.dirname(__FILE__)), "../../beaker.gemspec")
- VERSION_STRING =
" wWWWw |o o| | O | %s! |(\")| / \\X/ \\ | V | | | | "
Instance Method Summary collapse
- #execute! ⇒ Object
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
- #provision ⇒ Object
- #run_suite(suite_name, failure_strategy = false) ⇒ Object
- #setup ⇒ Object
- #validate ⇒ Object
Constructor Details
#initialize ⇒ CLI
Returns a new instance of CLI.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/beaker/cli.rb', line 13 def initialize @options_parser = Beaker::Options::Parser.new @options = @options_parser.parse_args @logger = Beaker::Logger.new(@options) @options[:logger] = @logger if @options[:help] @logger.notify(@options_parser.usage) exit end if @options[:version] @logger.notify(VERSION_STRING % Beaker::Version::STRING) exit end @logger.info(@options.dump) #add additional paths to the LOAD_PATH if not @options[:load_path].empty? @options[:load_path].each do |path| $LOAD_PATH << File.(path) end end @options[:helper].each do |helper| require File.(helper) end end |
Instance Method Details
#execute! ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/beaker/cli.rb', line 82 def execute! begin trap(:INT) do @logger.warn "Interrupt received; exiting..." exit(1) end provision validate setup errored = false #pre acceptance phase run_suite(:pre_suite, :fast) #testing phase begin run_suite(:tests) #post acceptance phase rescue => e #post acceptance on failure #run post-suite if we are in fail-slow mode if @options[:fail_mode] =~ /slow/ run_suite(:post_suite) end raise e else #post acceptance on success run_suite(:post_suite) end #cleanup phase rescue => e #cleanup on error if @options[:preserve_hosts] =~ /(never)/ @logger.notify "Cleanup: cleaning up after failed run" if @network_manager @network_manager.cleanup end end raise "Failed to execute tests!" else #cleanup on success if @options[:preserve_hosts] =~ /(never)|(onfail)/ @logger.notify "Cleanup: cleaning up after successful run" if @network_manager @network_manager.cleanup end end end end |
#provision ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/beaker/cli.rb', line 40 def provision begin @hosts = [] @network_manager = Beaker::NetworkManager.new(@options, @logger) @hosts = @network_manager.provision rescue => e report_and_raise(@logger, e, "CLI.provision") end end |
#run_suite(suite_name, failure_strategy = false) ⇒ Object
135 136 137 138 139 140 141 142 143 |
# File 'lib/beaker/cli.rb', line 135 def run_suite(suite_name, failure_strategy = false) if (@options[suite_name].empty?) @logger.notify("No tests to run for suite '#{suite_name.to_s}'") return end Beaker::TestSuite.new( suite_name, @hosts, @options, failure_strategy ).run_and_raise_on_failure end |
#setup ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/beaker/cli.rb', line 59 def setup @ntp_controller = Beaker::Utils::NTPControl.new(@options, @hosts) @setup = Beaker::Utils::SetupHelper.new(@options, @hosts) @repo_controller = Beaker::Utils::RepoControl.new(@options, @hosts) setup_steps = [[:timesync, "Sync time on hosts", Proc.new {@ntp_controller.timesync}], [:root_keys, "Sync keys to hosts" , Proc.new {@setup.sync_root_keys}], [:repo_proxy, "Proxy packaging repositories on ubuntu, debian and solaris-11", Proc.new {@repo_controller.proxy_config}], [:add_el_extras, "Add Extra Packages for Enterprise Linux (EPEL) repository to el-* hosts", Proc.new {@repo_controller.add_el_extras}], [:add_master_entry, "Update /etc/hosts on master with master's ip", Proc.new {@setup.add_master_entry}]] begin #setup phase setup_steps.each do |step| if (not @options.has_key?(step[0])) or @options[step[0]] @logger.notify "" @logger.notify "Setup: #{step[1]}" step[2].call end end rescue => e report_and_raise(@logger, e, "CLI.setup") end end |
#validate ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/beaker/cli.rb', line 50 def validate begin #validation phase Beaker::Utils::Validator.validate(@hosts, @logger) rescue => e report_and_raise(@logger, e, "CLI.validate") end end |