require 'spec_helper_acceptance' describe "Acceptance Testing" do before :each do |test| # Steop out a bunch of time to make sure we are at 0 # Yes this stupid, i know 10.times { logger.step_out } #try to find the indentation level and mirror it in beaker logger # Get the depth and add that as padding (test.metadata[:scoped_id].split(':').count - 1).times do logger.step_in end end <% tests.each do |test| -%> <% test.nodes.each do |node| -%> <% test.classes.each do |cls| -%> describe "<%= cls.name %> on <%= node.name %>" do after :all do # We have to use step_in and step_out here # otherwise everything will break, not my fault 10.times { logger.step_out } 2.times { logger.step_in } $nwm.cleanup end describe "provisioning <%= node.name %>" do #after :all do # # Reset the HOSTS hash to its original value # options[:HOSTS] = $original_hosts #end it "should be able to set up a Beaker Network Manger object to handle the hypervisors" do current_opts = {} OPTIONS.each do |opt,val| if opt == :HOSTS val.each do |k,v| if k == :'<%= node.name %>' current_opts[:HOSTS] = {k => v} end end else current_opts[opt] = val end end # I copied this code off the internet, basically it allows us # to refer to each key as either a string or an object current_opts.default_proc = proc do |h, k| case k when String then sym = k.to_sym; h[sym] if h.key?(sym) when Symbol then str = k.to_s; h[str] if h.key?(str) end end expect { $nwm = Beaker::NetworkManager.new(current_opts,logger) }.to_not raise_exception end it "should be able to provision using Beaker" do expect { $nwm.provision $nwm.proxy_package_manager $nwm.validate $nwm.configure $hosts = $nwm.instance_variable_get(:@hosts) }.not_to raise_exception end end describe "copying code to <%= node.name %>" do it "should copy the code successfully" do expect { scp_to $hosts, 'etc', '/' }.not_to raise_exception end end <% test.options['runs_before_idempotency'].times do %> describe "running puppet" do it "should run with no errors" do expect { manifest = < include <%= cls.name %> CODE apply_manifest_on($hosts,manifest,{:catch_failures => true}) }.not_to raise_exception end end <% end -%> <% if test.options['check_idempotency'] then %> describe "checking for idempotency" do it "should run with no changes" do expect { manifest = < include <%= cls.name %> CODE apply_manifest_on($hosts,manifest,{:catch_changes => true}) }.not_to raise_exception end end <% end -%> end <% end -%> <% end -%> <% end -%> end