spec/beaker-answers/versions/version20162_spec.rb in beaker-answers-0.5.1 vs spec/beaker-answers/versions/version20162_spec.rb in beaker-answers-0.5.2
- old
+ new
@@ -1,45 +1,12 @@
require 'spec_helper'
require 'json'
-describe BeakerAnswers::Version20162 do
- let( :ver ) { '2016.2.0' }
- 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( :answer_hash ) { answers.answers }
-
- it 'adds orchestrator database answers to console' do
- expect( answer_hash['vm2'][:q_orchestrator_database_name] ).to be === 'pe-orchestrator'
- expect( answer_hash['vm2'][:q_orchestrator_database_user] ).to be === 'Orc3Str8R'
- end
-
- it 'generates valid answers if #answer_string is called' do
- expect( answers.answer_string(basic_hosts[2]) ).to match(/q_orchestrator_database_name=pe-orchestrator/)
- end
-
- context 'when generating a hiera config' do
+RSpec.shared_examples 'pe.conf' do
let( :options ) { { :format => 'hiera' } }
let( :answer_hiera ) { answers.answer_hiera }
let( :default_password ) { '~!@#$%^*-/ aZ' }
- let( :gold_role_answers ) do
- {
- "console_admin_password" => default_password,
- "puppet_enterprise::use_application_services" => true,
- "puppet_enterprise::certificate_authority_host" => basic_hosts[0].hostname,
- "puppet_enterprise::puppet_master_host" => basic_hosts[0].hostname,
- "puppet_enterprise::console_host" => basic_hosts[1].hostname,
- "puppet_enterprise::puppetdb_host" => basic_hosts[2].hostname,
- "puppet_enterprise::database_host" => basic_hosts[2].hostname,
- "puppet_enterprise::pcp_broker_host" => basic_hosts[0].hostname,
- "puppet_enterprise::mcollective_middleware_hosts" => [basic_hosts[0].hostname],
- }
- end
let( :gold_db_answers ) do
{
"puppet_enterprise::activity_database_user" => 'adsfglkj',
"puppet_enterprise::classifier_database_user" => 'DFGhjlkj',
"puppet_enterprise::orchestrator_database_user" => 'Orc3Str8R',
@@ -75,10 +42,18 @@
"puppet_enterprise::orchestrator_database_password" => 'custom-orchestrator-password',
"puppet_enterprise::puppetdb_database_password" => 'custom-puppetdb-password',
"puppet_enterprise::rbac_database_password" => 'custom-rbac-password',
}
end
+ let( :overridding_parameters ) do
+ {
+ 'puppet_enterprise::certificate_authority_host' => 'enterpriseca.vm',
+ 'puppet_enterprise::console_host' => 'enterpriseconsole.vm',
+ 'console_admin_password' => 'testing123',
+ }
+ end
+ let( :gold_answers_with_overrides ) { gold_role_answers.merge(overridding_parameters) }
it 'should not have nil keys or values' do
answer_hash.each_pair { |k, v|
expect([k, v]).not_to include(nil)
}
@@ -175,25 +150,13 @@
'console_admin_password' => 'testing123',
}
}
end
- it 'overrides the defaults when multi-level hash :answers are given' do
- expect(answer_hash["puppet_enterprise::certificate_authority_host"]).to be === 'enterpriseca.vm'
+ it 'matches expected answers' do
+ expect(answer_hash).to eq(gold_answers_with_overrides)
end
-
- it 'overrides the defaults when a :: delimited key is given' do
- expect(answer_hash["puppet_enterprise::console_host"]).to be === 'enterpriseconsole.vm'
- end
-
- it 'overrides the console_admin_password default' do
- expect(answer_hash["console_admin_password"]).to be === 'testing123'
- end
-
- it 'does not add a duplicate key to the hash' do
- expect(answer_hash.length).to eq(gold_role_answers.length)
- end
end
context 'when overriding answers using symbolic keys' do
let( :options ) do
{
@@ -206,25 +169,64 @@
:console_admin_password => 'testing123',
}
}
end
- it 'overrides the defaults when multi-level hash :answers are given' do
- expect(answer_hash["puppet_enterprise::certificate_authority_host"]).to be === 'enterpriseca.vm'
+ it 'matches expected answers' do
+ expect(answer_hash).to eq(gold_answers_with_overrides)
end
+ end
+end
- it 'overrides the defaults when a :: delimited key is given' do
- expect(answer_hash["puppet_enterprise::console_host"]).to be === 'enterpriseconsole.vm'
- end
+describe BeakerAnswers::Version20162 do
+ let( :ver ) { '2016.2.0' }
+ 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( :answer_hash ) { answers.answers }
- it 'overrides the console_admin_password default' do
- expect(answer_hash["console_admin_password"]).to be === 'testing123'
+ it 'adds orchestrator database answers to console' do
+ expect( answer_hash['vm2'][:q_orchestrator_database_name] ).to be === 'pe-orchestrator'
+ expect( answer_hash['vm2'][:q_orchestrator_database_user] ).to be === 'Orc3Str8R'
+ end
+
+ it 'generates valid answers if #answer_string is called' do
+ expect( answers.answer_string(basic_hosts[2]) ).to match(/q_orchestrator_database_name=pe-orchestrator/)
+ end
+
+ context 'when generating a hiera config' do
+ context 'for a monolithic install' do
+ let( :basic_hosts ) { make_hosts( {'pe_ver' => ver }, 1 ) }
+ let( :hosts ) { basic_hosts[0]['roles'] = ['master', 'agent', 'dashboard', 'database']
+ basic_hosts }
+ let( :gold_role_answers ) do
+ {
+ "console_admin_password" => default_password,
+ "puppet_enterprise::use_application_services" => true,
+ "puppet_enterprise::puppet_master_host" => basic_hosts[0].hostname,
+ }
end
- it 'does not add duplicate keys to the hash' do
- expect(answer_hash.length).to eq(gold_role_answers.length)
+ include_examples 'pe.conf'
+ end
+
+ context 'for a split install' do
+ let( :gold_role_answers ) do
+ {
+ "console_admin_password" => default_password,
+ "puppet_enterprise::use_application_services" => true,
+ "puppet_enterprise::puppet_master_host" => basic_hosts[0].hostname,
+ "puppet_enterprise::console_host" => basic_hosts[1].hostname,
+ "puppet_enterprise::puppetdb_host" => basic_hosts[2].hostname,
+ }
end
+
+ include_examples 'pe.conf'
end
end
# This spec is just providing a baseline for :bash answer generation/regression.
# This and bash answer generation in 2016.2.0+ should be dropped once we've cutover.
@@ -360,7 +362,6 @@
:q_orchestrator_database_user=>"Orc3Str8R",
:q_orchestrator_database_password=>"'~!@\#$%^*-/ aZ'"
},
})
end
-
end