Class: Vagabond::Kitchen
- Inherits:
-
Thor
- Object
- Thor
- Vagabond::Kitchen
- Includes:
- Thor::Actions, Actions::Status, Helpers
- Defined in:
- lib/vagabond/kitchen.rb
Constant Summary
Constants included from Helpers
Helpers::GEN_NAME_LENGTH, Helpers::RAND_CHARS
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#internal_config ⇒ Object
readonly
Returns the value of attribute internal_config.
-
#kitchen ⇒ Object
readonly
Returns the value of attribute kitchen.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#ui ⇒ Object
readonly
Returns the value of attribute ui.
-
#vagabondfile ⇒ Object
readonly
Returns the value of attribute vagabondfile.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*args) ⇒ Kitchen
constructor
A new instance of Kitchen.
- #status(name = nil) ⇒ Object
- #teardown(cookbook) ⇒ Object
- #test(*args) ⇒ Object
Methods included from Actions::Status
Methods included from Helpers
Constructor Details
#initialize(*args) ⇒ Kitchen
Returns a new instance of Kitchen.
35 36 37 |
# File 'lib/vagabond/kitchen.rb', line 35 def initialize(*args) super end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
32 33 34 |
# File 'lib/vagabond/kitchen.rb', line 32 def action @action end |
#internal_config ⇒ Object (readonly)
Returns the value of attribute internal_config.
33 34 35 |
# File 'lib/vagabond/kitchen.rb', line 33 def internal_config @internal_config end |
#kitchen ⇒ Object (readonly)
Returns the value of attribute kitchen.
27 28 29 |
# File 'lib/vagabond/kitchen.rb', line 27 def kitchen @kitchen end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
31 32 33 |
# File 'lib/vagabond/kitchen.rb', line 31 def name @name end |
#ui ⇒ Object (readonly)
Returns the value of attribute ui.
30 31 32 |
# File 'lib/vagabond/kitchen.rb', line 30 def ui @ui end |
#vagabondfile ⇒ Object (readonly)
Returns the value of attribute vagabondfile.
29 30 31 |
# File 'lib/vagabond/kitchen.rb', line 29 def vagabondfile @vagabondfile end |
Class Method Details
.basename ⇒ Object
20 21 22 |
# File 'lib/vagabond/kitchen.rb', line 20 def basename 'vagabond kitchen' end |
Instance Method Details
#status(name = nil) ⇒ Object
143 144 145 146 |
# File 'lib/vagabond/kitchen.rb', line 143 def status(name=nil) setup(name, :status) _status end |
#teardown(cookbook) ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/vagabond/kitchen.rb', line 48 def teardown(cookbook) ui.info "#{ui.color('Vagabond:', :bold)} - Kitchen teardown for cookbook #{ui.color(name, :red)}" plats = [platform || [:platform] || platform_map.keys].flatten plats.each do |plat| validate_platform!(plat) ui.info ui.color(" -> Tearing down platform: #{plat}", :red) vagabond_instance(:destroy, plat).send(:execute) ui.info ui.color(" -> Teardown of platform: #{plat} - COMPLETE!", :red) end end |
#test(*args) ⇒ 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 134 135 136 137 138 139 140 |
# File 'lib/vagabond/kitchen.rb', line 82 def test(*args) cookbook = args.first setup(cookbook, :test) ui.info "#{ui.color('Vagabond:', :bold)} - Kitchen testing for cookbook #{ui.color(name, :cyan)}" results = Mash.new platforms = [[:platform] || platform_map.keys].flatten if(cluster_name = [:cluster]) ui.info ui.color(" -> Cluster Testing #{cluster_name}!", :yellow) if(kitchen.clusters.empty? || kitchen.clusters[cluster_name].nil?) ui.fatal "Requested cluster is not defined: #{[:cluster]}" raise VagabondError::ClusterInvalid.new(cluster_name) end serv = Server.new if(@solo && serv.vagabondfile[:local_chef_server].empty?) serv.vagabondfile[:local_chef_server].update(:enabled => true, :zero => true) end serv. = serv.send(:do_create) serv.auto_upload # upload everything : make optional? suites = kitchen.clusters[[:cluster]] platforms.each do |platform| %w(local_server_provision test destroy).each do |action| suites.each do |suite_name| res = self.send("#{action}_node", platform, suite_name) if(action == 'test') results[platform] ||=[] results[platform] << { :suite_name => suite_name, :result => res } end end end end serv.destroy else suites = [:suites] ? [:suites].split(',') : ['default'] platforms.each do |platform| suites.each do |suite_name| provision_node(platform, suite_name) results[platform] ||= [] results[platform] << { :suite_name => suite_name, :result => test_node(platform, suite_name) } destroy_node(platform, suite_name) end end end ui.info ui.color('Kitchen Test Results:', :bold) results.each do |platform, infos| ui.info " Platform: #{ui.color(platform, :blue, :bold)}" infos.each do |res| ui.info " Suite: #{res[:suite_name]} -> #{res[:result] ? ui.color('SUCCESS!', :green) : ui.color('FAILED!', :red)}" end end raise KitchenTestFailed.new(infos.map{|res| res[:suite_name] unless res[:result]}.compact) end |