oslo db: check puppet resource instead of actual config in spec

Change-Id: I4a0a8cb9e4b9e64091ea6a2d09f9e999720735ca
This commit is contained in:
ZhongShengping 2017-04-11 14:31:09 +08:00
parent a105fbaaf6
commit 3705c795af

View File

@ -6,14 +6,15 @@ describe 'trove::db' do
context 'with default parameters' do context 'with default parameters' do
it { is_expected.to contain_trove_config('database/connection').with_value('sqlite:////var/lib/trove/trove.sqlite').with_secret(true) } it { is_expected.to contain_oslo__db('trove_config').with(
it { is_expected.to contain_trove_config('database/idle_timeout').with_value('<SERVICE DEFAULT>') } :connection => 'sqlite:////var/lib/trove/trove.sqlite',
it { is_expected.to contain_trove_config('database/min_pool_size').with_value('<SERVICE DEFAULT>') } :idle_timeout => '<SERVICE DEFAULT>',
it { is_expected.to contain_trove_config('database/max_pool_size').with_value('<SERVICE DEFAULT>') } :min_pool_size => '<SERVICE DEFAULT>',
it { is_expected.to contain_trove_config('database/max_overflow').with_value('<SERVICE DEFAULT>') } :max_pool_size => '<SERVICE DEFAULT>',
it { is_expected.to contain_trove_config('database/max_retries').with_value('<SERVICE DEFAULT>') } :max_retries => '<SERVICE DEFAULT>',
it { is_expected.to contain_trove_config('database/retry_interval').with_value('<SERVICE DEFAULT>') } :retry_interval => '<SERVICE DEFAULT>',
:max_overflow => '<SERVICE DEFAULT>',
)}
end end
context 'with specific parameters' do context 'with specific parameters' do
@ -27,18 +28,20 @@ describe 'trove::db' do
:database_retry_interval => '11', } :database_retry_interval => '11', }
end end
it { is_expected.to contain_trove_config('database/connection').with_value('mysql+pymysql://trove:trove@localhost/trove').with_secret(true) } it { is_expected.to contain_oslo__db('trove_config').with(
it { is_expected.to contain_trove_config('database/idle_timeout').with_value('3601') } :connection => 'mysql+pymysql://trove:trove@localhost/trove',
it { is_expected.to contain_trove_config('database/min_pool_size').with_value('2') } :idle_timeout => '3601',
it { is_expected.to contain_trove_config('database/max_retries').with_value('11') } :min_pool_size => '2',
it { is_expected.to contain_trove_config('database/max_pool_size').with_value('21') } :max_pool_size => '21',
it { is_expected.to contain_trove_config('database/max_overflow').with_value('21') } :max_retries => '11',
it { is_expected.to contain_trove_config('database/retry_interval').with_value('11') } :retry_interval => '11',
:max_overflow => '21',
)}
end end
context 'with MySQL-python library as backend package' do context 'with MySQL-python library as backend package' do
let :params do let :params do
{ :database_connection => 'mysql://trove:trove@localhost/trove', } { :database_connection => 'mysql://trove:trove@localhost/trove', }
end end
it { is_expected.to contain_package('python-mysqldb').with(:ensure => 'present') } it { is_expected.to contain_package('python-mysqldb').with(:ensure => 'present') }
@ -46,7 +49,7 @@ describe 'trove::db' do
context 'with postgresql backend' do context 'with postgresql backend' do
let :params do let :params do
{ :database_connection => 'postgresql://trove:trove@localhost/trove', } { :database_connection => 'postgresql://trove:trove@localhost/trove', }
end end
it 'install the proper backend package' do it 'install the proper backend package' do
@ -57,7 +60,7 @@ describe 'trove::db' do
context 'with incorrect database_connection string' do context 'with incorrect database_connection string' do
let :params do let :params do
{ :database_connection => 'redis://trove:trove@localhost/trove', } { :database_connection => 'redis://trove:trove@localhost/trove', }
end end
it_raises 'a Puppet::Error', /validate_re/ it_raises 'a Puppet::Error', /validate_re/
@ -65,7 +68,7 @@ describe 'trove::db' do
context 'with incorrect pymysql database_connection string' do context 'with incorrect pymysql database_connection string' do
let :params do let :params do
{ :database_connection => 'foo+pymysql://trove:trove@localhost/trove', } { :database_connection => 'foo+pymysql://trove:trove@localhost/trove', }
end end
it_raises 'a Puppet::Error', /validate_re/ it_raises 'a Puppet::Error', /validate_re/
@ -76,7 +79,7 @@ describe 'trove::db' do
shared_examples_for 'trove::db on Debian platforms' do shared_examples_for 'trove::db on Debian platforms' do
context 'using pymysql driver' do context 'using pymysql driver' do
let :params do let :params do
{ :database_connection => 'mysql+pymysql://trove:trove@localhost/trove', } { :database_connection => 'mysql+pymysql://trove:trove@localhost/trove', }
end end
it 'install the proper backend package' do it 'install the proper backend package' do
@ -92,7 +95,7 @@ describe 'trove::db' do
shared_examples_for 'trove::db on RedHat platforms' do shared_examples_for 'trove::db on RedHat platforms' do
context 'using pymysql driver' do context 'using pymysql driver' do
let :params do let :params do
{ :database_connection => 'mysql+pymysql://trove:trove@localhost/trove', } { :database_connection => 'mysql+pymysql://trove:trove@localhost/trove', }
end end
it { is_expected.not_to contain_package('db_backend_package') } it { is_expected.not_to contain_package('db_backend_package') }
@ -100,7 +103,7 @@ describe 'trove::db' do
end end
on_supported_os({ on_supported_os({
:supported_os => OSDefaults.get_supported_os :supported_os => OSDefaults.get_supported_os
}).each do |os,facts| }).each do |os,facts|
context "on #{os}" do context "on #{os}" do
let (:facts) do let (:facts) do