From 0ddf5b14343ef08ffb17fea787d1a9d78d59715a Mon Sep 17 00:00:00 2001 From: ZhongShengping Date: Tue, 11 Apr 2017 14:37:37 +0800 Subject: [PATCH] oslo db: check puppet resource instead of actual config in spec Change-Id: Icc0bac09e7c43d122d29cae2fa7ceb0435bd10ce --- spec/classes/watcher_db_spec.rb | 50 ++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/spec/classes/watcher_db_spec.rb b/spec/classes/watcher_db_spec.rb index 38a07c0..8a41907 100644 --- a/spec/classes/watcher_db_spec.rb +++ b/spec/classes/watcher_db_spec.rb @@ -4,14 +4,16 @@ describe 'watcher::db' do shared_examples 'watcher::db' do context 'with default parameters' do - it { is_expected.to contain_watcher_config('database/connection').with_value('sqlite:////var/lib/watcher/watcher.sqlite') } - it { is_expected.to contain_watcher_config('database/idle_timeout').with_value('') } - it { is_expected.to contain_watcher_config('database/min_pool_size').with_value('') } - it { is_expected.to contain_watcher_config('database/db_max_retries').with_value('') } - it { is_expected.to contain_watcher_config('database/max_retries').with_value('') } - it { is_expected.to contain_watcher_config('database/retry_interval').with_value('') } - it { is_expected.to contain_watcher_config('database/max_pool_size').with_value('') } - it { is_expected.to contain_watcher_config('database/max_overflow').with_value('') } + it { is_expected.to contain_oslo__db('watcher_config').with( + :db_max_retries => '', + :connection => 'sqlite:////var/lib/watcher/watcher.sqlite', + :idle_timeout => '', + :min_pool_size => '', + :max_pool_size => '', + :max_retries => '', + :retry_interval => '', + :max_overflow => '', + )} end context 'with specific parameters' do @@ -27,19 +29,21 @@ describe 'watcher::db' do } end - it { is_expected.to contain_watcher_config('database/connection').with_value('mysql+pymysql://watcher:watcher@localhost/watcher') } - it { is_expected.to contain_watcher_config('database/idle_timeout').with_value('3601') } - it { is_expected.to contain_watcher_config('database/min_pool_size').with_value('2') } - it { is_expected.to contain_watcher_config('database/db_max_retries').with_value('-1') } - it { is_expected.to contain_watcher_config('database/max_retries').with_value('11') } - it { is_expected.to contain_watcher_config('database/retry_interval').with_value('11') } - it { is_expected.to contain_watcher_config('database/max_pool_size').with_value('11') } - it { is_expected.to contain_watcher_config('database/max_overflow').with_value('21') } + it { is_expected.to contain_oslo__db('watcher_config').with( + :db_max_retries => '-1', + :connection => 'mysql+pymysql://watcher:watcher@localhost/watcher', + :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://watcher:watcher@localhost/watcher', } + { :database_connection => 'postgresql://watcher:watcher@localhost/watcher', } end it 'install the proper backend package' do @@ -50,7 +54,7 @@ describe 'watcher::db' do context 'with MySQL-python library as backend package' do let :params do - { :database_connection => 'mysql://watcher:watcher@localhost/watcher', } + { :database_connection => 'mysql://watcher:watcher@localhost/watcher', } end it { is_expected.to contain_package('python-mysqldb').with(:ensure => 'present') } @@ -58,7 +62,7 @@ describe 'watcher::db' do context 'with incorrect database_connection string' do let :params do - { :database_connection => 'foodb://watcher:watcher@localhost/watcher', } + { :database_connection => 'foodb://watcher:watcher@localhost/watcher', } end it_raises 'a Puppet::Error', /validate_re/ @@ -66,7 +70,7 @@ describe 'watcher::db' do context 'with incorrect pymysql database_connection string' do let :params do - { :database_connection => 'foo+pymysql://watcher:watcher@localhost/watcher', } + { :database_connection => 'foo+pymysql://watcher:watcher@localhost/watcher', } end it_raises 'a Puppet::Error', /validate_re/ @@ -77,7 +81,7 @@ describe 'watcher::db' do shared_examples_for 'watcher::db on Debian' do context 'using pymysql driver' do let :params do - { :database_connection => 'mysql+pymysql://watcher:watcher@localhost/watcher', } + { :database_connection => 'mysql+pymysql://watcher:watcher@localhost/watcher', } end it 'install the proper backend package' do @@ -93,7 +97,7 @@ describe 'watcher::db' do shared_examples_for 'watcher::db on RedHat' do context 'using pymysql driver' do let :params do - { :database_connection => 'mysql+pymysql://watcher:watcher@localhost/watcher', } + { :database_connection => 'mysql+pymysql://watcher:watcher@localhost/watcher', } end it 'install the proper backend package' do @@ -103,7 +107,7 @@ describe 'watcher::db' do end on_supported_os({ - :supported_os => OSDefaults.get_supported_os + :supported_os => OSDefaults.get_supported_os }).each do |os,facts| context "on #{os}" do let (:facts) do