Skip to content

Commit

Permalink
Merge pull request #3 from nicklewis/APPMGMT-881-orchestrator-answers
Browse files Browse the repository at this point in the history
(APPMGMT-882) Add orchestrator answers for 2015.3
  • Loading branch information
kevpl committed Aug 31, 2015
2 parents ef47972 + a0e09a3 commit 40b8bed
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/beaker-answers/answers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ class Answers
:q_database_root_password => '=ZYdjiP3jCwV5eo9s1MBd',
:q_database_root_user => 'pe-postgres',
:q_database_export_dir => '/tmp',
:q_orchestrator_database_name => 'pe-orchestrator',
:q_orchestrator_database_user => 'Orc3Str8R',
:q_orchestrator_database_password => '~!@#$%^*-/ aZ',
:q_puppetdb_database_name => 'pe-puppetdb',
:q_puppetdb_database_user => 'mYpdBu3r',
:q_database_port => 5432,
Expand Down
32 changes: 32 additions & 0 deletions lib/beaker-answers/versions/version20153.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require 'beaker-answers/versions/version40'

module BeakerAnswers
# This class provides answer file information for PE version 2015.3
#
# @api private
class Version20153 < Version40
# The version of PE that this set of answers is appropriate for
def self.pe_version_matcher
/\A2015\.3/
end

def generate_answers
the_answers = super

return the_answers if @options[:masterless]

master = only_host_with_role(@hosts, 'master')
database = only_host_with_role(@hosts, 'database')

orchestrator_db = {
:q_orchestrator_database_name => answer_for(@options, :q_orchestrator_database_name),
:q_orchestrator_database_user => answer_for(@options, :q_orchestrator_database_user),
:q_orchestrator_database_password => answer_for(@options, :q_orchestrator_database_password),
}
the_answers[master.name].merge!(orchestrator_db)
the_answers[database.name].merge!(orchestrator_db)

the_answers
end
end
end
2 changes: 1 addition & 1 deletion lib/beaker-answers/versions/version40.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Version40 < Version38

# The version of PE that this set of answers is appropriate for
def self.pe_version_matcher
/(\A3\.99)|(\A4\.0)|(\A2015)/
/(\A3\.99)|(\A4\.0)|(\A2015\.[012])/
end

def generate_answers
Expand Down
33 changes: 33 additions & 0 deletions spec/beaker-answers/beaker-answers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
end
end

it 'generates 2015.3 answers for 2015.3 hosts' do
@ver = '2015.3.0'
expect( answers ).to be_a_kind_of BeakerAnswers::Version20153
end

it 'generates 4.0 answers for 2015 hosts' do
@ver = '2015.1.2'
expect( answers ).to be_a_kind_of BeakerAnswers::Version40
Expand Down Expand Up @@ -314,6 +319,34 @@
end
end

describe BeakerAnswers::Version20153 do
let( :options ) { StringifyHash.new }
let( :basic_hosts ) { make_hosts( {'pe_ver' => @ver } ) }
let( :hosts ) { basic_hosts[0]['roles'] = ['master', 'agent']
basic_hosts[1]['roles'] = ['dashboard', 'agent']
basic_hosts[2]['roles'] = ['database', 'agent']
basic_hosts }
let( :answers ) { BeakerAnswers::Answers.create(@ver, hosts, options) }
let( :upgrade_answers ) { BeakerAnswers::Answers.create(@ver, hosts, options.merge( {:type => :upgrade}) ) }

before :each do
@ver = '2015.3'
@answers = answers.answers
end

it 'should add orchestrator database answers to master' do
expect( @answers['vm1'][:q_orchestrator_database_name] ).to be === 'pe-orchestrator'
expect( @answers['vm1'][:q_orchestrator_database_user] ).to be === 'Orc3Str8R'
expect( @answers['vm1'][:q_orchestrator_database_password] ).to be === '~!@#$%^*-/ aZ'
end

it 'should add orchestrator database answers to database' do
expect( @answers['vm3'][:q_orchestrator_database_name] ).to be === 'pe-orchestrator'
expect( @answers['vm3'][:q_orchestrator_database_user] ).to be === 'Orc3Str8R'
expect( @answers['vm3'][:q_orchestrator_database_password] ).to be === '~!@#$%^*-/ aZ'
end
end

describe BeakerAnswers::Version32 do
let( :options ) { StringifyHash.new }
let( :basic_hosts ) { make_hosts( {'pe_ver' => @ver } ) }
Expand Down

0 comments on commit 40b8bed

Please sign in to comment.