Skip to content

Commit

Permalink
(PE-14271) Prepare host installer options based on version/env
Browse files Browse the repository at this point in the history
The addition of a use_meep? query allows setting host options for either
legacy or meep installer.  This enables installer_cmd to invoke the
correct installer.
  • Loading branch information
jpartlow committed May 26, 2016
1 parent 7ea8fbc commit 616612a
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 4 deletions.
29 changes: 25 additions & 4 deletions lib/beaker-pe/install/pe_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ module PEUtils
include PuppetUtils
include WindowsUtils

# Version of PE when we switched from legacy installer to MEEP.
MEEP_CUTOVER_VERSION = '2016.2.0'

# @!macro [new] common_opts
# @param [Hash{Symbol=>String}] opts Options to alter execution.
# @option opts [Boolean] :silent (false) Do not produce log output
Expand Down Expand Up @@ -497,6 +500,17 @@ def do_install hosts, opts = {}
end
end

# True if version is greater than or equal to 2016.2.0 and the
# INSTALLER_TYPE environment variable is 'meep'.
#
# This will be switched to be true if >= 2016.2.0 and INSTALLER_TYPE !=
# 'legacy' once meep is default.
#
# And then to just >= 2016.2.0 for cutover.
def use_meep?(version)
!version_is_less(version, MEEP_CUTOVER_VERSION) && ENV['INSTALLER_TYPE'] == 'meep'
end

# Set installer options on the passed *host* according to current
# version and external INSTALLER_TYPE setting.
#
Expand All @@ -508,10 +522,17 @@ def do_install hosts, opts = {}
# @param [Beaker::Host] host The host object to configure
# @return [Beaker::Host] The same host object passed in
def prepare_host_installer_options(host)
conf_file = "#{host['working_dir']}/answers"
host['pe_installer_conf_file'] = conf_file
host['pe_installer_conf_setting'] = "-a #{conf_file}"
host['pe_installer_type'] = 'legacy'
if use_meep?(host['pe_ver'])
conf_file = "#{host['working_dir']}/pe.conf"
host['pe_installer_conf_file'] = conf_file
host['pe_installer_conf_setting'] = "-c #{conf_file}"
host['pe_installer_type'] = 'meep'
else
conf_file = "#{host['working_dir']}/answers"
host['pe_installer_conf_file'] = conf_file
host['pe_installer_conf_setting'] = "-a #{conf_file}"
host['pe_installer_type'] = 'legacy'
end
host
end

Expand Down
73 changes: 73 additions & 0 deletions spec/beaker-pe/install/pe_utils_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,79 @@ def logger

end

describe 'prepare_host_installer_options' do
let(:legacy_settings) do
{
:pe_installer_conf_file => '/tmp/answers',
:pe_installer_conf_setting => '-a /tmp/answers',
:pe_installer_type => 'legacy',
}
end
let(:meep_settings) do
{
:pe_installer_conf_file => '/tmp/pe.conf',
:pe_installer_conf_setting => '-c /tmp/pe.conf',
:pe_installer_type => 'meep',
}
end
let(:installer_type) { nil }
let(:host) { unixhost }

before(:each) do
ENV['INSTALLER_TYPE'] = installer_type
host['pe_ver'] = pe_ver
subject.prepare_host_installer_options(host)
end

after(:each) do
ENV.delete('INSTALLER_TYPE')
end

def slice_installer_options(host)
host.select { |k,v| [ :pe_installer_conf_file, :pe_installer_conf_setting, :pe_installer_type].include?(k) }
end

context 'when version < 2016.2.0' do
let(:pe_ver) { '3.8.5' }

it 'sets legacy settings' do
expect(slice_installer_options(host)).to eq(legacy_settings)
end

context 'and ENV["INSTALLER"]=="meep"' do
let(:installer_type) { 'meep' }

it 'still sets legacy settings' do
expect(slice_installer_options(host)).to eq(legacy_settings)
end
end
end

context 'when version >= 2016.2.0' do
let (:pe_ver) { '2016.2.0' }

context 'and ENV["INSTALLER_TYPE"]=="legacy"' do
let(:installer_type) { 'legacy' }

it 'sets legacy settings' do
expect(slice_installer_options(host)).to eq(legacy_settings)
end
end

context 'and ENV["INSTALLER_TYPE"]=="meep"' do
let(:installer_type) { 'meep' }

it 'sets meep settings' do
expect(slice_installer_options(host)).to eq(meep_settings)
end
end
end
end

describe 'generate_installer_conf_file_for' do
it 'generates a legacy answer file if host["pe_installer_type"]=="legacy"'
it 'generates a meep config file if host["pe_installer_type"]=="meep"'
end

describe 'fetch_pe' do

Expand Down

0 comments on commit 616612a

Please sign in to comment.