Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 34 additions & 5 deletions lib/beaker-pe/install/pe_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,35 @@ def fetch_pe_on_mac(host, opts)
end
end

# Helper method to get common variables for agent package installation
# @param [String] puppet_agent_ver The puppet agent version
# @param [Hash{Symbol=>Symbol, String}] opts The options
# @return [Hash] Hash containing agent_downloads_url, master_aio_version, and stream
# @api private
def agent_package_common_vars(puppet_agent_ver, opts)
{
agent_downloads_url: "http://agent-downloads.delivery.puppetlabs.net/puppet-agent",
master_aio_version: puppet_fact(master, 'aio_agent_build'),
stream: opts[:puppet_collection] || "puppet#{puppet_agent_ver[0]}"
}
end

# Determine the build package to download on a solaris-10-sparc host, install that package onto the host.
# Assumed file name format: puppet-agent-8.15.0-1.sparc.pkg.gz
# This method should be called after puppet is installed on the master since it relies on the master
# telling it the puppet agent version to form the download URL.
# @param [Host] host The sol10-sparc host to download and install the package on.
# @param [Hash{Symbol=>Symbol, String}] opts The options
# @api private
def install_pkg_on_sol10_sparc_host(host, puppet_agent_ver, opts)
# Since sol10-sparc builds are not available in PE, download from agent-downloads.
vars = agent_package_common_vars(puppet_agent_ver, opts)
path = "#{vars[:agent_downloads_url]}/#{puppet_agent_ver}/repos/solaris/10/#{vars[:stream]}"
filename = "puppet-agent-#{vars[:master_aio_version]}-1.sparc"
extension = ".pkg.gz"
host.install_package("#{path}/#{filename}#{extension}")
end

# Determine the build package to download on a sles-11 (Intel) host, install that package onto the host.
# Assumed file name format: puppet-agent-7.29.1.26.gf344eeefa-1.sles11.x86_64.rpm.
# This method should be called after puppet is installed on the master since it relies on the master
Expand All @@ -334,11 +363,9 @@ def fetch_pe_on_mac(host, opts)
# @api private
def install_rpm_on_sles11_host(host, puppet_agent_ver, opts)
# Since sles11 builds are not available in PE, download from agent-downloads.
agent_downloads_url = "http://agent-downloads.delivery.puppetlabs.net/puppet-agent"
master_aio_version = puppet_fact(master, 'aio_agent_build')
stream = opts[:puppet_collection] || "puppet#{puppet_agent_ver[0]}"
path = "#{agent_downloads_url}/#{puppet_agent_ver}/repos/sles/11/#{stream}/x86_64"
filename = "puppet-agent-#{master_aio_version}-1.sles11.x86_64"
vars = agent_package_common_vars(puppet_agent_ver, opts)
path = "#{vars[:agent_downloads_url]}/#{puppet_agent_ver}/repos/sles/11/#{vars[:stream]}/x86_64"
filename = "puppet-agent-#{vars[:master_aio_version]}-1.sles11.x86_64"
extension = ".rpm"
host.install_package_with_rpm("#{path}/#{filename}#{extension}")
end
Expand Down Expand Up @@ -1174,6 +1201,8 @@ def generic_install hosts, opts = {}
}
if host['platform'] =~ /sles-11/
install_rpm_on_sles11_host(host, install_params[:puppet_agent_version], opts)
elsif host['platform'] =~ /solaris-10-sparc/
install_pkg_on_sol10_sparc_host(host, install_params[:puppet_agent_version], opts)
else
install_params.delete(:pe_promoted_builds_url) if install_params[:pe_promoted_builds_url].nil?
install_puppet_agent_pe_promoted_repo_on(host, install_params)
Expand Down
37 changes: 32 additions & 5 deletions spec/beaker-pe/install/pe_utils_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ def metadata
let(:basic_hosts) { make_hosts( { :pe_ver => '3.0',
:platform => 'linux',
:roles => [ 'agent' ],
:type => 'pe'}, 5 ) }
:type => 'pe'}, 6 ) }
let(:hosts) { basic_hosts[0][:roles] = ['master', 'database', 'dashboard']
basic_hosts[1][:platform] = 'windows'
basic_hosts[2][:platform] = 'osx-10.9-x86_64'
basic_hosts[3][:platform] = 'eos'
basic_hosts[4][:platform] = 'sles'
basic_hosts[5][:platform] = 'solaris'
basic_hosts }
let(:hosts_sorted) { [ hosts[1], hosts[0], hosts[2], hosts[3], hosts[4] ] }
let(:hosts_sorted) { [ hosts[1], hosts[0], hosts[2], hosts[3], hosts[4], hosts[5] ] }
let(:winhost) { make_host( 'winhost', { :platform => 'windows',
:pe_ver => '3.0',
:type => 'pe',
Expand All @@ -60,6 +61,10 @@ def metadata
:pe_ver => '3.0',
:type => 'pe',
:working_dir => '/tmp'} ) }
let(:solaris10host) { make_host( 'sol10', { :platform => 'solaris-10-sparc',
:pe_ver => '3.0',
:type => 'pe',
:working_dir => '/tmp'} ) }
let(:lei_hosts) { make_hosts( { :pe_ver => '3.0',
:platform => 'linux',
:roles => [ 'agent' ],
Expand Down Expand Up @@ -1672,18 +1677,40 @@ def slice_installer_options(host)
let(:filename) { "puppet-agent-#{master_version}-1.sles11.x86_64" }
let(:extension) { '.rpm' }
let(:url) { "#{path}/#{filename}#{extension}" }

it "generates the correct url to download the package" do
allow( subject ).to receive( :puppet_fact ).and_return( master_version )
allow( subject ).to receive( :master ).and_return( {} )

expect( hosts[4] ).to receive( :install_package_with_rpm ).with( url ).once
subject.install_rpm_on_sles11_host(hosts[4], puppet_agent_ver, opts)
end
end

context 'install pkg.gz file in solaris host' do
let(:opts) {
{ :puppet_collection => 'puppet8' }
}
let(:stream) { opts[:puppet_collection] }
let(:puppet_agent_ver) { '8.15.0.65' }
let(:agent_downloads_url) { "http://agent-downloads.delivery.puppetlabs.net/puppet-agent" }
let(:master_version) { '8.15.0.65.gd2a4b575d' }
let(:path) { "#{agent_downloads_url}/#{puppet_agent_ver}/repos/solaris/10/#{stream}" }
let(:filename) { "puppet-agent-#{master_version}-1.sparc" }
let(:extension) { '.pkg.gz' }
let(:url) { "#{path}/#{filename}#{extension}" }

it 'generates the correct url to download the package' do
allow( subject ).to receive( :puppet_fact ).and_return( master_version )
allow( subject ).to receive( :master ).and_return( {} )

expect( hosts[5] ).to receive( :install_package ).with( url ).once
subject.install_pkg_on_sol10_sparc_host(hosts[5], puppet_agent_ver, opts)
end
end

it 'can perform a simple installation' do
expect(subject).to receive(:get_mco_setting).and_return({}).twice
expect(subject).to receive(:get_mco_setting).and_return({}).thrice
allow( subject ).to receive( :verify_network_resources).with(hosts, nil)
allow( subject ).to receive( :on ).and_return( Beaker::Result.new( {}, '' ) )
allow( subject ).to receive( :fetch_pe ).and_return( true )
Expand Down