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.
- #provision ⇒ Object
- #run_suite(suite_name, failure_strategy = false) ⇒ Object
- #setup ⇒ Object
- #validate ⇒ 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 |
# File 'lib/beaker/cli.rb', line 3 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 @logger.notify(@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
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 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/beaker/cli.rb', line 68 def execute! begin trap(:INT) do @logger.warn "Interrupt received; exiting..." exit(1) end provision validate setup #pre acceptance phase run_suite(:pre_suite, :fail_fast) #testing phase begin run_suite(:tests) #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) unless @options[:fail_mode] == "stop" raise e else #post acceptance on success run_suite(: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" if @network_manager @network_manager.cleanup end end raise "Failed to execute tests!" else #cleanup on success @logger.notify "Cleanup: cleaning up after successful run" if @network_manager @network_manager.cleanup end end end |
#provision ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/beaker/cli.rb', line 26 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
116 117 118 119 120 121 122 123 124 |
# File 'lib/beaker/cli.rb', line 116 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
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/beaker/cli.rb', line 45 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
36 37 38 39 40 41 42 43 |
# File 'lib/beaker/cli.rb', line 36 def validate begin #validation phase Beaker::Utils::Validator.validate(@hosts, @logger) rescue => e report_and_raise(@logger, e, "CLI.validate") end end |