Skip to content

Commit

Permalink
(BKR-656) Update spec tests for do_install
Browse files Browse the repository at this point in the history
Commit 7112971 introduced changes to
the do_install method but did not have any updates for the spec tests.
This commit adds those tests in.
  • Loading branch information
tvpartytonight committed May 13, 2016
1 parent a6fd7be commit b602661
Showing 1 changed file with 32 additions and 21 deletions.
53 changes: 32 additions & 21 deletions spec/beaker-pe/install/pe_utils_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ class ClassMixedWithDSLInstallUtils

attr_accessor :hosts

def metadata
@metadata ||= {}
end

def logger
@logger ||= RSpec::Mocks::Double.new('logger').as_null_object
end
Expand Down Expand Up @@ -355,6 +359,8 @@ def logger
allow( subject ).to receive( :version_is_less ).with('3.0', '3.0').and_return( false )
allow( subject ).to receive( :version_is_less ).with('3.0', '3.99').and_return( true )
allow( subject ).to receive( :version_is_less ).with('3.99', '3.0').and_return( false )
allow( subject ).to receive( :check_puppetdb_status_endpoint ).and_return( nil )
allow( subject ).to receive( :version_is_less ).with('3.0', '2016.1.0').and_return( false )
allow( subject ).to receive( :wait_for_host_in_dashboard ).and_return( true )
allow( subject ).to receive( :puppet_agent ) do |arg|
"puppet agent #{arg}"
Expand Down Expand Up @@ -390,19 +396,19 @@ def logger
expect( subject ).to receive( :stop_agent_on ).with( hosts[1] ).once
expect( subject ).to receive( :stop_agent_on ).with( hosts[2] ).once
expect( subject ).to receive( :stop_agent_on ).with( hosts[3] ).once
#wait for puppetdb to start
expect( subject ).to receive( :sleep_until_puppetdb_started ).with( hosts[0] ).once
#run each puppet agent once
expect( subject ).to receive( :on ).with( hosts[0], /puppet agent -t/, :acceptable_exit_codes => [0,2] ).once
expect( subject ).to receive( :on ).with( hosts[1], /puppet agent -t/, :acceptable_exit_codes => [0,2] ).once
expect( subject ).to receive( :on ).with( hosts[2], /puppet agent -t/, :acceptable_exit_codes => [0,2] ).once
expect( subject ).to receive( :on ).with( hosts[3], /puppet agent -t/, :acceptable_exit_codes => [0,2] ).once
# We wait for puppetdb to restart 3 times; once before the first puppet run, and then during each puppet run
expect( subject ).to receive( :sleep_until_puppetdb_started ).with( hosts[0] ).exactly(3).times
# Each puppet agent runs twice, once for the initial run, and once to configure mcollective
expect( subject ).to receive( :on ).with( hosts[0], /puppet agent -t/, :acceptable_exit_codes => [0,2] ).twice
expect( subject ).to receive( :on ).with( hosts[1], /puppet agent -t/, :acceptable_exit_codes => [0,2] ).twice
expect( subject ).to receive( :on ).with( hosts[2], /puppet agent -t/, :acceptable_exit_codes => [0,2] ).twice
expect( subject ).to receive( :on ).with( hosts[3], /puppet agent -t/, :acceptable_exit_codes => [0,2] ).twice
#run rake task on dashboard

expect( subject ).to receive( :on ).with( hosts[0], /\/opt\/puppet\/bin\/rake -sf \/opt\/puppet\/share\/puppet-dashboard\/Rakefile .* RAILS_ENV=production/ ).once
#wait for all hosts to appear in the dashboard
#run puppet agent now that installation is complete
expect( subject ).to receive( :on ).with( hosts, /puppet agent/, :acceptable_exit_codes => [0,2] ).once
#expect( subject ).to receive( :on ).with( hosts, /puppet agent/, :acceptable_exit_codes => [0,2] ).once

hosts.each do |host|
allow( host ).to receive( :tmpdir )
Expand Down Expand Up @@ -469,6 +475,8 @@ def logger
allow( subject ).to receive( :version_is_less ).with('3.99', '4.0').and_return( true )
# pe_ver is only set on the hosts for this test, not the opt
allow( subject ).to receive( :version_is_less ).with('4.0', '3.99').and_return( true )
allow( subject ).to receive( :version_is_less ).with('4.0', '2016.1.0').and_return( false )
allow( subject ).to receive( :check_puppetdb_status_endpoint ).and_return( nil )
allow( subject ).to receive( :wait_for_host_in_dashboard ).and_return( true )
allow( subject ).to receive( :puppet_agent ) do |arg|
"puppet agent #{arg}"
Expand All @@ -490,12 +498,11 @@ def logger
expect( subject ).to receive( :configure_type_defaults_on ).with( host ).once
expect( subject ).to receive( :sign_certificate_for ).with( host ).once
expect( subject ).to receive( :stop_agent_on ).with( host ).once
expect( subject ).to receive( :on ).with( host, /puppet agent -t/, :acceptable_exit_codes => [0,2] ).once
# Each puppet agent runs twice, once for the initial run, and once to configure mcollective
expect( subject ).to receive( :on ).with( host, /puppet agent -t/, :acceptable_exit_codes => [0,2] ).twice
end
#wait for puppetdb to start
expect( subject ).to receive( :sleep_until_puppetdb_started ).with( hosts[0] ).once#wait for all hosts to appear in the dashboard
#run puppet agent now that installation is complete
expect( subject ).to receive( :on ).with( hosts, /puppet agent/, :acceptable_exit_codes => [0,2] ).once
# We wait for puppetdb to restart 3 times; once before the first puppet run, and then during each puppet run
expect( subject ).to receive( :sleep_until_puppetdb_started ).with( hosts[0] ).exactly(3).times

hosts.each do |host|
allow( host ).to receive( :tmpdir )
Expand Down Expand Up @@ -530,6 +537,8 @@ def logger
allow( subject ).to receive( :version_is_less ).with('3.99', '4.0').and_return( true )
allow( subject ).to receive( :version_is_less ).with('3.8', '4.0').and_return( true )
# pe_ver is only set on the hosts for this test, not the opt
allow( subject ).to receive( :version_is_less ).with('4.0', '2016.1.0').and_return( false )
allow( subject ).to receive( :check_puppetdb_status_endpoint ).and_return( nil )
allow( subject ).to receive( :version_is_less ).with('4.0', '3.99').and_return( true )
allow( subject ).to receive( :wait_for_host_in_dashboard ).and_return( true )
allow( subject ).to receive( :puppet_agent ) do |arg|
Expand All @@ -551,12 +560,11 @@ def logger
expect( subject ).to receive( :configure_type_defaults_on ).with( host ).once
expect( subject ).to receive( :sign_certificate_for ).with( host ).once
expect( subject ).to receive( :stop_agent_on ).with( host ).once
expect( subject ).to receive( :on ).with( host, /puppet agent -t/, :acceptable_exit_codes => [0,2] ).once
# Each puppet agent runs twice, once for the initial run, and once to configure mcollective
expect( subject ).to receive( :on ).with( host, /puppet agent -t/, :acceptable_exit_codes => [0,2] ).twice
end
#wait for puppetdb to start
expect( subject ).to receive( :sleep_until_puppetdb_started ).with( hosts[0] ).once#wait for all hosts to appear in the dashboard
#run puppet agent now that installation is complete
expect( subject ).to receive( :on ).with( hosts, /puppet agent/, :acceptable_exit_codes => [0,2] ).once
# We wait for puppetdb to restart 3 times; once before the first puppet run, and then during each puppet run
expect( subject ).to receive( :sleep_until_puppetdb_started ).with( hosts[0] ).exactly(3).times

hosts.each do |host|
allow( host ).to receive( :tmpdir )
Expand Down Expand Up @@ -590,6 +598,8 @@ def logger
allow( subject ).to receive( :version_is_less ).with('3.8', '4.0').and_return( true )
# pe_ver is only set on the hosts for this test, not the opt
allow( subject ).to receive( :version_is_less ).with('4.0', '3.99').and_return( true )
allow( subject ).to receive( :version_is_less ).with('4.0', '2016.1.0').and_return( false )
allow( subject ).to receive( :check_puppetdb_status_endpoint ).and_return( nil )
allow( subject ).to receive( :wait_for_host_in_dashboard ).and_return( true )
allow( subject ).to receive( :puppet_agent ) do |arg|
"puppet agent #{arg}"
Expand All @@ -610,12 +620,13 @@ def logger
allow( subject ).to receive( :add_pe_defaults_on ).with( host ) unless subject.aio_version?(host)
allow( subject ).to receive( :sign_certificate_for ).with( host )
allow( subject ).to receive( :stop_agent_on ).with( host )
# Each puppet agent runs twice, once for the initial run, and once to configure mcollective
allow( subject ).to receive( :on ).with( host, /puppet agent -t/, :acceptable_exit_codes => [0,2] )
end
#wait for puppetdb to start
allow( subject ).to receive( :sleep_until_puppetdb_started ).with( hosts[0] ) #wait for all hosts to appear in the dashboard
# We wait for puppetdb to restart 3 times; once before the first puppet run, and then during each puppet run
allow( subject ).to receive( :sleep_until_puppetdb_started ).with( hosts[0] ).exactly(3).times
#run puppet agent now that installation is complete
allow( subject ).to receive( :on ).with( hosts, /puppet agent/, :acceptable_exit_codes => [0,2] )
allow( subject ).to receive( :on ).with( hosts, /puppet agent/, :acceptable_exit_codes => [0,2] ).twice

opts[:type] = :upgrade
expect( subject ).to receive( :setup_defaults_and_config_helper_on ).with( hosts[1], hosts[0], [0, 1, 2] )
Expand Down

0 comments on commit b602661

Please sign in to comment.