Skip to content

Commit

Permalink
(PE-14271) Adjust higgs commands to provide correct answer
Browse files Browse the repository at this point in the history
...for both legacy and meep installers.  The former prompts to continue
expecting 'Y' and the later prompts with options where '1' is intended
to kick off Higgs.

Also added spec coverage for these methods.
  • Loading branch information
jpartlow committed May 26, 2016
1 parent 6bc392f commit f7cc8d9
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/beaker-pe/install/pe_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -736,9 +736,8 @@ 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

"cd #{host['working_dir']}/#{host['dist']} ; nohup ./#{host['pe_installer']} <<<Y > #{host['higgs_file']} 2>&1 &"

higgs_answer = host['pe_installer_type'] == 'meep' ? '1' : 'Y'
"cd #{host['working_dir']}/#{host['dist']} ; nohup ./#{host['pe_installer']} <<<#{higgs_answer} > #{host['higgs_file']} 2>&1 &"
end

#Perform a Puppet Enterprise Higgs install up until web browser interaction is required, runs on linux hosts only.
Expand Down Expand Up @@ -771,6 +770,8 @@ def do_higgs_install host, opts
fetch_pe([host], opts)

host['higgs_file'] = "higgs_#{File.basename(host['working_dir'])}.log"

prepare_host_installer_options(host)
on host, higgs_installer_cmd(host), opts

#wait for output to host['higgs_file']
Expand Down
62 changes: 62 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,68 @@ def logger

end

describe 'higgs installer' do
let(:host) { unixhost }
let(:higgs_regex) { %r{cd .* ; nohup \./puppet-enterprise-installer <<<#{higgs_answer} .*} }
before(:each) do
host['pe_installer'] = 'puppet-enterprise-installer'
end

def prep_host(host)
allow(subject).to receive(:sleep)
allow(host).to receive(:tmpdir).and_return('/tmp')
allow(subject).to receive(:fetch_pe)
expect(subject).to receive(:on).with(host, higgs_regex, opts).once
result = double(Beaker::Result, :stdout => 'Please go to https://somewhere in your browser to continue installation')
expect(subject).to receive(:on).with(host, %r{cd .* && cat .*}, anything)
.and_return(result)
end

context 'for legacy installer' do
let(:higgs_answer) { 'Y' }

context 'the higgs_installer_cmd' do
it 'returns correct command to invoke Higgs' do
expect(subject.higgs_installer_cmd(host)).to match(higgs_regex)
end
end

context 'the do_higgs_install' do
it 'submits the correct installer cmd to invoke Higgs' do
prep_host(host)
subject.do_higgs_install(host, opts)
end
end
end

context 'for meep installer' do
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)
expect(subject.higgs_installer_cmd(host)).to match(higgs_regex)
end
end

context 'the do_higgs_install' do
it 'submits the correct installer cmd to invoke Higgs' do
prep_host(host)
subject.do_higgs_install(host, opts)
end
end
end
end

describe 'prepare_host_installer_options' do
let(:legacy_settings) do
{
Expand Down

0 comments on commit f7cc8d9

Please sign in to comment.