Class: Beaker::CLI
- Inherits:
-
Object
- Object
- Beaker::CLI
- Defined in:
- lib/beaker/cli.rb
Instance Method Summary collapse
- #execute! ⇒ Object
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
- #run_suite(name, options, failure_strategy = false) ⇒ Object
Constructor Details
#initialize ⇒ CLI
Returns a new instance of CLI.
3 4 5 6 7 8 9 10 11 12 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 39 40 41 42 43 44 |
# File 'lib/beaker/cli.rb', line 3 def initialize @options = Beaker::Options.parse_args @logger = Beaker::Logger.new(@options) @options[:logger] = @logger if not @options[:config] report_and_raise(@logger, RuntimeError.new("Argh! There is no default for Config, specify one (-c or --config)!"), "CLI: initialize") end @logger.debug("Options") @options.each do |opt, val| if val and val != [] @logger.debug("\t#{opt.to_s}:") if val.kind_of?(Array) val.each do |v| @logger.debug("\t\t#{v.to_s}") end else @logger.debug("\t\t#{val.to_s}") end end end @config = Beaker::TestConfig.new(@options[:config], @options) #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 @hosts = [] @network_manager = Beaker::NetworkManager.new(@config, @options, @logger) @hosts = @network_manager.provision #validate that the hosts are correctly configured Beaker::Utils::Validator.validate(@hosts, @logger) end |
Instance Method Details
#execute! ⇒ Object
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 93 94 95 96 97 98 99 100 |
# File 'lib/beaker/cli.rb', line 46 def execute! @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 trap(:INT) do @logger.warn "Interrupt received; exiting..." exit(1) end #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 #pre acceptance phase run_suite('pre-suite', @options.merge({:tests => @options[:pre_suite]}), :fail_fast) #testing phase begin run_suite('acceptance', @options) #post acceptance phase rescue => e #post acceptance on failure #if we error then run the post suite as long as we aren't in fail-stop mode run_suite('post-suite', @options.merge({:tests => @options[:post_suite]})) unless @options[:fail_mode] == "stop" raise e else #post acceptance on success run_suite('post-suite', @options.merge({:tests => @options[:post_suite]})) end #cleanup phase rescue => e #cleanup on error #only do cleanup if we aren't in fail-stop mode @logger.notify "Cleanup: cleaning up after failed run" if @options[:fail_mode] != "stop" @network_manager.cleanup end raise "Failed to execute tests!" else #cleanup on success @logger.notify "Cleanup: cleaning up after successful run" @network_manager.cleanup end end |
#run_suite(name, options, failure_strategy = false) ⇒ Object
102 103 104 105 106 107 108 109 110 |
# File 'lib/beaker/cli.rb', line 102 def run_suite(name, , failure_strategy = false) if ([:tests].empty?) @logger.notify("No tests to run for suite '#{name}'") return end Beaker::TestSuite.new( name, @hosts, , @config, failure_strategy ).run_and_raise_on_failure end |