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 39 40 |
# 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] require 'rubygems' unless defined?(Gem) spec = Gem::Specification::load(GEMSPEC) @logger.notify(VERSION_STRING % spec.version) 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
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 |
# File 'lib/beaker/cli.rb', line 84 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
42 43 44 45 46 47 48 49 50 |
# File 'lib/beaker/cli.rb', line 42 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
132 133 134 135 136 137 138 139 140 |
# File 'lib/beaker/cli.rb', line 132 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
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/beaker/cli.rb', line 61 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
52 53 54 55 56 57 58 59 |
# File 'lib/beaker/cli.rb', line 52 def validate begin #validation phase Beaker::Utils::Validator.validate(@hosts, @logger) rescue => e report_and_raise(@logger, e, "CLI.validate") end end |