Skip to content

Commit

Permalink
(PE-14555) Always use MEEP for >= 2016.2.0
Browse files Browse the repository at this point in the history
Prior to this commit pe-beaker would use `INSTALLER_TYPE` to
specify whether to run a MEEP (new) or legacy install.
This commit changes pe-beaker to always use MEEP if the PE
version being installed is >= 2016.2.0, and legacy otherwise.

No ENV parameters will be passed to specify which to use, as we
are now relying on the installer itself to default to using MEEP
by default in all 2016.2.0 builds going forward.
  • Loading branch information
Brandon High committed Jun 9, 2016
1 parent f5ad188 commit de3a505
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 87 deletions.
24 changes: 7 additions & 17 deletions lib/beaker-pe/install/pe_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -511,24 +511,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.
# True if version is greater than or equal to MEEP_CUTOVER_VERSION (2016.2.0)
def use_meep?(version)
!version_is_less(version, MEEP_CUTOVER_VERSION) && ENV['INSTALLER_TYPE'] != 'legacy'
!version_is_less(version, MEEP_CUTOVER_VERSION)
end

# Set installer options on the passed *host* according to current
# version and external INSTALLER_TYPE setting.
# version.
#
# Sets:
# * 'pe_installer_conf_file'
# * 'pe_installer_conf_setting'
# * 'pe_installer_type'
#
# @param [Beaker::Host] host The host object to configure
# @return [Beaker::Host] The same host object passed in
Expand All @@ -537,12 +530,10 @@ def prepare_host_installer_options(host)
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 All @@ -559,7 +550,7 @@ def prepare_host_installer_options(host)
# @param [Hash] opts The Beaker options hash
# @return [Hash] a dup of the opts hash with additional settings for BeakerAnswers
def setup_beaker_answers_opts(host, opts)
beaker_answers_opts = host['pe_installer_type'] == 'meep' ?
beaker_answers_opts = use_meep?(host['pe_ver']) ?
{ :format => :hiera } :
{ :format => :bash }

Expand All @@ -574,9 +565,8 @@ def setup_beaker_answers_opts(host, opts)
# installation.
#
# Expects the host['pe_installer_conf_file'] to have been set, which is
# where the configuration will be written to, and expects
# host['pe_installer_type'] to have been set to either 'legacy' or
# 'meep'.
# where the configuration will be written to, and will run MEEP or legacy
# depending on host[:pe_ver]
#
# @param [Beaker::Host] host The host to create a configuration file on
# @param [Array<Beaker::Host]> hosts All of the hosts to be configured
Expand Down Expand Up @@ -776,7 +766,7 @@ def prep_host_for_upgrade(host, opts={}, path='')
# The host object must have the 'working_dir', 'dist' and 'pe_installer' field set correctly.
# @api private
def higgs_installer_cmd host
higgs_answer = host['pe_installer_type'] == 'meep' ? '1' : 'Y'
higgs_answer = use_meep?(host['pe_ver']) ? '1' : 'Y'
"cd #{host['working_dir']}/#{host['dist']} ; nohup ./#{host['pe_installer']} <<<#{higgs_answer} > #{host['higgs_file']} 2>&1 &"
end

Expand Down
81 changes: 11 additions & 70 deletions spec/beaker-pe/install/pe_utils_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -292,14 +292,9 @@ def prep_host(host)
let(:higgs_answer) { '1' }

before(:each) do
ENV['INSTALLER_TYPE'] = 'meep'
host['pe_ver'] = '2016.2.0'
end

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

context 'the higgs_installer_cmd' do
it 'submits correct command to invoke Higgs' do
subject.prepare_host_installer_options(host)
Expand All @@ -321,31 +316,23 @@ def prep_host(host)
{
: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) }
host.select { |k,v| [ :pe_installer_conf_file, :pe_installer_conf_setting].include?(k) }
end

context 'when version < 2016.2.0' do
Expand All @@ -354,67 +341,29 @@ def slice_installer_options(host)
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

it 'test use_meep?' do
expect(subject.use_meep?('3.8.5')).to eq(false)
expect(subject.use_meep?('2016.1.2')).to eq(false)
expect(subject.use_meep?('2016.2.0')).to eq(false)
expect(subject.use_meep?('2016.2.0-rc1-gabcdef')).to eq(false)
end
it 'test use_meep?' do
expect(subject.use_meep?('3.8.5')).to eq(false)
expect(subject.use_meep?('2016.1.2')).to eq(false)
expect(subject.use_meep?('2016.2.0')).to eq(true)
expect(subject.use_meep?('2016.2.0-rc1-gabcdef')).to eq(true)
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

context 'and ENV["INSTALLER_TYPE"] is not set' do
before(:each) do
ENV.delete('INSTALLER_TYPE')
end

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

it 'test use_meep?' do
expect(subject.use_meep?('3.8.5')).to eq(false)
expect(subject.use_meep?('2016.1.2')).to eq(false)
expect(subject.use_meep?('2016.2.0')).to eq(true)
expect(subject.use_meep?('2016.2.0-rc1-gabcdef')).to eq(true)
end
it 'sets meep settings' do
expect(slice_installer_options(host)).to eq(meep_settings)
end
end
end

describe 'generate_installer_conf_file_for' do
let(:master) { hosts.first }

it 'generates a legacy answer file if host["pe_installer_type"]=="legacy"' do
it 'generates a legacy answer file if < 2016.2.0' do
master['pe_installer_conf_file'] = '/tmp/answers'
master['pe_installer_type'] = 'legacy'
expect(subject).to receive(:create_remote_file).with(
master,
'/tmp/answers',
Expand All @@ -423,9 +372,8 @@ def slice_installer_options(host)
subject.generate_installer_conf_file_for(master, hosts, opts)
end

it 'generates a meep config file if host["pe_installer_type"]=="meep"' do
it 'generates a meep config file if >= 2016.2.0' do
master['pe_installer_conf_file'] = '/tmp/pe.conf'
master['pe_installer_type'] = 'meep'
master['pe_ver'] = '2016.2.0'
expect(subject).to receive(:create_remote_file).with(
master,
Expand All @@ -442,7 +390,6 @@ def slice_installer_options(host)

context 'for legacy installer' do
it 'adds option for bash format' do
host['pe_installer_type'] = 'legacy'
expect(subject.setup_beaker_answers_opts(host, opts)).to eq(
opts.merge(
:format => :bash,
Expand All @@ -454,13 +401,7 @@ def slice_installer_options(host)

context 'for meep installer' do
before(:each) do
ENV['INSTALLER_TYPE'] = 'meep'
host['pe_ver'] = '2016.2.0'
host['pe_installer_type'] = 'meep'
end

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

it 'adds option for hiera format' do
Expand Down Expand Up @@ -886,7 +827,7 @@ def slice_installer_options(host)
allow( subject ).to receive( :on ).with( host, /puppet agent -t/, :acceptable_exit_codes => [0,2] )
end
# 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
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] ).twice

Expand Down

0 comments on commit de3a505

Please sign in to comment.