summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2019-01-19 00:00:01 +0000
committerGerrit Code Review <review@openstack.org>2019-01-19 00:00:01 +0000
commit890b23abecf4019dae40d2117dc86f8d3d2c3c9c (patch)
tree40d0edb98bc77c013b2e5effce1b6b027bdcf111
parentf54faaf00407bd41a56dc82ff7869db6df798e85 (diff)
parent6df93a38bdc2c2f6347bfa7c726aecefa9773173 (diff)
Merge "Remove redundantly tested code"
-rw-r--r--spec/classes/glare_db_spec.rb78
1 files changed, 10 insertions, 68 deletions
diff --git a/spec/classes/glare_db_spec.rb b/spec/classes/glare_db_spec.rb
index e43f832..02f6f56 100644
--- a/spec/classes/glare_db_spec.rb
+++ b/spec/classes/glare_db_spec.rb
@@ -1,10 +1,11 @@
1require 'spec_helper' 1require 'spec_helper'
2 2
3describe 'glare::db' do 3describe 'glare::db' do
4
5 shared_examples 'glare::db' do 4 shared_examples 'glare::db' do
6 context 'with default parameters' do 5 context 'with default parameters' do
7 it { is_expected.to contain_oslo__db('glare_config').with( 6 it { should contain_class('glare::deps') }
7
8 it { should contain_oslo__db('glare_config').with(
8 :db_max_retries => '<SERVICE DEFAULT>', 9 :db_max_retries => '<SERVICE DEFAULT>',
9 :connection => 'sqlite:////var/lib/glare/glare.sqlite', 10 :connection => 'sqlite:////var/lib/glare/glare.sqlite',
10 :idle_timeout => '<SERVICE DEFAULT>', 11 :idle_timeout => '<SERVICE DEFAULT>',
@@ -19,7 +20,8 @@ describe 'glare::db' do
19 20
20 context 'with specific parameters' do 21 context 'with specific parameters' do
21 let :params do 22 let :params do
22 { :database_connection => 'mysql+pymysql://glare:glare@localhost/glare', 23 {
24 :database_connection => 'mysql+pymysql://glare:glare@localhost/glare',
23 :database_idle_timeout => '3601', 25 :database_idle_timeout => '3601',
24 :database_min_pool_size => '2', 26 :database_min_pool_size => '2',
25 :database_db_max_retries => '-1', 27 :database_db_max_retries => '-1',
@@ -31,7 +33,9 @@ describe 'glare::db' do
31 } 33 }
32 end 34 end
33 35
34 it { is_expected.to contain_oslo__db('glare_config').with( 36 it { should contain_class('glare::deps') }
37
38 it { should contain_oslo__db('glare_config').with(
35 :db_max_retries => '-1', 39 :db_max_retries => '-1',
36 :connection => 'mysql+pymysql://glare:glare@localhost/glare', 40 :connection => 'mysql+pymysql://glare:glare@localhost/glare',
37 :idle_timeout => '3601', 41 :idle_timeout => '3601',
@@ -43,79 +47,17 @@ describe 'glare::db' do
43 :pool_timeout => '21', 47 :pool_timeout => '21',
44 )} 48 )}
45 end 49 end
46
47 context 'with postgresql backend' do
48 let :params do
49 { :database_connection => 'postgresql://glare:glare@localhost/glare', }
50 end
51
52 it 'install the proper backend package' do
53 is_expected.to contain_package('python-psycopg2').with(:ensure => 'present')
54 end
55
56 end
57
58 context 'with MySQL-python library as backend package' do
59 let :params do
60 { :database_connection => 'mysql://glare:glare@localhost/glare', }
61 end
62
63 it { is_expected.to contain_package('python-mysqldb').with(:ensure => 'present') }
64 end
65
66 context 'with incorrect database_connection string' do
67 let :params do
68 { :database_connection => 'foodb://glare:glare@localhost/glare', }
69 end
70
71 it_raises 'a Puppet::Error', /validate_re/
72 end
73
74 context 'with incorrect pymysql database_connection string' do
75 let :params do
76 { :database_connection => 'foo+pymysql://glare:glare@localhost/glare', }
77 end
78
79 it_raises 'a Puppet::Error', /validate_re/
80 end
81
82 end
83
84 shared_examples_for 'glare::db on Debian' do
85 context 'using pymysql driver' do
86 let :params do
87 { :database_connection => 'mysql+pymysql://glare:glare@localhost/glare', }
88 end
89
90 it 'install the proper backend package' do
91 is_expected.to contain_package('python-pymysql').with(
92 :ensure => 'present',
93 :name => 'python-pymysql',
94 :tag => 'openstack'
95 )
96 end
97 end
98 end
99
100 shared_examples_for 'glare::db on RedHat' do
101 context 'using pymysql driver' do
102 let :params do
103 { :database_connection => 'mysql+pymysql://glare:glare@localhost/glare', }
104 end
105
106 end
107 end 50 end
108 51
109 on_supported_os({ 52 on_supported_os({
110 :supported_os => OSDefaults.get_supported_os 53 :supported_os => OSDefaults.get_supported_os
111 }).each do |os,facts| 54 }).each do |os,facts|
112 context "on #{os}" do 55 context "on #{os}" do
113 let (:facts) do 56 let (:facts) do
114 facts.merge!(OSDefaults.get_facts()) 57 facts.merge!(OSDefaults.get_facts())
115 end 58 end
116 59
117 it_configures 'glare::db' 60 it_behaves_like 'glare::db'
118 it_configures "glare::db on #{facts[:osfamily]}"
119 end 61 end
120 end 62 end
121end 63end