puppet-openstacklib/spec/defines/openstacklib_db_postgresql_spec.rb
Takashi Kajinami aff3a53d49 Revert "CentOS 9: Disable unit tests dependent on puppet-postgresql"
This reverts commit 83f966a850.

Reason for revert:
puppet-postgresql 8.1.0 was released and now the module supports RHEL 9
(and CentOS 9 effectively).

Note:
This change adds the service_provider fact in test fact data because
it is required by puppet-postgresql.

Depends-on: https://review.opendev.org/850705
Change-Id: I2845d25c5f2de57e104d09284f0c5aedcd5d0362
2022-07-24 00:54:42 +09:00

102 lines
2.5 KiB
Ruby

require 'spec_helper'
describe 'openstacklib::db::postgresql' do
let (:title) { 'nova' }
let :required_params do
{
:password => 'pw'
}
end
let (:pre_condition) do
"include postgresql::server"
end
shared_examples 'openstacklib::db::postgresql examples' do
context 'with only required parameters' do
let :params do
required_params
end
it { should contain_postgresql__server__db(title).with(
:user => title,
:password => 'md557ae0608fad632bf0155cb9502a6b454'
)}
end
context 'when overriding encoding' do
let :params do
required_params.merge!( :encoding => 'latin1' )
end
it { should contain_postgresql__server__db(title).with_encoding(params[:encoding]) }
end
context 'when omitting the required parameter password_hash' do
let :params do
{}
end
it { should raise_error(Puppet::Error) }
end
context 'when notifying other resources' do
let :pre_condition do
"include postgresql::server
exec { 'nova-db-sync': }"
end
let :params do
required_params.merge!( :notify => 'Exec[nova-db-sync]' )
end
it { should contain_exec('nova-db-sync').that_subscribes_to("Openstacklib::Db::Postgresql[#{title}]") }
end
context 'when required for other openstack services' do
let :pre_condition do
"include postgresql::server
service {'keystone':}"
end
let :title do
'keystone'
end
let :params do
required_params.merge!( :before => 'Service[keystone]' )
end
it { should contain_service('keystone').that_requires("Openstacklib::Db::Postgresql[keystone]") }
end
context 'when deprecated password_hash is used' do
let :params do
{ :password_hash => 'md557ae0608fad632bf0155cb9502a6b454' }
end
it { should contain_postgresql__server__db(title).with(
:user => title,
:password => 'md557ae0608fad632bf0155cb9502a6b454'
)}
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts({
# puppet-postgresql requires the service_provider fact provided by
# puppetlabs-postgresql.
:service_provider => 'systemd'
}))
end
it_behaves_like 'openstacklib::db::postgresql examples'
end
end
end