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

Change-Id: I3ea681bff3ab92956f9d076db1028ec16ba31ea3
This commit is contained in:
ZhongShengping 2017-04-09 12:20:47 +08:00
parent 8ffd763a2b
commit 7930ae7ff7
1 changed files with 26 additions and 22 deletions

View File

@ -4,14 +4,16 @@ describe 'glare::db' do
shared_examples 'glare::db' do
context 'with default parameters' do
it { is_expected.to contain_glare_config('database/connection').with_value('sqlite:////var/lib/glare/glare.sqlite') }
it { is_expected.to contain_glare_config('database/idle_timeout').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_glare_config('database/min_pool_size').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_glare_config('database/db_max_retries').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_glare_config('database/max_retries').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_glare_config('database/retry_interval').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_glare_config('database/max_pool_size').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_glare_config('database/max_overflow').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_oslo__db('glare_config').with(
:db_max_retries => '<SERVICE DEFAULT>',
:connection => 'sqlite:////var/lib/glare/glare.sqlite',
:idle_timeout => '<SERVICE DEFAULT>',
:min_pool_size => '<SERVICE DEFAULT>',
:max_pool_size => '<SERVICE DEFAULT>',
:max_retries => '<SERVICE DEFAULT>',
:retry_interval => '<SERVICE DEFAULT>',
:max_overflow => '<SERVICE DEFAULT>',
)}
end
context 'with specific parameters' do
@ -27,19 +29,21 @@ describe 'glare::db' do
}
end
it { is_expected.to contain_glare_config('database/connection').with_value('mysql+pymysql://glare:glare@localhost/glare') }
it { is_expected.to contain_glare_config('database/idle_timeout').with_value('3601') }
it { is_expected.to contain_glare_config('database/min_pool_size').with_value('2') }
it { is_expected.to contain_glare_config('database/db_max_retries').with_value('-1') }
it { is_expected.to contain_glare_config('database/max_retries').with_value('11') }
it { is_expected.to contain_glare_config('database/retry_interval').with_value('11') }
it { is_expected.to contain_glare_config('database/max_pool_size').with_value('11') }
it { is_expected.to contain_glare_config('database/max_overflow').with_value('21') }
it { is_expected.to contain_oslo__db('glare_config').with(
:db_max_retries => '-1',
:connection => 'mysql+pymysql://glare:glare@localhost/glare',
:idle_timeout => '3601',
:min_pool_size => '2',
:max_pool_size => '11',
:max_retries => '11',
:retry_interval => '11',
:max_overflow => '21',
)}
end
context 'with postgresql backend' do
let :params do
{ :database_connection => 'postgresql://glare:glare@localhost/glare', }
{ :database_connection => 'postgresql://glare:glare@localhost/glare', }
end
it 'install the proper backend package' do
@ -50,7 +54,7 @@ describe 'glare::db' do
context 'with MySQL-python library as backend package' do
let :params do
{ :database_connection => 'mysql://glare:glare@localhost/glare', }
{ :database_connection => 'mysql://glare:glare@localhost/glare', }
end
it { is_expected.to contain_package('python-mysqldb').with(:ensure => 'present') }
@ -58,7 +62,7 @@ describe 'glare::db' do
context 'with incorrect database_connection string' do
let :params do
{ :database_connection => 'foodb://glare:glare@localhost/glare', }
{ :database_connection => 'foodb://glare:glare@localhost/glare', }
end
it_raises 'a Puppet::Error', /validate_re/
@ -66,7 +70,7 @@ describe 'glare::db' do
context 'with incorrect pymysql database_connection string' do
let :params do
{ :database_connection => 'foo+pymysql://glare:glare@localhost/glare', }
{ :database_connection => 'foo+pymysql://glare:glare@localhost/glare', }
end
it_raises 'a Puppet::Error', /validate_re/
@ -77,7 +81,7 @@ describe 'glare::db' do
shared_examples_for 'glare::db on Debian' do
context 'using pymysql driver' do
let :params do
{ :database_connection => 'mysql+pymysql://glare:glare@localhost/glare', }
{ :database_connection => 'mysql+pymysql://glare:glare@localhost/glare', }
end
it 'install the proper backend package' do
@ -93,7 +97,7 @@ describe 'glare::db' do
shared_examples_for 'glare::db on RedHat' do
context 'using pymysql driver' do
let :params do
{ :database_connection => 'mysql+pymysql://glare:glare@localhost/glare', }
{ :database_connection => 'mysql+pymysql://glare:glare@localhost/glare', }
end
it 'install the proper backend package' do