Browse Source

Switch glance to rspec-puppet-facts

This change updates the glance tests to use rspec-puppet-facts to test
multiple operating systems.

Change-Id: I75fd8970ba8335cb4ffa09a7d600415056e9f889
Alex Schultz 3 years ago
parent
commit
cda71192de

+ 15
- 17
spec/classes/glance_api_db_spec.rb View File

@@ -52,13 +52,7 @@ describe 'glance::api::db' do
52 52
 
53 53
   end
54 54
 
55
-  context 'on Debian platforms' do
56
-    let :facts do
57
-      @default_facts.merge({ :osfamily => 'Debian' })
58
-    end
59
-
60
-    it_configures 'glance::api::db'
61
-
55
+  shared_examples_for 'glance::api::db Debian' do
62 56
    context 'using pymysql driver' do
63 57
       let :params do
64 58
         { :database_connection     => 'mysql+pymysql://glance_api:glance@localhost/glance', }
@@ -74,16 +68,7 @@ describe 'glance::api::db' do
74 68
     end
75 69
   end
76 70
 
77
-  context 'on Redhat platforms' do
78
-    let :facts do
79
-      @default_facts.merge({
80
-        :osfamily               => 'RedHat',
81
-        :operatingsystemrelease => '7',
82
-      })
83
-    end
84
-
85
-    it_configures 'glance::api::db'
86
-
71
+  shared_examples_for 'glance::api::db RedHat' do
87 72
     context 'using pymysql driver' do
88 73
       let :params do
89 74
         { :database_connection     => 'mysql+pymysql://glance_api:glance@localhost/glance', }
@@ -93,5 +78,18 @@ describe 'glance::api::db' do
93 78
     end
94 79
   end
95 80
 
81
+  on_supported_os({
82
+    :supported_os   => OSDefaults.get_supported_os
83
+  }).each do |os,facts|
84
+    context "on #{os}" do
85
+      let (:facts) do
86
+        facts.merge!(OSDefaults.get_facts())
87
+      end
88
+
89
+      it_configures 'glance::api::db'
90
+      it_configures "glance::api::db #{facts[:osfamily]}"
91
+    end
92
+  end
93
+
96 94
 end
97 95
 

+ 9
- 17
spec/classes/glance_api_logging_spec.rb View File

@@ -127,24 +127,16 @@ describe 'glance::api::logging' do
127 127
       }
128 128
   end
129 129
 
130
-  context 'on Debian platforms' do
131
-    let :facts do
132
-      @default_facts.merge({
133
-        :osfamily       => 'Debian',
134
-      })
130
+  on_supported_os({
131
+    :supported_os   => OSDefaults.get_supported_os
132
+  }).each do |os,facts|
133
+    context "on #{os}" do
134
+      let (:facts) do
135
+        facts.merge!(OSDefaults.get_facts())
136
+      end
137
+
138
+      it_configures 'glance-api-logging'
135 139
     end
136
-
137
-    it_configures 'glance-api-logging'
138
-  end
139
-
140
-  context 'on RedHat platforms' do
141
-    let :facts do
142
-      @default_facts.merge({
143
-        :osfamily => 'RedHat',
144
-      })
145
-    end
146
-
147
-    it_configures 'glance-api-logging'
148 140
   end
149 141
 
150 142
 end

+ 239
- 242
spec/classes/glance_api_spec.rb View File

@@ -2,13 +2,6 @@ require 'spec_helper'
2 2
 
3 3
 describe 'glance::api' do
4 4
 
5
-  let :facts do
6
-    @default_facts.merge({
7
-     :osfamily       => 'Debian',
8
-     :processorcount => '7',
9
-    })
10
-  end
11
-
12 5
   let :default_params do
13 6
     {
14 7
       :verbose                  => false,
@@ -50,280 +43,277 @@ describe 'glance::api' do
50 43
     }
51 44
   end
52 45
 
53
-  [{:keystone_password => 'ChangeMe'},
54
-   {
55
-      :verbose                  => true,
56
-      :debug                    => true,
57
-      :bind_host                => '127.0.0.1',
58
-      :bind_port                => '9222',
59
-      :registry_host            => '127.0.0.1',
60
-      :registry_port            => '9111',
61
-      :registry_client_protocol => 'https',
62
-      :auth_type                => 'not_keystone',
63
-      :auth_region              => 'RegionOne2',
64
-      :enabled                  => false,
65
-      :backlog                  => '4095',
66
-      :workers                  => '5',
67
-      :keystone_tenant          => 'admin2',
68
-      :keystone_user            => 'admin2',
69
-      :keystone_password        => 'ChangeMe2',
70
-      :token_cache_time         => '300',
71
-      :show_image_direct_url    => true,
72
-      :show_multiple_locations  => true,
73
-      :location_strategy        => 'store_type',
74
-      :delayed_delete           => 'true',
75
-      :scrub_time               => '10',
76
-      :image_cache_dir          => '/tmp/glance',
77
-      :image_cache_stall_time   => '10',
78
-      :image_cache_max_size     => '10737418240',
79
-      :os_region_name           => 'RegionOne2',
80
-      :signing_dir              => '/path/to/dir',
81
-      :pipeline                 => 'keystone2',
82
-      :auth_uri                 => 'http://127.0.0.1:5000/v2.0',
83
-      :identity_uri             => 'http://127.0.0.1:35357/v2.0',
84
-    }
85
-  ].each do |param_set|
86
-
87
-    describe "when #{param_set == {:keystone_password => 'ChangeMe'} ? "using default" : "specifying"} class parameters" do
88
-
89
-      let :param_hash do
90
-        default_params.merge(param_set)
91
-      end
92
-
93
-      let :params do
94
-        param_set
95
-      end
46
+  shared_examples_for 'glance::api' do
47
+    [{:keystone_password => 'ChangeMe'},
48
+     {
49
+        :verbose                  => true,
50
+        :debug                    => true,
51
+        :bind_host                => '127.0.0.1',
52
+        :bind_port                => '9222',
53
+        :registry_host            => '127.0.0.1',
54
+        :registry_port            => '9111',
55
+        :registry_client_protocol => 'https',
56
+        :auth_type                => 'not_keystone',
57
+        :auth_region              => 'RegionOne2',
58
+        :enabled                  => false,
59
+        :backlog                  => '4095',
60
+        :workers                  => '5',
61
+        :keystone_tenant          => 'admin2',
62
+        :keystone_user            => 'admin2',
63
+        :keystone_password        => 'ChangeMe2',
64
+        :token_cache_time         => '300',
65
+        :show_image_direct_url    => true,
66
+        :show_multiple_locations  => true,
67
+        :location_strategy        => 'store_type',
68
+        :delayed_delete           => 'true',
69
+        :scrub_time               => '10',
70
+        :image_cache_dir          => '/tmp/glance',
71
+        :image_cache_stall_time   => '10',
72
+        :image_cache_max_size     => '10737418240',
73
+        :os_region_name           => 'RegionOne2',
74
+        :signing_dir              => '/path/to/dir',
75
+        :pipeline                 => 'keystone2',
76
+        :auth_uri                 => 'http://127.0.0.1:5000/v2.0',
77
+        :identity_uri             => 'http://127.0.0.1:35357/v2.0',
78
+      }
79
+    ].each do |param_set|
96 80
 
97
-      it { is_expected.to contain_class 'glance' }
98
-      it { is_expected.to contain_class 'glance::policy' }
99
-      it { is_expected.to contain_class 'glance::api::logging' }
100
-      it { is_expected.to contain_class 'glance::api::db' }
81
+      describe "when #{param_set == {:keystone_password => 'ChangeMe'} ? "using default" : "specifying"} class parameters" do
101 82
 
102
-      it { is_expected.to contain_service('glance-api').with(
103
-        'ensure'     => (param_hash[:manage_service] && param_hash[:enabled]) ? 'running': 'stopped',
104
-        'enable'     => param_hash[:enabled],
105
-        'hasstatus'  => true,
106
-        'hasrestart' => true,
107
-        'tag'        => 'glance-service',
108
-      ) }
109
-
110
-      it { is_expected.to_not contain_exec('validate_nova_api') }
111
-      it { is_expected.to contain_glance_api_config("paste_deploy/flavor").with_value(param_hash[:pipeline]) }
112
-
113
-      it 'is_expected.to lay down default api config' do
114
-        [
115
-          'use_stderr',
116
-          'bind_host',
117
-          'bind_port',
118
-          'registry_host',
119
-          'registry_port',
120
-          'registry_client_protocol',
121
-          'show_image_direct_url',
122
-          'show_multiple_locations',
123
-          'location_strategy',
124
-          'delayed_delete',
125
-          'scrub_time',
126
-          'image_cache_dir',
127
-          'auth_region'
128
-        ].each do |config|
129
-          is_expected.to contain_glance_api_config("DEFAULT/#{config}").with_value(param_hash[config.intern])
83
+        let :param_hash do
84
+          default_params.merge(param_set)
130 85
         end
131
-      end
132 86
 
133
-      it 'is_expected.to lay down default cache config' do
134
-        [
135
-          'registry_host',
136
-          'registry_port',
137
-          'image_cache_stall_time',
138
-          'image_cache_max_size',
139
-        ].each do |config|
140
-          is_expected.to contain_glance_cache_config("DEFAULT/#{config}").with_value(param_hash[config.intern])
87
+        let :params do
88
+          param_set
141 89
         end
142
-      end
143 90
 
144
-      it 'is_expected.to lay down default glance_store api and cache config' do
145
-        [
146
-          'os_region_name',
147
-        ].each do |config|
148
-          is_expected.to contain_glance_cache_config("glance_store/#{config}").with_value(param_hash[config.intern])
149
-          is_expected.to contain_glance_api_config("glance_store/#{config}").with_value(param_hash[config.intern])
91
+        it { is_expected.to contain_class 'glance' }
92
+        it { is_expected.to contain_class 'glance::policy' }
93
+        it { is_expected.to contain_class 'glance::api::logging' }
94
+        it { is_expected.to contain_class 'glance::api::db' }
95
+
96
+        it { is_expected.to contain_service('glance-api').with(
97
+          'ensure'     => (param_hash[:manage_service] && param_hash[:enabled]) ? 'running': 'stopped',
98
+          'enable'     => param_hash[:enabled],
99
+          'hasstatus'  => true,
100
+          'hasrestart' => true,
101
+          'tag'        => 'glance-service',
102
+        ) }
103
+
104
+        it { is_expected.to_not contain_exec('validate_nova_api') }
105
+        it { is_expected.to contain_glance_api_config("paste_deploy/flavor").with_value(param_hash[:pipeline]) }
106
+
107
+        it 'is_expected.to lay down default api config' do
108
+          [
109
+            'use_stderr',
110
+            'bind_host',
111
+            'bind_port',
112
+            'registry_host',
113
+            'registry_port',
114
+            'registry_client_protocol',
115
+            'show_image_direct_url',
116
+            'show_multiple_locations',
117
+            'location_strategy',
118
+            'delayed_delete',
119
+            'scrub_time',
120
+            'image_cache_dir',
121
+            'auth_region'
122
+          ].each do |config|
123
+            is_expected.to contain_glance_api_config("DEFAULT/#{config}").with_value(param_hash[config.intern])
124
+          end
150 125
         end
151
-      end
152 126
 
153
-      it 'is_expected.to have no ssl options' do
154
-        is_expected.to contain_glance_api_config('DEFAULT/ca_file').with_ensure('absent')
155
-        is_expected.to contain_glance_api_config('DEFAULT/cert_file').with_ensure('absent')
156
-        is_expected.to contain_glance_api_config('DEFAULT/key_file').with_ensure('absent')
157
-      end
127
+        it 'is_expected.to lay down default cache config' do
128
+          [
129
+            'registry_host',
130
+            'registry_port',
131
+            'image_cache_stall_time',
132
+            'image_cache_max_size',
133
+          ].each do |config|
134
+            is_expected.to contain_glance_cache_config("DEFAULT/#{config}").with_value(param_hash[config.intern])
135
+          end
136
+        end
158 137
 
159
-      it 'is_expected.to configure itself for keystone if that is the auth_type' do
160
-        if params[:auth_type] == 'keystone'
161
-          is_expected.to contain('paste_deploy/flavor').with_value('keystone+cachemanagement')
162
-          is_expected.to contain_glance_api_config('keystone_authtoken/memcached_servers').with_value(param_hash[:memcached_servers])
163
-          ['admin_tenant_name', 'admin_user', 'admin_password', 'token_cache_time', 'signing_dir', 'auth_uri', 'identity_uri'].each do |config|
164
-            is_expected.to contain_glance_api_config("keystone_authtoken/#{config}").with_value(param_hash[config.intern])
138
+        it 'is_expected.to lay down default glance_store api and cache config' do
139
+          [
140
+            'os_region_name',
141
+          ].each do |config|
142
+            is_expected.to contain_glance_cache_config("glance_store/#{config}").with_value(param_hash[config.intern])
143
+            is_expected.to contain_glance_api_config("glance_store/#{config}").with_value(param_hash[config.intern])
165 144
           end
166
-          is_expected.to contain_glance_api_config('keystone_authtoken/admin_password').with_value(param_hash[:keystone_password]).with_secret(true)
145
+        end
146
+
147
+        it 'is_expected.to have no ssl options' do
148
+          is_expected.to contain_glance_api_config('DEFAULT/ca_file').with_ensure('absent')
149
+          is_expected.to contain_glance_api_config('DEFAULT/cert_file').with_ensure('absent')
150
+          is_expected.to contain_glance_api_config('DEFAULT/key_file').with_ensure('absent')
151
+        end
167 152
 
168
-          ['admin_tenant_name', 'admin_user', 'admin_password'].each do |config|
169
-            is_expected.to contain_glance_cache_config("keystone_authtoken/#{config}").with_value(param_hash[config.intern])
153
+        it 'is_expected.to configure itself for keystone if that is the auth_type' do
154
+          if params[:auth_type] == 'keystone'
155
+            is_expected.to contain('paste_deploy/flavor').with_value('keystone+cachemanagement')
156
+            is_expected.to contain_glance_api_config('keystone_authtoken/memcached_servers').with_value(param_hash[:memcached_servers])
157
+            ['admin_tenant_name', 'admin_user', 'admin_password', 'token_cache_time', 'signing_dir', 'auth_uri', 'identity_uri'].each do |config|
158
+              is_expected.to contain_glance_api_config("keystone_authtoken/#{config}").with_value(param_hash[config.intern])
159
+            end
160
+            is_expected.to contain_glance_api_config('keystone_authtoken/admin_password').with_value(param_hash[:keystone_password]).with_secret(true)
161
+
162
+            ['admin_tenant_name', 'admin_user', 'admin_password'].each do |config|
163
+              is_expected.to contain_glance_cache_config("keystone_authtoken/#{config}").with_value(param_hash[config.intern])
164
+            end
165
+            is_expected.to contain_glance_cache_config('keystone_authtoken/admin_password').with_value(param_hash[:keystone_password]).with_secret(true)
170 166
           end
171
-          is_expected.to contain_glance_cache_config('keystone_authtoken/admin_password').with_value(param_hash[:keystone_password]).with_secret(true)
172 167
         end
173 168
       end
174
-    end
175
-
176
-  end
177 169
 
178
-  describe 'with disabled service managing' do
179
-    let :params do
180
-      {
181
-        :keystone_password => 'ChangeMe',
182
-        :manage_service => false,
183
-        :enabled        => false,
184
-      }
185 170
     end
186 171
 
187
-    it { is_expected.to contain_service('glance-api').with(
188
-        'ensure'     => nil,
189
-        'enable'     => false,
190
-        'hasstatus'  => true,
191
-        'hasrestart' => true,
192
-        'tag'        => 'glance-service',
193
-      ) }
194
-  end
172
+    describe 'with disabled service managing' do
173
+      let :params do
174
+        {
175
+          :keystone_password => 'ChangeMe',
176
+          :manage_service => false,
177
+          :enabled        => false,
178
+        }
179
+      end
195 180
 
196
-  describe 'with overridden pipeline' do
197
-    let :params do
198
-      {
199
-        :keystone_password => 'ChangeMe',
200
-        :pipeline          => 'something',
201
-      }
181
+      it { is_expected.to contain_service('glance-api').with(
182
+          'ensure'     => nil,
183
+          'enable'     => false,
184
+          'hasstatus'  => true,
185
+          'hasrestart' => true,
186
+          'tag'        => 'glance-service',
187
+        ) }
202 188
     end
203 189
 
204
-    it { is_expected.to contain_glance_api_config('paste_deploy/flavor').with_value('something') }
205
-  end
190
+    describe 'with overridden pipeline' do
191
+      let :params do
192
+        {
193
+          :keystone_password => 'ChangeMe',
194
+          :pipeline          => 'something',
195
+        }
196
+      end
206 197
 
207
-  describe 'with blank pipeline' do
208
-    let :params do
209
-      {
210
-        :keystone_password => 'ChangeMe',
211
-        :pipeline          => '',
212
-      }
198
+      it { is_expected.to contain_glance_api_config('paste_deploy/flavor').with_value('something') }
213 199
     end
214 200
 
215
-    it { is_expected.to contain_glance_api_config('paste_deploy/flavor').with_ensure('absent') }
216
-  end
217
-
218
-  [
219
-    'keystone/',
220
-    'keystone+',
221
-    '+keystone',
222
-    'keystone+cachemanagement+',
223
-    '+'
224
-  ].each do |pipeline|
225
-    describe "with pipeline incorrect value #{pipeline}" do
201
+    describe 'with blank pipeline' do
226 202
       let :params do
227 203
         {
228 204
           :keystone_password => 'ChangeMe',
229
-          :pipeline          => pipeline
205
+          :pipeline          => '',
230 206
         }
231 207
       end
232 208
 
233
-      it { expect { is_expected.to contain_glance_api_config('filter:paste_deploy/flavor') }.to\
234
-        raise_error(Puppet::Error, /validate_re\(\): .* does not match/) }
209
+      it { is_expected.to contain_glance_api_config('paste_deploy/flavor').with_ensure('absent') }
235 210
     end
236
-  end
237 211
 
238
-  describe 'with ssl options' do
239
-    let :params do
240
-      default_params.merge({
241
-        :ca_file     => '/tmp/ca_file',
242
-        :cert_file   => '/tmp/cert_file',
243
-        :key_file    => '/tmp/key_file'
244
-      })
245
-    end
212
+    [
213
+      'keystone/',
214
+      'keystone+',
215
+      '+keystone',
216
+      'keystone+cachemanagement+',
217
+      '+'
218
+    ].each do |pipeline|
219
+      describe "with pipeline incorrect value #{pipeline}" do
220
+        let :params do
221
+          {
222
+            :keystone_password => 'ChangeMe',
223
+            :pipeline          => pipeline
224
+          }
225
+        end
246 226
 
247
-    context 'with ssl options' do
248
-      it { is_expected.to contain_glance_api_config('DEFAULT/ca_file').with_value('/tmp/ca_file') }
249
-      it { is_expected.to contain_glance_api_config('DEFAULT/cert_file').with_value('/tmp/cert_file') }
250
-      it { is_expected.to contain_glance_api_config('DEFAULT/key_file').with_value('/tmp/key_file') }
251
-    end
252
-  end
253
-  describe 'with known_stores by default' do
254
-    let :params do
255
-      default_params
227
+        it { expect { is_expected.to contain_glance_api_config('filter:paste_deploy/flavor') }.to\
228
+          raise_error(Puppet::Error, /validate_re\(\): .* does not match/) }
229
+      end
256 230
     end
257 231
 
258
-    it { is_expected.to_not contain_glance_api_config('glance_store/stores').with_value('false') }
259
-  end
232
+    describe 'with ssl options' do
233
+      let :params do
234
+        default_params.merge({
235
+          :ca_file     => '/tmp/ca_file',
236
+          :cert_file   => '/tmp/cert_file',
237
+          :key_file    => '/tmp/key_file'
238
+        })
239
+      end
260 240
 
261
-  describe 'with known_stores override' do
262
-    let :params do
263
-      default_params.merge({
264
-        :known_stores   => ['glance.store.filesystem.Store','glance.store.http.Store'],
265
-      })
241
+      context 'with ssl options' do
242
+        it { is_expected.to contain_glance_api_config('DEFAULT/ca_file').with_value('/tmp/ca_file') }
243
+        it { is_expected.to contain_glance_api_config('DEFAULT/cert_file').with_value('/tmp/cert_file') }
244
+        it { is_expected.to contain_glance_api_config('DEFAULT/key_file').with_value('/tmp/key_file') }
245
+      end
266 246
     end
247
+    describe 'with known_stores by default' do
248
+      let :params do
249
+        default_params
250
+      end
267 251
 
268
-    it { is_expected.to contain_glance_api_config('glance_store/stores').with_value("glance.store.filesystem.Store,glance.store.http.Store") }
269
-  end
270
-
271
-  describe 'while validating the service with default command' do
272
-    let :params do
273
-      default_params.merge({
274
-        :validate => true,
275
-      })
252
+      it { is_expected.to_not contain_glance_api_config('glance_store/stores').with_value('false') }
276 253
     end
277
-    it { is_expected.to contain_exec('execute glance-api validation').with(
278
-      :path        => '/usr/bin:/bin:/usr/sbin:/sbin',
279
-      :provider    => 'shell',
280
-      :tries       => '10',
281
-      :try_sleep   => '2',
282
-      :command     => 'glance --os-auth-url http://127.0.0.1:5000/ --os-tenant-name services --os-username glance --os-password ChangeMe image-list',
283
-    )}
284 254
 
285
-    it { is_expected.to contain_anchor('create glance-api anchor').with(
286
-      :require => 'Exec[execute glance-api validation]',
287
-    )}
288
-  end
255
+    describe 'with known_stores override' do
256
+      let :params do
257
+        default_params.merge({
258
+          :known_stores   => ['glance.store.filesystem.Store','glance.store.http.Store'],
259
+        })
260
+      end
289 261
 
290
-  describe 'while validating the service with custom command' do
291
-    let :params do
292
-      default_params.merge({
293
-        :validate            => true,
294
-        :validation_options  => { 'glance-api' => { 'command' => 'my-script' } }
295
-      })
262
+      it { is_expected.to contain_glance_api_config('glance_store/stores').with_value("glance.store.filesystem.Store,glance.store.http.Store") }
296 263
     end
297
-    it { is_expected.to contain_exec('execute glance-api validation').with(
298
-      :path        => '/usr/bin:/bin:/usr/sbin:/sbin',
299
-      :provider    => 'shell',
300
-      :tries       => '10',
301
-      :try_sleep   => '2',
302
-      :command     => 'my-script',
303
-    )}
304 264
 
305
-    it { is_expected.to contain_anchor('create glance-api anchor').with(
306
-      :require => 'Exec[execute glance-api validation]',
307
-    )}
308
-  end
265
+    describe 'while validating the service with default command' do
266
+      let :params do
267
+        default_params.merge({
268
+          :validate => true,
269
+        })
270
+      end
271
+      it { is_expected.to contain_exec('execute glance-api validation').with(
272
+        :path        => '/usr/bin:/bin:/usr/sbin:/sbin',
273
+        :provider    => 'shell',
274
+        :tries       => '10',
275
+        :try_sleep   => '2',
276
+        :command     => 'glance --os-auth-url http://127.0.0.1:5000/ --os-tenant-name services --os-username glance --os-password ChangeMe image-list',
277
+      )}
278
+
279
+      it { is_expected.to contain_anchor('create glance-api anchor').with(
280
+        :require => 'Exec[execute glance-api validation]',
281
+      )}
282
+    end
309 283
 
310
-  describe 'Support IPv6' do
311
-    let :params do
312
-      default_params.merge({
313
-        :registry_host => '2001::1',
314
-      })
284
+    describe 'Support IPv6' do
285
+      let :params do
286
+        default_params.merge({
287
+          :registry_host => '2001::1',
288
+        })
289
+      end
290
+      it { is_expected.to contain_glance_api_config('DEFAULT/registry_host').with(
291
+        :value => '[2001::1]'
292
+      )}
315 293
     end
316
-    it { is_expected.to contain_glance_api_config('DEFAULT/registry_host').with(
317
-      :value => '[2001::1]'
318
-    )}
319
-  end
320 294
 
321
-  describe 'on Debian platforms' do
322
-    let :facts do
323
-      @default_facts.merge({
324
-        :osfamily       => 'Debian',
325
-      })
295
+    describe 'while validating the service with custom command' do
296
+      let :params do
297
+        default_params.merge({
298
+          :validate            => true,
299
+          :validation_options  => { 'glance-api' => { 'command' => 'my-script' } }
300
+        })
301
+      end
302
+      it { is_expected.to contain_exec('execute glance-api validation').with(
303
+        :path        => '/usr/bin:/bin:/usr/sbin:/sbin',
304
+        :provider    => 'shell',
305
+        :tries       => '10',
306
+        :try_sleep   => '2',
307
+        :command     => 'my-script',
308
+      )}
309
+
310
+      it { is_expected.to contain_anchor('create glance-api anchor').with(
311
+        :require => 'Exec[execute glance-api validation]',
312
+      )}
326 313
     end
314
+  end
315
+
316
+  shared_examples_for 'glance::api Debian' do
327 317
     let(:params) { default_params }
328 318
 
329 319
     # We only test this on Debian platforms, since on RedHat there isn't a
@@ -339,13 +329,7 @@ describe 'glance::api' do
339 329
     end
340 330
   end
341 331
 
342
-  describe 'on RedHat platforms' do
343
-    let :facts do
344
-      @default_facts.merge({
345
-        :osfamily               => 'RedHat',
346
-        :operatingsystemrelease => '7',
347
-      })
348
-    end
332
+  shared_examples_for 'glance::api RedHat' do
349 333
     let(:params) { default_params }
350 334
 
351 335
     it { is_expected.to contain_package('openstack-glance').with(
@@ -353,6 +337,19 @@ describe 'glance::api' do
353 337
     )}
354 338
   end
355 339
 
340
+  on_supported_os({
341
+    :supported_os   => OSDefaults.get_supported_os
342
+  }).each do |os,facts|
343
+    context "on #{os}" do
344
+      let (:facts) do
345
+        facts.merge!(OSDefaults.get_facts())
346
+      end
347
+
348
+      it_configures 'glance::api'
349
+      it_configures "glance::api #{facts[:osfamily]}"
350
+    end
351
+  end
352
+
356 353
   describe 'on unknown platforms' do
357 354
     let :facts do
358 355
       { :osfamily => 'unknown' }

+ 8
- 16
spec/classes/glance_backend_cinder_spec.rb View File

@@ -76,24 +76,16 @@ describe 'glance::backend::cinder' do
76 76
 
77 77
   end
78 78
 
79
-  context 'on Debian platforms' do
80
-    let :facts do
81
-      @default_facts.merge({
82
-        :osfamily       => 'Debian',
83
-      })
84
-    end
85 79
 
86
-    it_configures 'glance with cinder backend'
87
-  end
80
+  on_supported_os({
81
+    :supported_os   => OSDefaults.get_supported_os
82
+  }).each do |os,facts|
83
+    context "on #{os}" do
84
+      let (:facts) do
85
+        facts.merge!(OSDefaults.get_facts())
86
+      end
88 87
 
89
-  context 'on RedHat platforms' do
90
-    let :facts do
91
-      @default_facts.merge({
92
-        :osfamily               => 'RedHat',
93
-        :operatingsystemrelease => '7',
94
-      })
88
+      it_configures 'glance with cinder backend'
95 89
     end
96
-
97
-    it_configures 'glance with cinder backend'
98 90
   end
99 91
 end

+ 29
- 20
spec/classes/glance_backend_file_spec.rb View File

@@ -1,32 +1,41 @@
1 1
 require 'spec_helper'
2 2
 
3 3
 describe 'glance::backend::file' do
4
-  let :facts do
5
-      @default_facts.merge({
6
-        :osfamily       => 'Debian',
7
-      })
8
-  end
9
-
10
-  it 'configures glance-api.conf' do
11
-    is_expected.to contain_glance_api_config('glance_store/default_store').with_value('file')
12
-    is_expected.to contain_glance_api_config('glance_store/filesystem_store_datadir').with_value('/var/lib/glance/images/')
13
-  end
14 4
 
15
-  it 'configures glance-cache.conf' do
16
-    is_expected.to contain_glance_cache_config('glance_store/filesystem_store_datadir').with_value('/var/lib/glance/images/')
17
-  end
5
+  shared_examples_for 'glance::backend::file' do
6
+    it 'configures glance-api.conf' do
7
+      is_expected.to contain_glance_api_config('glance_store/default_store').with_value('file')
8
+      is_expected.to contain_glance_api_config('glance_store/filesystem_store_datadir').with_value('/var/lib/glance/images/')
9
+    end
18 10
 
19
-  describe 'when overriding datadir' do
20
-    let :params do
21
-      {:filesystem_store_datadir => '/tmp/'}
11
+    it 'configures glance-cache.conf' do
12
+      is_expected.to contain_glance_cache_config('glance_store/filesystem_store_datadir').with_value('/var/lib/glance/images/')
22 13
     end
23 14
 
24
-    it 'configures glance-api.conf' do
25
-      is_expected.to contain_glance_api_config('glance_store/filesystem_store_datadir').with_value('/tmp/')
15
+    describe 'when overriding datadir' do
16
+      let :params do
17
+        {:filesystem_store_datadir => '/tmp/'}
18
+      end
19
+
20
+      it 'configures glance-api.conf' do
21
+        is_expected.to contain_glance_api_config('glance_store/filesystem_store_datadir').with_value('/tmp/')
22
+      end
23
+
24
+      it 'configures glance-cache.conf' do
25
+        is_expected.to contain_glance_cache_config('glance_store/filesystem_store_datadir').with_value('/tmp/')
26
+      end
26 27
     end
28
+  end
27 29
 
28
-    it 'configures glance-cache.conf' do
29
-      is_expected.to contain_glance_cache_config('glance_store/filesystem_store_datadir').with_value('/tmp/')
30
+  on_supported_os({
31
+    :supported_os   => OSDefaults.get_supported_os
32
+  }).each do |os,facts|
33
+    context "on #{os}" do
34
+      let (:facts) do
35
+        facts.merge!(OSDefaults.get_facts())
36
+      end
37
+
38
+      it_configures 'glance::backend::file'
30 39
     end
31 40
   end
32 41
 end

+ 100
- 92
spec/classes/glance_backend_s3_spec.rb View File

@@ -1,117 +1,125 @@
1 1
 require 'spec_helper'
2 2
 
3 3
 describe 'glance::backend::s3' do
4
-  let :facts do
5
-    @default_facts.merge({
6
-        :osfamily       => 'Debian',
7
-    })
8
-  end
4
+  shared_examples_for 'glance::backend::s3' do
5
+    let :params do
6
+      {
7
+        :access_key => 'access',
8
+        :secret_key => 'secret',
9
+        :host       => 'host',
10
+        :bucket     => 'bucket'
11
+      }
12
+    end
9 13
 
10
-  let :params do
11
-    {
12
-      :access_key => 'access',
13
-      :secret_key => 'secret',
14
-      :host       => 'host',
15
-      :bucket     => 'bucket'
16
-    }
17
-  end
14
+    describe 'when default parameters' do
18 15
 
19
-  describe 'when default parameters' do
16
+      it 'configures glance-api.conf' do
17
+        is_expected.to contain_glance_api_config('glance_store/default_store').with_value('s3')
18
+        is_expected.to contain_glance_api_config('glance_store/s3_store_access_key').with_value('access')
19
+        is_expected.to contain_glance_api_config('glance_store/s3_store_secret_key').with_value('secret')
20
+        is_expected.to contain_glance_api_config('glance_store/s3_store_host').with_value('host')
21
+        is_expected.to contain_glance_api_config('glance_store/s3_store_bucket').with_value('bucket')
22
+        is_expected.to contain_glance_api_config('glance_store/s3_store_bucket_url_format').with_value('subdomain')
23
+        is_expected.to contain_glance_api_config('glance_store/s3_store_create_bucket_on_put').with_value('false')
24
+        is_expected.to contain_glance_api_config('glance_store/s3_store_large_object_size').with_value('100')
25
+        is_expected.to contain_glance_api_config('glance_store/s3_store_large_object_chunk_size').with_value('10')
26
+        is_expected.to contain_glance_api_config('glance_store/s3_store_object_buffer_dir').with_value(nil)
27
+        is_expected.to contain_glance_api_config('glance_store/s3_store_thread_pools').with_value('10')
28
+      end
20 29
 
21
-    it 'configures glance-api.conf' do
22
-      is_expected.to contain_glance_api_config('glance_store/default_store').with_value('s3')
23
-      is_expected.to contain_glance_api_config('glance_store/s3_store_access_key').with_value('access')
24
-      is_expected.to contain_glance_api_config('glance_store/s3_store_secret_key').with_value('secret')
25
-      is_expected.to contain_glance_api_config('glance_store/s3_store_host').with_value('host')
26
-      is_expected.to contain_glance_api_config('glance_store/s3_store_bucket').with_value('bucket')
27
-      is_expected.to contain_glance_api_config('glance_store/s3_store_bucket_url_format').with_value('subdomain')
28
-      is_expected.to contain_glance_api_config('glance_store/s3_store_create_bucket_on_put').with_value('false')
29
-      is_expected.to contain_glance_api_config('glance_store/s3_store_large_object_size').with_value('100')
30
-      is_expected.to contain_glance_api_config('glance_store/s3_store_large_object_chunk_size').with_value('10')
31
-      is_expected.to contain_glance_api_config('glance_store/s3_store_object_buffer_dir').with_value(nil)
32
-      is_expected.to contain_glance_api_config('glance_store/s3_store_thread_pools').with_value('10')
33 30
     end
34 31
 
35
-  end
32
+    describe 'when overriding parameters' do
33
+      let :params do
34
+        {
35
+          :access_key               => 'access2',
36
+          :secret_key               => 'secret2',
37
+          :host                     => 'host2',
38
+          :bucket                   => 'bucket2',
39
+          :bucket_url_format        => 'path',
40
+          :create_bucket_on_put     => true,
41
+          :large_object_size        => 200,
42
+          :large_object_chunk_size  => 20,
43
+          :object_buffer_dir        => '/tmp',
44
+          :thread_pools             => 20,
45
+          :default_store            => false
46
+        }
47
+      end
36 48
 
37
-  describe 'when overriding parameters' do
38
-    let :params do
39
-      {
40
-        :access_key               => 'access2',
41
-        :secret_key               => 'secret2',
42
-        :host                     => 'host2',
43
-        :bucket                   => 'bucket2',
44
-        :bucket_url_format        => 'path',
45
-        :create_bucket_on_put     => true,
46
-        :large_object_size        => 200,
47
-        :large_object_chunk_size  => 20,
48
-        :object_buffer_dir        => '/tmp',
49
-        :thread_pools             => 20,
50
-        :default_store            => false
51
-      }
52
-    end
49
+      it 'configures glance-api.conf' do
50
+        is_expected.to contain_glance_api_config('glance_store/s3_store_access_key').with_value('access2')
51
+        is_expected.to contain_glance_api_config('glance_store/s3_store_secret_key').with_value('secret2')
52
+        is_expected.to contain_glance_api_config('glance_store/s3_store_host').with_value('host2')
53
+        is_expected.to contain_glance_api_config('glance_store/s3_store_bucket').with_value('bucket2')
54
+        is_expected.to contain_glance_api_config('glance_store/s3_store_bucket_url_format').with_value('path')
55
+        is_expected.to contain_glance_api_config('glance_store/s3_store_create_bucket_on_put').with_value('true')
56
+        is_expected.to contain_glance_api_config('glance_store/s3_store_large_object_size').with_value('200')
57
+        is_expected.to contain_glance_api_config('glance_store/s3_store_large_object_chunk_size').with_value('20')
58
+        is_expected.to contain_glance_api_config('glance_store/s3_store_object_buffer_dir').with_value('/tmp')
59
+        is_expected.to contain_glance_api_config('glance_store/s3_store_thread_pools').with_value('20')
60
+        is_expected.to_not contain_glance_api_config('glance_store/default_store')
61
+      end
53 62
 
54
-    it 'configures glance-api.conf' do
55
-      is_expected.to contain_glance_api_config('glance_store/s3_store_access_key').with_value('access2')
56
-      is_expected.to contain_glance_api_config('glance_store/s3_store_secret_key').with_value('secret2')
57
-      is_expected.to contain_glance_api_config('glance_store/s3_store_host').with_value('host2')
58
-      is_expected.to contain_glance_api_config('glance_store/s3_store_bucket').with_value('bucket2')
59
-      is_expected.to contain_glance_api_config('glance_store/s3_store_bucket_url_format').with_value('path')
60
-      is_expected.to contain_glance_api_config('glance_store/s3_store_create_bucket_on_put').with_value('true')
61
-      is_expected.to contain_glance_api_config('glance_store/s3_store_large_object_size').with_value('200')
62
-      is_expected.to contain_glance_api_config('glance_store/s3_store_large_object_chunk_size').with_value('20')
63
-      is_expected.to contain_glance_api_config('glance_store/s3_store_object_buffer_dir').with_value('/tmp')
64
-      is_expected.to contain_glance_api_config('glance_store/s3_store_thread_pools').with_value('20')
65
-      is_expected.to_not contain_glance_api_config('glance_store/default_store')
66 63
     end
67 64
 
68
-  end
65
+    describe 'with invalid bucket_url_format' do
66
+      let :params do
67
+        {
68
+          :access_key               => 'access',
69
+          :secret_key               => 'secret',
70
+          :host                     => 'host',
71
+          :bucket                   => 'bucket',
72
+          :bucket_url_format        => 'invalid'
73
+        }
74
+      end
69 75
 
70
-  describe 'with invalid bucket_url_format' do
71
-    let :params do
72
-      {
73
-        :access_key               => 'access',
74
-        :secret_key               => 'secret',
75
-        :host                     => 'host',
76
-        :bucket                   => 'bucket',
77
-        :bucket_url_format        => 'invalid'
78
-      }
76
+      it 'throws errors' do
77
+        is_expected.to raise_error(Puppet::Error, /glance::backend::s3::bucket_url_format must be either "subdomain" or "path"/)
78
+      end
79 79
     end
80 80
 
81
-    it 'throws errors' do
82
-      is_expected.to raise_error(Puppet::Error, /glance::backend::s3::bucket_url_format must be either "subdomain" or "path"/)
83
-    end
84
-  end
81
+    describe 'with invalid large_object_chunk_size' do
82
+      let :params do
83
+        {
84
+          :access_key               => 'access',
85
+          :secret_key               => 'secret',
86
+          :host                     => 'host',
87
+          :bucket                   => 'bucket',
88
+          :large_object_chunk_size  => 1
89
+        }
90
+      end
85 91
 
86
-  describe 'with invalid large_object_chunk_size' do
87
-    let :params do
88
-      {
89
-        :access_key               => 'access',
90
-        :secret_key               => 'secret',
91
-        :host                     => 'host',
92
-        :bucket                   => 'bucket',
93
-        :large_object_chunk_size  => 1
94
-      }
92
+      it 'throws error' do
93
+        is_expected.to raise_error(Puppet::Error, /glance::backend::s3::large_object_chunk_size must be an integer >= 5/)
94
+      end
95 95
     end
96 96
 
97
-    it 'throws error' do
98
-      is_expected.to raise_error(Puppet::Error, /glance::backend::s3::large_object_chunk_size must be an integer >= 5/)
97
+    describe 'with non-integer large_object_chunk_size' do
98
+      let :params do
99
+        {
100
+          :access_key               => 'access',
101
+          :secret_key               => 'secret',
102
+          :host                     => 'host',
103
+          :bucket                   => 'bucket',
104
+          :large_object_chunk_size  => 'string'
105
+        }
106
+      end
107
+
108
+      it 'throws error' do
109
+        is_expected.to raise_error(Puppet::Error, /glance::backend::s3::large_object_chunk_size must be an integer >= 5/)
110
+      end
99 111
     end
100 112
   end
101 113
 
102
-  describe 'with non-integer large_object_chunk_size' do
103
-    let :params do
104
-      {
105
-        :access_key               => 'access',
106
-        :secret_key               => 'secret',
107
-        :host                     => 'host',
108
-        :bucket                   => 'bucket',
109
-        :large_object_chunk_size  => 'string'
110
-      }
111
-    end
114
+  on_supported_os({
115
+    :supported_os   => OSDefaults.get_supported_os
116
+  }).each do |os,facts|
117
+    context "on #{os}" do
118
+      let (:facts) do
119
+        facts.merge!(OSDefaults.get_facts())
120
+      end
112 121
 
113
-    it 'throws error' do
114
-      is_expected.to raise_error(Puppet::Error, /glance::backend::s3::large_object_chunk_size must be an integer >= 5/)
122
+      it_configures 'glance::backend::s3'
115 123
     end
116 124
   end
117 125
 end

+ 62
- 55
spec/classes/glance_backend_swift_spec.rb View File

@@ -1,70 +1,77 @@
1 1
 require 'spec_helper'
2 2
 
3 3
 describe 'glance::backend::swift' do
4
-  let :facts do
5
-    @default_facts.merge({
6
-      :osfamily       => 'Debian',
7
-    })
8
-  end
4
+  shared_examples_for 'glance::backend::swift' do
5
+    let :params do
6
+      {
7
+        :swift_store_user => 'user',
8
+        :swift_store_key  => 'key',
9
+      }
10
+    end
9 11
 
10
-  let :params do
11
-    {
12
-      :swift_store_user => 'user',
13
-      :swift_store_key  => 'key',
14
-    }
15
-  end
12
+    let :pre_condition do
13
+      'class { "glance::api": keystone_password => "pass" }'
14
+    end
16 15
 
17
-  let :pre_condition do
18
-    'class { "glance::api": keystone_password => "pass" }'
19
-  end
16
+    describe 'when default parameters' do
20 17
 
21
-  describe 'when default parameters' do
18
+      it 'configures glance-api.conf' do
19
+        is_expected.to contain_glance_api_config('glance_store/default_store').with_value('swift')
20
+        is_expected.to contain_glance_api_config('glance_store/swift_store_large_object_size').with_value('5120')
21
+        is_expected.to contain_glance_api_config('glance_store/swift_store_container').with_value('glance')
22
+        is_expected.to contain_glance_api_config('glance_store/swift_store_create_container_on_put').with_value(false)
23
+        is_expected.to contain_glance_api_config('glance_store/swift_store_endpoint_type').with_value('internalURL')
24
+        is_expected.to contain_glance_api_config('glance_store/swift_store_region').with_value(nil)
25
+        is_expected.to contain_glance_api_config('glance_store/swift_store_config_file').with_value('/etc/glance/glance-swift.conf')
26
+        is_expected.to contain_glance_api_config('glance_store/default_swift_reference').with_value('ref1')
27
+        is_expected.to contain_glance_swift_config('ref1/key').with_value('key')
28
+        is_expected.to contain_glance_swift_config('ref1/user').with_value('user')
29
+        is_expected.to contain_glance_swift_config('ref1/auth_version').with_value('2')
30
+        is_expected.to contain_glance_swift_config('ref1/auth_address').with_value('http://127.0.0.1:5000/v2.0/')
31
+      end
22 32
 
23
-    it 'configures glance-api.conf' do
24
-      is_expected.to contain_glance_api_config('glance_store/default_store').with_value('swift')
25
-      is_expected.to contain_glance_api_config('glance_store/swift_store_large_object_size').with_value('5120')
26
-      is_expected.to contain_glance_api_config('glance_store/swift_store_container').with_value('glance')
27
-      is_expected.to contain_glance_api_config('glance_store/swift_store_create_container_on_put').with_value(false)
28
-      is_expected.to contain_glance_api_config('glance_store/swift_store_endpoint_type').with_value('internalURL')
29
-      is_expected.to contain_glance_api_config('glance_store/swift_store_region').with_value(nil)
30
-      is_expected.to contain_glance_api_config('glance_store/swift_store_config_file').with_value('/etc/glance/glance-swift.conf')
31
-      is_expected.to contain_glance_api_config('glance_store/default_swift_reference').with_value('ref1')
32
-      is_expected.to contain_glance_swift_config('ref1/key').with_value('key')
33
-      is_expected.to contain_glance_swift_config('ref1/user').with_value('user')
34
-      is_expected.to contain_glance_swift_config('ref1/auth_version').with_value('2')
35
-      is_expected.to contain_glance_swift_config('ref1/auth_address').with_value('http://127.0.0.1:5000/v2.0/')
36 33
     end
37 34
 
38
-  end
35
+    describe 'when overriding parameters' do
36
+      let :params do
37
+        {
38
+          :swift_store_user                    => 'user2',
39
+          :swift_store_key                     => 'key2',
40
+          :swift_store_auth_version            => '1',
41
+          :swift_store_large_object_size       => '100',
42
+          :swift_store_auth_address            => '127.0.0.2:8080/v1.0/',
43
+          :swift_store_container               => 'swift',
44
+          :swift_store_create_container_on_put => true,
45
+          :swift_store_endpoint_type           => 'publicURL',
46
+          :swift_store_region                  => 'RegionTwo',
47
+          :default_swift_reference             => 'swift_creds',
48
+        }
49
+      end
39 50
 
40
-  describe 'when overriding parameters' do
41
-    let :params do
42
-      {
43
-        :swift_store_user                    => 'user2',
44
-        :swift_store_key                     => 'key2',
45
-        :swift_store_auth_version            => '1',
46
-        :swift_store_large_object_size       => '100',
47
-        :swift_store_auth_address            => '127.0.0.2:8080/v1.0/',
48
-        :swift_store_container               => 'swift',
49
-        :swift_store_create_container_on_put => true,
50
-        :swift_store_endpoint_type           => 'publicURL',
51
-        :swift_store_region                  => 'RegionTwo',
52
-        :default_swift_reference             => 'swift_creds',
53
-      }
51
+      it 'configures glance-api.conf' do
52
+        is_expected.to contain_glance_api_config('glance_store/swift_store_container').with_value('swift')
53
+        is_expected.to contain_glance_api_config('glance_store/swift_store_create_container_on_put').with_value(true)
54
+        is_expected.to contain_glance_api_config('glance_store/swift_store_large_object_size').with_value('100')
55
+        is_expected.to contain_glance_api_config('glance_store/swift_store_endpoint_type').with_value('publicURL')
56
+        is_expected.to contain_glance_api_config('glance_store/swift_store_region').with_value('RegionTwo')
57
+        is_expected.to contain_glance_api_config('glance_store/default_swift_reference').with_value('swift_creds')
58
+        is_expected.to contain_glance_swift_config('swift_creds/key').with_value('key2')
59
+        is_expected.to contain_glance_swift_config('swift_creds/user').with_value('user2')
60
+        is_expected.to contain_glance_swift_config('swift_creds/auth_version').with_value('1')
61
+        is_expected.to contain_glance_swift_config('swift_creds/auth_address').with_value('127.0.0.2:8080/v1.0/')
62
+      end
54 63
     end
64
+  end
55 65
 
56
-    it 'configures glance-api.conf' do
57
-      is_expected.to contain_glance_api_config('glance_store/swift_store_container').with_value('swift')
58
-      is_expected.to contain_glance_api_config('glance_store/swift_store_create_container_on_put').with_value(true)
59
-      is_expected.to contain_glance_api_config('glance_store/swift_store_large_object_size').with_value('100')
60
-      is_expected.to contain_glance_api_config('glance_store/swift_store_endpoint_type').with_value('publicURL')
61
-      is_expected.to contain_glance_api_config('glance_store/swift_store_region').with_value('RegionTwo')
62
-      is_expected.to contain_glance_api_config('glance_store/default_swift_reference').with_value('swift_creds')
63
-      is_expected.to contain_glance_swift_config('swift_creds/key').with_value('key2')
64
-      is_expected.to contain_glance_swift_config('swift_creds/user').with_value('user2')
65
-      is_expected.to contain_glance_swift_config('swift_creds/auth_version').with_value('1')
66
-      is_expected.to contain_glance_swift_config('swift_creds/auth_address').with_value('127.0.0.2:8080/v1.0/')
67
-    end
66
+  on_supported_os({
67
+    :supported_os   => OSDefaults.get_supported_os
68
+  }).each do |os,facts|
69
+    context "on #{os}" do
70
+      let (:facts) do
71
+        facts.merge!(OSDefaults.get_facts())
72
+      end
68 73
 
74
+      it_configures 'glance::backend::swift'
75
+    end
69 76
   end
70 77
 end

+ 8
- 18
spec/classes/glance_backend_vsphere_spec.rb View File

@@ -73,27 +73,17 @@ describe 'glance::backend::vsphere' do
73 73
         is_expected.to contain_glance_api_config('glance_store/vmware_api_retry_count').with_value('11')
74 74
       end
75 75
     end
76
-
77 76
   end
78 77
 
79
-  context 'on Debian platforms' do
80
-    let :facts do
81
-      @default_facts.merge({
82
-        :osfamily       => 'Debian',
83
-      })
84
-    end
85
-
86
-    it_configures 'glance with vsphere backend'
87
-  end
78
+  on_supported_os({
79
+    :supported_os   => OSDefaults.get_supported_os
80
+  }).each do |os,facts|
81
+    context "on #{os}" do
82
+      let (:facts) do
83
+        facts.merge!(OSDefaults.get_facts())
84
+      end
88 85
 
89
-  context 'on RedHat platforms' do
90
-    let :facts do
91
-      @default_facts.merge({
92
-        :osfamily               => 'RedHat',
93
-        :operatingsystemrelease => '7',
94
-      })
86
+      it_configures 'glance with vsphere backend'
95 87
     end
96
-
97
-    it_configures 'glance with vsphere backend'
98 88
   end
99 89
 end

+ 21
- 17
spec/classes/glance_cache_cleaner_spec.rb View File

@@ -17,6 +17,10 @@ describe 'glance::cache::cleaner' do
17 17
           :month       => '*',
18 18
           :weekday     => '*'
19 19
         )
20
+
21
+        is_expected.to contain_cron('glance-cache-cleaner').with(
22
+          :require => "Package[#{platform_params[:api_package_name]}]"
23
+        )
20 24
       end
21 25
     end
22 26
 
@@ -46,25 +50,25 @@ describe 'glance::cache::cleaner' do
46 50
     end
47 51
   end
48 52
 
49
-  context 'on Debian platforms' do
50
-    let :facts do
51
-      @default_facts.merge({
52
-        :osfamily       => 'Debian',
53
-      })
54
-    end
55
-    include_examples 'glance cache cleaner'
56
-    it { is_expected.to contain_cron('glance-cache-cleaner').with(:require     => 'Package[glance-api]')}
57
-  end
53
+  on_supported_os({
54
+    :supported_os   => OSDefaults.get_supported_os
55
+  }).each do |os,facts|
56
+    context "on #{os}" do
57
+      let (:facts) do
58
+        facts.merge!(OSDefaults.get_facts())
59
+      end
60
+
61
+      let(:platform_params) do
62
+        case facts[:osfamily]
63
+        when 'Debian'
64
+          { :api_package_name => 'glance-api' }
65
+        when 'RedHat'
66
+          { :api_package_name => 'openstack-glance' }
67
+        end
68
+      end
58 69
 
59
-  context 'on RedHat platforms' do
60
-    let :facts do
61
-      @default_facts.merge({
62
-        :osfamily               => 'RedHat',
63
-        :operatingsystemrelease => '7',
64
-      })
70
+      it_configures 'glance cache cleaner'
65 71
     end
66
-    include_examples 'glance cache cleaner'
67
-    it { is_expected.to contain_cron('glance-cache-cleaner').with(:require     => 'Package[openstack-glance]')}
68 72
   end
69 73
 
70 74
 end

+ 9
- 14
spec/classes/glance_cache_logging_spec.rb View File

@@ -127,20 +127,15 @@ describe 'glance::cache::logging' do
127 127
       }
128 128
   end
129 129
 
130
-  context 'on Debian platforms' do
131
-    let :facts do
132
-       @default_facts.merge({ :osfamily => 'Debian' })
130
+  on_supported_os({
131
+    :supported_os   => OSDefaults.get_supported_os
132
+  }).each do |os,facts|
133
+    context "on #{os}" do
134
+      let (:facts) do
135
+        facts.merge!(OSDefaults.get_facts())
136
+      end
137
+
138
+      it_configures 'glance-cache-logging'
133 139
     end
134
-
135
-    it_configures 'glance-cache-logging'
136
-  end
137
-
138
-  context 'on RedHat platforms' do
139
-    let :facts do
140
-       @default_facts.merge({ :osfamily => 'RedHat' })
141
-    end
142
-
143
-    it_configures 'glance-cache-logging'
144 140
   end
145
-
146 141
 end

+ 20
- 18
spec/classes/glance_cache_pruner_spec.rb View File

@@ -17,6 +17,9 @@ describe 'glance::cache::pruner' do
17 17
           :month       => '*',
18 18
           :weekday     => '*'
19 19
         )
20
+        is_expected.to contain_cron('glance-cache-pruner').with(
21
+          :require => "Package[#{platform_params[:api_package_name]}]"
22
+        )
20 23
       end
21 24
     end
22 25
 
@@ -46,25 +49,24 @@ describe 'glance::cache::pruner' do
46 49
     end
47 50
   end
48 51
 
49
-  context 'on Debian platforms' do
50
-    let :facts do
51
-      @default_facts.merge({
52
-        :osfamily       => 'Debian',
53
-      })
54
-    end
55
-    include_examples 'glance cache pruner'
56
-    it { is_expected.to contain_cron('glance-cache-pruner').with(:require     => 'Package[glance-api]')}
57
-  end
52
+  on_supported_os({
53
+    :supported_os   => OSDefaults.get_supported_os
54
+  }).each do |os,facts|
55
+    context "on #{os}" do
56
+      let (:facts) do
57
+        facts.merge!(OSDefaults.get_facts())
58
+      end
59
+
60
+      let(:platform_params) do
61
+        case facts[:osfamily]
62
+        when 'Debian'
63
+          { :api_package_name => 'glance-api' }
64
+        when 'RedHat'
65
+          { :api_package_name => 'openstack-glance' }
66
+        end
67
+      end
58 68
 
59
-  context 'on RedHat platforms' do
60
-    let :facts do
61
-      @default_facts.merge({
62
-        :osfamily               => 'RedHat',
63
-        :operatingsystemrelease => '7',
64
-      })
69
+      it_configures 'glance cache pruner'
65 70
     end
66
-    include_examples 'glance cache pruner'
67
-    it { is_expected.to contain_cron('glance-cache-pruner').with(:require     => 'Package[openstack-glance]')}
68 71
   end
69
-
70 72
 end

+ 8
- 15
spec/classes/glance_client_spec.rb View File

@@ -12,22 +12,15 @@ describe 'glance::client' do
12 12
     }
13 13
   end
14 14
 
15
-  context 'on Debian platforms' do
16
-    let :facts do
17
-      @default_facts.merge({
18
-        :osfamily       => 'Debian',
19
-      })
20
-    end
21
-    include_examples 'glance client'
22
-  end
15
+  on_supported_os({
16
+    :supported_os   => OSDefaults.get_supported_os
17
+  }).each do |os,facts|
18
+    context "on #{os}" do
19
+      let (:facts) do
20
+        facts.merge!(OSDefaults.get_facts())
21
+      end
23 22
 
24
-  context 'on RedHat platforms' do
25
-    let :facts do
26
-      @default_facts.merge({
27
-        :osfamily               => 'RedHat',
28
-        :operatingsystemrelease => '7',
29
-      })
23
+      it_configures 'glance client'
30 24
     end
31
-    include_examples 'glance client'
32 25
   end
33 26
 end

+ 63
- 57
spec/classes/glance_db_mysql_spec.rb View File

@@ -1,79 +1,85 @@
1 1
 require 'spec_helper'
2 2
 
3 3
 describe 'glance::db::mysql' do
4
-  let :facts do
5
-    @default_facts.merge({
6
-      :osfamily       => 'Debian',
7
-    })
8
-  end
9
-
10
-  let :pre_condition do
11
-    'include mysql::server'
12
-  end
13
-
14
-  describe "with default params" do
15
-    let :params do
16
-      {
17
-        :password => 'glancepass1',
18
-      }
4
+  shared_examples_for 'glance::db::mysql' do
5
+    let :pre_condition do
6
+      'include mysql::server'
19 7
     end
20 8
 
21
-    it { is_expected.to contain_openstacklib__db__mysql('glance').with(
22
-      :password_hash => '*41C910F70EB213CF4CB7B2F561B4995503C0A87B',
23
-      :charset       => 'utf8',
24
-      :collate       => 'utf8_general_ci',
25
-    )}
9
+    describe "with default params" do
10
+      let :params do
11
+        {
12
+          :password => 'glancepass1',
13
+        }
14
+      end
26 15
 
27
-  end
16
+      it { is_expected.to contain_openstacklib__db__mysql('glance').with(
17
+        :password_hash => '*41C910F70EB213CF4CB7B2F561B4995503C0A87B',
18
+        :charset       => 'utf8',
19
+        :collate       => 'utf8_general_ci',
20
+      )}
28 21
 
29
-  describe "overriding default params" do
30
-    let :params do
31
-      {
32
-        :password       => 'glancepass2',
33
-        :dbname         => 'glancedb2',
34
-        :charset        => 'utf8',
35
-      }
36 22
     end
37 23
 
38
-    it { is_expected.to contain_openstacklib__db__mysql('glance').with(
39
-      :password_hash => '*6F9A1CB9BD83EE06F3903BDFF9F4188764E694CA',
40
-      :dbname        => 'glancedb2',
41
-      :charset       => 'utf8'
42
-    )}
24
+    describe "overriding default params" do
25
+      let :params do
26
+        {
27
+          :password       => 'glancepass2',
28
+          :dbname         => 'glancedb2',
29
+          :charset        => 'utf8',
30
+        }
31
+      end
43 32
 
44
-  end
33
+      it { is_expected.to contain_openstacklib__db__mysql('glance').with(
34
+        :password_hash => '*6F9A1CB9BD83EE06F3903BDFF9F4188764E694CA',
35
+        :dbname        => 'glancedb2',
36
+        :charset       => 'utf8'
37
+      )}
45 38
 
46
-  describe "overriding allowed_hosts param to array" do
47
-    let :params do
48
-      {
49
-        :password       => 'glancepass2',
50
-        :dbname         => 'glancedb2',
51
-        :allowed_hosts  => ['127.0.0.1','%']
52
-      }
53 39
     end
54 40
 
55
-  end
41
+    describe "overriding allowed_hosts param to array" do
42
+      let :params do
43
+        {
44
+          :password       => 'glancepass2',
45
+          :dbname         => 'glancedb2',
46
+          :allowed_hosts  => ['127.0.0.1','%']
47
+        }
48
+      end
56 49
 
57
-  describe "overriding allowed_hosts param to string" do
58
-    let :params do
59
-      {
60
-        :password       => 'glancepass2',
61
-        :dbname         => 'glancedb2',
62
-        :allowed_hosts  => '192.168.1.1'
63
-      }
64 50
     end
65 51
 
66
-  end
52
+    describe "overriding allowed_hosts param to string" do
53
+      let :params do
54
+        {
55
+          :password       => 'glancepass2',
56
+          :dbname         => 'glancedb2',
57
+          :allowed_hosts  => '192.168.1.1'
58
+        }
59
+      end
67 60
 
68
-  describe "overriding allowed_hosts param equals to host param " do
69
-    let :params do
70
-      {
71
-        :password       => 'glancepass2',
72
-        :dbname         => 'glancedb2',
73
-        :allowed_hosts  => '127.0.0.1'
74
-      }
75 61
     end
76 62
 
63
+    describe "overriding allowed_hosts param equals to host param " do
64
+      let :params do
65
+        {
66
+          :password       => 'glancepass2',
67
+          :dbname         => 'glancedb2',
68
+          :allowed_hosts  => '127.0.0.1'
69
+        }
70
+      end
71
+    end
77 72
   end
78 73
 
74
+  on_supported_os({
75
+    :supported_os   => OSDefaults.get_supported_os
76
+  }).each do |os,facts|
77
+    context "on #{os}" do
78
+      let (:facts) do
79
+        facts.merge!(OSDefaults.get_facts())
80
+      end
81
+
82
+      it_configures 'glance::db::mysql'
83
+    end
84
+  end
79 85
 end

+ 13
- 34
spec/classes/glance_db_postgresql_spec.rb View File

@@ -2,21 +2,13 @@ require 'spec_helper'
2 2
 
3 3
 describe 'glance::db::postgresql' do
4 4
 
5
-  let :req_params do
6
-    { :password => 'pw' }
7
-  end
8
-
9
-  let :pre_condition do
10
-    'include postgresql::server'
11
-  end
5
+  shared_examples_for 'glance::db::postgresql' do
6
+    let :req_params do
7
+      { :password => 'pw' }
8
+    end
12 9
 
13
-  context 'on a RedHat osfamily' do
14
-    let :facts do
15
-      @default_facts.merge({
16
-        :osfamily                 => 'RedHat',
17
-        :operatingsystemrelease   => '7.0',
18
-        :concat_basedir => '/var/lib/puppet/concat'
19
-      })
10
+    let :pre_condition do
11
+      'include postgresql::server'
20 12
     end
21 13
 
22 14
     context 'with only required parameters' do
@@ -29,30 +21,17 @@ describe 'glance::db::postgresql' do
29 21
         :password => 'md56c7c03b193c2c1e0667bc5bd891703db'
30 22
       )}
31 23
     end
32
-
33 24
   end
34 25
 
35
-  context 'on a Debian osfamily' do
36
-    let :facts do
37
-      @default_facts.merge({
38
-        :operatingsystemrelease => '7.8',
39
-        :operatingsystem        => 'Debian',
40
-        :osfamily               => 'Debian',
41
-        :concat_basedir => '/var/lib/puppet/concat'
42
-      })
43
-    end
44
-
45
-    context 'with only required parameters' do
46
-      let :params do
47
-        req_params
26
+  on_supported_os({
27
+    :supported_os   => OSDefaults.get_supported_os
28
+  }).each do |os,facts|
29
+    context "on #{os}" do
30
+      let (:facts) do
31
+        facts.merge!(OSDefaults.get_facts({ :concat_basedir => '/var/lib/puppet/concat' }))
48 32
       end
49 33
 
50
-      it { is_expected.to contain_postgresql__server__db('glance').with(
51
-        :user     => 'glance',
52
-        :password => 'md56c7c03b193c2c1e0667bc5bd891703db'
53
-      )}
34
+      it_configures 'glance::db::postgresql'
54 35
     end
55
-
56 36
   end
57
-
58 37
 end

+ 8
- 23
spec/classes/glance_db_sync_spec.rb View File

@@ -30,33 +30,18 @@ describe 'glance::db::sync' do
30 30
       )
31 31
       }
32 32
     end
33
-
34
-
35 33
   end
36 34
 
37
-  context 'on a RedHat osfamily' do
38
-    let :facts do
39
-      @default_facts.merge({
40
-        :osfamily                 => 'RedHat',
41
-        :operatingsystemrelease   => '7.0',
42
-        :concat_basedir => '/var/lib/puppet/concat'
43
-      })
44
-    end
45
-
46
-    it_configures 'glance-dbsync'
47
-  end
35
+  on_supported_os({
36
+    :supported_os   => OSDefaults.get_supported_os
37
+  }).each do |os,facts|
38
+    context "on #{os}" do
39
+      let (:facts) do
40
+        facts.merge!(OSDefaults.get_facts({ :concat_basedir => '/var/lib/puppet/concat' }))
41
+      end
48 42
 
49
-  context 'on a Debian osfamily' do
50
-    let :facts do
51
-      @default_facts.merge({
52
-        :operatingsystemrelease => '7.8',
53
-        :operatingsystem        => 'Debian',
54
-        :osfamily               => 'Debian',
55
-        :concat_basedir => '/var/lib/puppet/concat'
56
-      })
43
+      it_configures 'glance-dbsync'
57 44
     end
58
-
59
-    it_configures 'glance-dbsync'
60 45
   end
61 46
 
62 47
 end

+ 154
- 147
spec/classes/glance_keystone_auth_spec.rb View File

@@ -2,189 +2,196 @@ require 'spec_helper'
2 2
 
3 3
 describe 'glance::keystone::auth' do
4 4
 
5
-  describe 'with defaults' do
5
+  shared_examples_for 'glance::keystone::auth' do
6
+    describe 'with defaults' do
7
+
8
+      let :params do
9
+        {:password => 'pass'}
10
+      end
11
+
12
+      it { is_expected.to contain_keystone_user('glance').with(
13
+        :ensure   => 'present',
14
+        :password => 'pass'
15
+      )}
16
+
17
+      it { is_expected.to contain_keystone_user_role('glance@services').with(
18
+        :ensure => 'present',
19
+        :roles  => ['admin']
20
+      ) }
21
+
22
+      it { is_expected.to contain_keystone_service('Image Service::image').with(
23
+        :ensure      => 'present',
24
+        :description => 'OpenStack Image Service'
25
+      ) }
26
+
27
+      it { is_expected.to contain_keystone_endpoint('RegionOne/Image Service::image').with(
28
+        :ensure       => 'present',
29
+        :public_url   => 'http://127.0.0.1:9292',
30
+        :admin_url    => 'http://127.0.0.1:9292',
31
+        :internal_url => 'http://127.0.0.1:9292'
32
+      )}
6 33
 
7
-    let :params do
8
-      {:password => 'pass'}
9 34
     end
10 35
 
11
-    it { is_expected.to contain_keystone_user('glance').with(
12
-      :ensure   => 'present',
13
-      :password => 'pass'
14
-    )}
36
+    describe 'when auth_type, password, and service_type are overridden' do
15 37
 
16
-    it { is_expected.to contain_keystone_user_role('glance@services').with(
17
-      :ensure => 'present',
18
-      :roles  => ['admin']
19
-    ) }
38
+      let :params do
39
+        {
40
+          :auth_name    => 'glancey',
41
+          :password     => 'password',
42
+          :service_type => 'imagey'
43
+        }
44
+      end
20 45
 
21
-    it { is_expected.to contain_keystone_service('Image Service::image').with(
22
-      :ensure      => 'present',
23
-      :description => 'OpenStack Image Service'
24
-    ) }
46
+      it { is_expected.to contain_keystone_user('glancey').with(
47
+        :ensure   => 'present',
48
+        :password => 'password'
49
+      )}
25 50
 
26
-    it { is_expected.to contain_keystone_endpoint('RegionOne/Image Service::image').with(
27
-      :ensure       => 'present',
28
-      :public_url   => 'http://127.0.0.1:9292',
29
-      :admin_url    => 'http://127.0.0.1:9292',
30
-      :internal_url => 'http://127.0.0.1:9292'
31
-    )}
51
+      it { is_expected.to contain_keystone_user_role('glancey@services').with(
52
+        :ensure => 'present',
53
+        :roles  => ['admin']
54
+      ) }
32 55
 
33
-  end
34
-
35
-  describe 'when auth_type, password, and service_type are overridden' do
56
+      it { is_expected.to contain_keystone_service('Image Service::imagey').with(
57
+        :ensure      => 'present',
58
+        :description => 'OpenStack Image Service'
59
+      ) }
36 60
 
37
-    let :params do
38
-      {
39
-        :auth_name    => 'glancey',
40
-        :password     => 'password',
41
-        :service_type => 'imagey'
42
-      }
43 61
     end
44 62
 
45
-    it { is_expected.to contain_keystone_user('glancey').with(
46
-      :ensure   => 'present',
47
-      :password => 'password'
48
-    )}
49
-
50
-    it { is_expected.to contain_keystone_user_role('glancey@services').with(
51
-      :ensure => 'present',
52
-      :roles  => ['admin']
53
-    ) }
54
-
55
-    it { is_expected.to contain_keystone_service('Image Service::imagey').with(
56
-      :ensure      => 'present',
57
-      :description => 'OpenStack Image Service'
58
-    ) }
59
-
60
-  end
61
-
62
-  describe 'when overriding endpoint URLs' do
63
-    let :params do
64
-      { :password         => 'passw0rd',
65
-        :region            => 'RegionTwo',
66
-        :public_url       => 'https://10.10.10.10:81/v2',
67
-        :internal_url     => 'https://10.10.10.11:81/v2',
68
-        :admin_url        => 'https://10.10.10.12:81/v2' }
63
+    describe 'when overriding endpoint URLs' do
64
+      let :params do
65
+        { :password         => 'passw0rd',
66
+          :region            => 'RegionTwo',
67
+          :public_url       => 'https://10.10.10.10:81/v2',
68
+          :internal_url     => 'https://10.10.10.11:81/v2',
69
+          :admin_url        => 'https://10.10.10.12:81/v2' }
70
+      end
71
+
72
+      it { is_expected.to contain_keystone_endpoint('RegionTwo/Image Service::image').with(
73
+        :ensure       => 'present',
74
+        :public_url   => 'https://10.10.10.10:81/v2',
75
+        :internal_url => 'https://10.10.10.11:81/v2',
76
+        :admin_url    => 'https://10.10.10.12:81/v2'
77
+      ) }
69 78
     end
70 79
 
71
-    it { is_expected.to contain_keystone_endpoint('RegionTwo/Image Service::image').with(
72
-      :ensure       => 'present',
73
-      :public_url   => 'https://10.10.10.10:81/v2',
74
-      :internal_url => 'https://10.10.10.11:81/v2',
75
-      :admin_url    => 'https://10.10.10.12:81/v2'
76
-    ) }
77
-  end
80
+    describe 'with deprecated endpoints parameters' do
81
+
82
+      let :params do
83
+        {
84
+          :password          => 'pass',
85
+          :public_address    => '10.0.0.1',
86
+          :admin_address     => '10.0.0.2',
87
+          :internal_address  => '10.0.0.3',
88
+          :port              => '9393',
89
+          :region            => 'RegionTwo',
90
+          :public_protocol   => 'https',
91
+          :admin_protocol    => 'https',
92
+          :internal_protocol => 'https'
93
+        }
94
+      end
95
+
96
+      it { is_expected.to contain_keystone_endpoint('RegionTwo/Image Service::image').with(
97
+        :ensure       => 'present',
98
+        :public_url   => 'https://10.0.0.1:9393',
99
+        :admin_url    => 'https://10.0.0.2:9393',
100
+        :internal_url => 'https://10.0.0.3:9393'
101
+      )}
78 102
 
79
-  describe 'with deprecated endpoints parameters' do
80
-
81
-    let :params do
82
-      {
83
-        :password          => 'pass',
84
-        :public_address    => '10.0.0.1',
85
-        :admin_address     => '10.0.0.2',
86
-        :internal_address  => '10.0.0.3',
87
-        :port              => '9393',
88
-        :region            => 'RegionTwo',
89
-        :public_protocol   => 'https',
90
-        :admin_protocol    => 'https',
91
-        :internal_protocol => 'https'
92
-      }
93 103
     end
94 104
 
95
-    it { is_expected.to contain_keystone_endpoint('RegionTwo/Image Service::image').with(
96
-      :ensure       => 'present',
97
-      :public_url   => 'https://10.0.0.1:9393',
98
-      :admin_url    => 'https://10.0.0.2:9393',
99
-      :internal_url => 'https://10.0.0.3:9393'
100
-    )}
105
+    describe 'when endpoint is not set' do
101 106
 
102
-  end
107
+      let :params do
108
+        {
109
+          :configure_endpoint => false,
110
+          :password         => 'pass',
111
+        }
112
+      end
103 113
 
104
-  describe 'when endpoint is not set' do
105
-
106
-    let :params do
107
-      {
108
-        :configure_endpoint => false,
109
-        :password         => 'pass',
110
-      }
114
+      it { is_expected.to_not contain_keystone_endpoint('RegionOne/Image Service::image') }
111 115
     end
112 116
 
113
-    it { is_expected.to_not contain_keystone_endpoint('RegionOne/Image Service::image') }
114
-  end
117
+    describe 'when disabling user configuration' do
118
+      let :params do
119
+        {
120
+          :configure_user => false,
121
+          :password       => 'pass',
122
+        }
123
+      end
115 124
 
116
-  describe 'when disabling user configuration' do
117
-    let :params do
118
-      {
119
-        :configure_user => false,
120
-        :password       => 'pass',
121
-      }
125
+      it { is_expected.to_not contain_keystone_user('glance') }
126
+
127
+      it { is_expected.to contain_keystone_user_role('glance@services') }
128
+
129
+      it { is_expected.to contain_keystone_service('Image Service::image').with(
130
+        :ensure      => 'present',
131
+        :description => 'OpenStack Image Service'
132
+      ) }
122 133
     end
123 134
 
124
-    it { is_expected.to_not contain_keystone_user('glance') }
135
+    describe 'when disabling user and user role configuration' do
136
+      let :params do
137
+        {
138
+          :configure_user      => false,
139
+          :configure_user_role => false,
140
+          :password            => 'pass',
141
+        }
142
+      end
125 143
 
126
-    it { is_expected.to contain_keystone_user_role('glance@services') }
144
+      it { is_expected.to_not contain_keystone_user('glance') }
127 145
 
128
-    it { is_expected.to contain_keystone_service('Image Service::image').with(
129
-      :ensure      => 'present',
130
-      :description => 'OpenStack Image Service'
131
-    ) }
132
-  end
146
+      it { is_expected.to_not contain_keystone_user_role('glance@services') }
133 147
 
134
-  describe 'when disabling user and user role configuration' do
135
-    let :params do
136
-      {
137
-        :configure_user      => false,
138
-        :configure_user_role => false,
139
-        :password            => 'pass',
140
-      }
148
+      it { is_expected.to contain_keystone_service('Image Service::image').with(
149
+        :ensure      => 'present',
150
+        :description => 'OpenStack Image Service'
151
+      ) }
141 152
     end
142 153
 
143
-    it { is_expected.to_not contain_keystone_user('glance') }
154
+    describe 'when configuring glance-api and the keystone endpoint' do
155
+      let :pre_condition do
156
+        "class { 'glance::api': keystone_password => 'test' }"
157
+      end
144 158
 
145
-    it { is_expected.to_not contain_keystone_user_role('glance@services') }
159
+      let :params do
160
+        {
161
+          :password => 'test',
162
+          :configure_endpoint => true
163
+        }
164
+      end
146 165
 
147
-    it { is_expected.to contain_keystone_service('Image Service::image').with(
148
-      :ensure      => 'present',
149
-      :description => 'OpenStack Image Service'
150
-    ) }
151
-  end
166
+      it { is_expected.to contain_keystone_endpoint('RegionOne/Image Service::image').with_notify(["Service[glance-api]"]) }
167
+      end
152 168
 
153
-  describe 'when configuring glance-api and the keystone endpoint' do
154
-    let :pre_condition do
155
-      "class { 'glance::api': keystone_password => 'test' }"
156
-    end
169
+    describe 'when overriding service name' do
157 170
 
158
-    let :facts do
159
-      @default_facts.merge({
160
-        :osfamily       => 'Debian',
161
-      })
162
-    end
171
+      let :params do
172
+        {
173
+          :service_name => 'glance_service',
174
+          :password     => 'pass'
175
+        }
176
+      end
163 177
 
164
-    let :params do
165
-      {
166
-        :password => 'test',
167
-        :configure_endpoint => true
168
-      }
169
-    end
178
+      it { is_expected.to contain_keystone_user('glance') }
179
+      it { is_expected.to contain_keystone_user_role('glance@services') }
180
+      it { is_expected.to contain_keystone_service('glance_service::image') }
181
+      it { is_expected.to contain_keystone_endpoint('RegionOne/glance_service::image') }
170 182
 
171
-    it { is_expected.to contain_keystone_endpoint('RegionOne/Image Service::image').with_notify(["Service[glance-api]"]) }
172 183
     end
184
+  end
173 185
 
174
-  describe 'when overriding service name' do
186
+  on_supported_os({
187
+    :supported_os   => OSDefaults.get_supported_os
188
+  }).each do |os,facts|
189
+    context "on #{os}" do
190
+      let (:facts) do
191
+        facts.merge!(OSDefaults.get_facts())
192
+      end
175 193
 
176
-    let :params do
177
-      {
178
-        :service_name => 'glance_service',
179
-        :password     => 'pass'
180
-      }
194
+      it_configures 'glance::keystone::auth'
181 195
     end
182
-
183
-    it { is_expected.to contain_keystone_user('glance') }
184
-    it { is_expected.to contain_keystone_user_role('glance@services') }
185
-    it { is_expected.to contain_keystone_service('glance_service::image') }
186
-    it { is_expected.to contain_keystone_endpoint('RegionOne/glance_service::image') }
187
-
188 196
   end
189
-
190 197
 end

+ 148
- 138
spec/classes/glance_notify_rabbitmq_spec.rb View File

@@ -1,165 +1,175 @@
1 1
 require 'spec_helper'
2 2
 describe 'glance::notify::rabbitmq' do
3
-  let :facts do
4
-    @default_facts.merge({
5
-     :osfamily       => 'Debian',
6
-    })
7
-  end
8 3
 
9
-  let :pre_condition do
10
-    'class { "glance::api": keystone_password => "pass" }'
11
-  end
4
+  shared_examples_for 'glance::notify::rabbitmq' do
5
+    let :pre_condition do
6
+      'class { "glance::api": keystone_password => "pass" }'
7
+    end
12 8
 
13
-  describe 'when defaults with rabbit pass specified' do
14
-    let :params do
15
-      {:rabbit_password => 'pass'}
9
+    describe 'when defaults with rabbit pass specified' do
10
+      let :params do
11
+        {:rabbit_password => 'pass'}
12
+      end
13
+      it { is_expected.to contain_glance_api_config('DEFAULT/notification_driver').with_value('messaging') }
14
+      it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_password').with_value('pass') }
15
+      it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_password').with_value(params[:rabbit_password]).with_secret(true) }
16
+      it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_userid').with_value('guest') }
17
+      it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_host').with_value('localhost') }
18
+      it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_port').with_value('5672') }
19
+      it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_hosts').with_value('localhost:5672') }
20
+      it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_ha_queues').with_value('false') }
21
+      it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/amqp_durable_queues').with_value('false') }
22
+      it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_virtual_host').with_value('/') }
23
+      it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_notification_exchange').with_value('glance') }
24
+      it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_notification_topic').with_value('notifications') }
25
+      it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/heartbeat_timeout_threshold').with_value('0') }
26
+      it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/heartbeat_rate').with_value('2') }
27
+      it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/kombu_reconnect_delay').with_value('<SERVICE DEFAULT>') }
16 28
     end
17
-    it { is_expected.to contain_glance_api_config('DEFAULT/notification_driver').with_value('messaging') }
18
-    it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_password').with_value('pass') }
19
-    it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_password').with_value(params[:rabbit_password]).with_secret(true) }
20
-    it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_userid').with_value('guest') }
21
-    it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_host').with_value('localhost') }
22
-    it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_port').with_value('5672') }
23
-    it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_hosts').with_value('localhost:5672') }
24
-    it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_ha_queues').with_value('false') }
25
-    it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/amqp_durable_queues').with_value('false') }
26
-    it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_virtual_host').with_value('/') }
27
-    it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_notification_exchange').with_value('glance') }
28
-    it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_notification_topic').with_value('notifications') }
29
-    it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/heartbeat_timeout_threshold').with_value('0') }
30
-    it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/heartbeat_rate').with_value('2') }
31
-    it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/kombu_reconnect_delay').with_value('<SERVICE DEFAULT>') }
32
-  end
33 29
 
34
-  describe 'when passing params and use ssl' do
35
-    let :params do
36
-      {
37
-        :rabbit_password        => 'pass',
38
-        :rabbit_userid          => 'guest2',
39
-        :rabbit_host            => 'localhost2',
40
-        :rabbit_port            => '5673',
41
-        :rabbit_use_ssl         => true,
42
-        :rabbit_durable_queues  => true,
43
-        :kombu_reconnect_delay  => '5.0'
44
-      }
45
-      it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_userid').with_value('guest2') }
46
-      it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_host').with_value('localhost2') }
47
-      it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_port').with_value('5673') }
48
-      it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_use_ssl').with_value('true') }
30
+    describe 'when passing params and use ssl' do
31
+      let :params do
32
+        {
33
+          :rabbit_password        => 'pass',
34
+          :rabbit_userid          => 'guest2',
35
+          :rabbit_host            => 'localhost2',
36
+          :rabbit_port            => '5673',
37
+          :rabbit_use_ssl         => true,
38
+          :rabbit_durable_queues  => true,
39
+          :kombu_reconnect_delay  => '5.0'
40
+        }
41
+        it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_userid').with_value('guest2') }
42
+        it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_host').with_value('localhost2') }
43
+        it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_port').with_value('5673') }
44
+        it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_use_ssl').with_value('true') }
45
+        it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/kombu_ssl_ca_certs').with_ensure('absent') }
46
+        it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/kombu_ssl_certfile').with_ensure('absent') }
47
+        it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/kombu_ssl_keyfile').with_ensure('absent') }
48
+        it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/kombu_ssl_version').with_value('TLSv1') }
49
+        it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_durable_queues').with_value('true') }
50
+        it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/kombu_reconnect_delay').with_value('5.0') }
51
+      end
52
+    end
53
+
54
+    describe 'with rabbit ssl cert parameters' do
55
+      let :params do
56
+        {
57
+          :rabbit_password        => 'pass',
58
+          :rabbit_use_ssl     => 'true',
59
+          :kombu_ssl_ca_certs => '/etc/ca.cert',
60
+          :kombu_ssl_certfile => '/etc/certfile',
61
+          :kombu_ssl_keyfile  => '/etc/key',
62
+          :kombu_ssl_version  => 'TLSv1',
63
+        }
64
+      end
65
+      it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_use_ssl').with_value(true) }
66
+      it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/kombu_ssl_ca_certs').with_value('/etc/ca.cert') }
67
+      it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/kombu_ssl_certfile').with_value('/etc/certfile') }
68
+      it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/kombu_ssl_keyfile').with_value('/etc/key') }
69
+      it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/kombu_ssl_version').with_value('TLSv1') }
70
+    end
71
+
72
+    describe 'with rabbit ssl disabled' do
73
+      let :params do
74
+        {
75
+          :rabbit_password    => 'pass',
76
+          :rabbit_use_ssl     => false,
77
+          :kombu_ssl_ca_certs => 'undef',
78
+          :kombu_ssl_certfile => 'undef',
79
+          :kombu_ssl_keyfile  => 'undef',
80
+          :kombu_ssl_version  => 'TLSv1',
81
+        }
82
+      end
83
+
84
+      it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_use_ssl').with_value('false') }
49 85
       it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/kombu_ssl_ca_certs').with_ensure('absent') }
50 86
       it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/kombu_ssl_certfile').with_ensure('absent') }
51 87
       it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/kombu_ssl_keyfile').with_ensure('absent') }
52
-      it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/kombu_ssl_version').with_value('TLSv1') }
53
-      it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_durable_queues').with_value('true') }
54
-      it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/kombu_reconnect_delay').with_value('5.0') }
88
+      it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/kombu_ssl_version').with_ensure('absent') }
55 89
     end
56
-  end
57 90
 
58
-  describe 'with rabbit ssl cert parameters' do
59
-    let :params do
60
-      {
61
-        :rabbit_password        => 'pass',
62
-        :rabbit_use_ssl     => 'true',
63
-        :kombu_ssl_ca_certs => '/etc/ca.cert',
64
-        :kombu_ssl_certfile => '/etc/certfile',
65
-        :kombu_ssl_keyfile  => '/etc/key',
66
-        :kombu_ssl_version  => 'TLSv1',
67
-      }
91
+    describe 'when passing params for single rabbit host' do
92
+      let :params do
93
+        {
94
+          :rabbit_password        => 'pass',
95
+          :rabbit_userid          => 'guest2',
96
+          :rabbit_host            => 'localhost2',
97
+          :rabbit_port            => '5673',
98
+          :rabbit_use_ssl         => true,
99
+          :rabbit_durable_queues  => true,
100
+        }
101
+      end
102
+      it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_userid').with_value('guest2') }
103
+      it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_host').with_value('localhost2') }
104
+      it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_port').with_value('5673') }
105
+      it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_hosts').with_value('localhost2:5673') }
106
+      it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_use_ssl').with_value('true') }
107
+      it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/amqp_durable_queues').with_value('true') }
68 108
     end
69
-    it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_use_ssl').with_value(true) }
70
-    it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/kombu_ssl_ca_certs').with_value('/etc/ca.cert') }
71
-    it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/kombu_ssl_certfile').with_value('/etc/certfile') }
72
-    it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/kombu_ssl_keyfile').with_value('/etc/key') }
73
-    it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/kombu_ssl_version').with_value('TLSv1') }
74
-  end
75 109
 
76
-  describe 'with rabbit ssl disabled' do
77
-    let :params do
78
-      {
79
-        :rabbit_password    => 'pass',
80
-        :rabbit_use_ssl     => false,
81
-        :kombu_ssl_ca_certs => 'undef',
82
-        :kombu_ssl_certfile => 'undef',
83
-        :kombu_ssl_keyfile  => 'undef',
84
-        :kombu_ssl_version  => 'TLSv1',
85
-      }
110
+    describe 'when passing params for multiple rabbit hosts' do
111
+      let :params do
112
+        {
113
+          :rabbit_password => 'pass',
114
+          :rabbit_userid   => 'guest3',
115
+          :rabbit_hosts    => ['nonlocalhost3:5673', 'nonlocalhost4:5673']
116
+        }
117
+      end
118
+      it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_userid').with_value('guest3') }
119
+      it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_hosts').with_value(
120
+                                            'nonlocalhost3:5673,nonlocalhost4:5673') }
121
+      it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_ha_queues').with_value('true') }
122
+      it { is_expected.to_not contain_glance_api_config('oslo_messaging_rabbit/rabbit_port') }
123
+      it { is_expected.to_not contain_glance_api_config('oslo_messaging_rabbit/rabbit_host') }
86 124
     end
87 125
 
88
-    it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_use_ssl').with_value('false') }
89
-    it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/kombu_ssl_ca_certs').with_ensure('absent') }
90
-    it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/kombu_ssl_certfile').with_ensure('absent') }
91
-    it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/kombu_ssl_keyfile').with_ensure('absent') }
92
-    it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/kombu_ssl_version').with_ensure('absent') }
93
-  end
94
-
95
-  describe 'when passing params for single rabbit host' do
96
-    let :params do
97
-      {
98
-        :rabbit_password        => 'pass',
99
-        :rabbit_userid          => 'guest2',
100
-        :rabbit_host            => 'localhost2',
101
-        :rabbit_port            => '5673',
102
-        :rabbit_use_ssl         => true,
103
-        :rabbit_durable_queues  => true,
104
-      }
105
-    end
106
-    it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_userid').with_value('guest2') }
107
-    it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_host').with_value('localhost2') }
108
-    it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_port').with_value('5673') }
109
-    it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_hosts').with_value('localhost2:5673') }
110
-    it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_use_ssl').with_value('true') }
111
-    it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/amqp_durable_queues').with_value('true') }
112
-  end
126
+    describe 'a single rabbit_host with enable ha queues' do
127
+      let :params do
128
+         {
129
+          :rabbit_password  => 'pass',
130
+          :rabbit_userid    => 'guest3',
131
+          :rabbit_ha_queues => true,
132
+         }
133
+      end
113 134
 
114
-  describe 'when passing params for multiple rabbit hosts' do
115
-    let :params do
116
-      {
117
-        :rabbit_password => 'pass',
118
-        :rabbit_userid   => 'guest3',
119
-        :rabbit_hosts    => ['nonlocalhost3:5673', 'nonlocalhost4:5673']
120
-      }
135
+      it 'should contain rabbit_ha_queues' do
136
+        is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_ha_queues').with_value('true')
137
+      end
121 138
     end
122
-    it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_userid').with_value('guest3') }
123
-    it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_hosts').with_value(
124
-                                          'nonlocalhost3:5673,nonlocalhost4:5673') }
125
-    it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_ha_queues').with_value('true') }
126
-    it { is_expected.to_not contain_glance_api_config('oslo_messaging_rabbit/rabbit_port') }
127
-    it { is_expected.to_not contain_glance_api_config('oslo_messaging_rabbit/rabbit_host') }
128
-  end
129 139
 
130
-  describe 'a single rabbit_host with enable ha queues' do
131
-    let :params do
132
-       {
133
-        :rabbit_password  => 'pass',
134
-        :rabbit_userid    => 'guest3',
135
-        :rabbit_ha_queues => true,
136
-       }
140
+    describe 'when passing params for rabbitmq heartbeat' do
141
+      let :params do
142
+        {
143
+          :rabbit_password                    => 'pass',
144
+          :rabbit_heartbeat_timeout_threshold => '60',
145
+          :rabbit_heartbeat_rate              => '10',
146
+        }
147
+      end
148
+      it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/heartbeat_timeout_threshold').with_value('60') }
149
+      it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/heartbeat_rate').with_value('10') }
137 150
     end
138 151
 
139
-    it 'should contain rabbit_ha_queues' do
140
-      is_expected.to contain_glance_api_config('oslo_messaging_rabbit/rabbit_ha_queues').with_value('true')
152
+    describe 'when using deprecated params' do
153
+      let :params do
154
+        {
155
+          :rabbit_durable_queues  => true,
156
+          :rabbit_password        => 'pass'
157
+        }
158
+      end
159
+      it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/amqp_durable_queues').with_value('true') }
141 160
     end
142 161
   end
143 162
 
144
-  describe 'when passing params for rabbitmq heartbeat' do
145
-    let :params do
146
-      {
147
-        :rabbit_password                    => 'pass',
148
-        :rabbit_heartbeat_timeout_threshold => '60',
149
-        :rabbit_heartbeat_rate              => '10',
150
-      }
151
-    end
152
-    it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/heartbeat_timeout_threshold').with_value('60') }
153
-    it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/heartbeat_rate').with_value('10') }
154
-  end
155 163
 
156
-  describe 'when using deprecated params' do
157
-    let :params do
158
-      {
159
-        :rabbit_durable_queues  => true,
160
-        :rabbit_password        => 'pass'
161
-      }
164
+  on_supported_os({
165
+    :supported_os   => OSDefaults.get_supported_os
166
+  }).each do |os,facts|
167
+    context "on #{os}" do
168
+      let (:facts) do
169
+        facts.merge!(OSDefaults.get_facts())
170
+      end
171
+
172
+      it_configures 'glance::notify::rabbitmq'
162 173
     end
163
-    it { is_expected.to contain_glance_api_config('oslo_messaging_rabbit/amqp_durable_queues').with_value('true') }
164 174
   end
165 175
 end

+ 8
- 16
spec/classes/glance_policy_spec.rb View File

@@ -23,23 +23,15 @@ describe 'glance::policy' do
23 23
     end
24 24
   end
25 25
 
26
-  context 'on Debian platforms' do
27
-    let :facts do
28
-      @default_facts.merge({
29
-        :osfamily       => 'Debian',
30
-      })
31
-    end
32
-
33
-    it_configures 'glance policies'
34
-  end
26
+  on_supported_os({
27
+    :supported_os   => OSDefaults.get_supported_os
28
+  }).each do |os,facts|
29
+    context "on #{os}" do
30
+      let (:facts) do
31
+        facts.merge!(OSDefaults.get_facts())
32
+      end
35 33
 
36
-  context 'on RedHat platforms' do
37
-    let :facts do
38
-      @default_facts.merge({
39
-        :osfamily => 'RedHat',
40
-      })
34
+      it_configures 'glance policies'
41 35
     end
42
-
43
-    it_configures 'glance policies'
44 36
   end
45 37
 end

+ 17
- 18
spec/classes/glance_registry_db_spec.rb View File

@@ -52,14 +52,8 @@ describe 'glance::registry::db' do
52 52
 
53 53
   end
54 54
 
55
-  context 'on Debian platforms' do
56
-    let :facts do
57
-      @default_facts.merge({ :osfamily => 'Debian' })
58
-    end
59
-
60
-    it_configures 'glance::registry::db'
61
-
62
-   context 'using pymysql driver' do
55
+  shared_examples_for 'glance::registry::db Debian' do
56
+    context 'using pymysql driver' do
63 57
       let :params do
64 58
         { :database_connection     => 'mysql+pymysql://glance_registry:glance@localhost/glance', }
65 59
       end
@@ -74,16 +68,7 @@ describe 'glance::registry::db' do
74 68
     end
75 69
   end
76 70
 
77
-  context 'on Redhat platforms' do
78
-    let :facts do
79
-      @default_facts.merge({
80
-        :osfamily               => 'RedHat',
81
-        :operatingsystemrelease => '7',
82
-      })
83
-    end
84
-
85
-    it_configures 'glance::registry::db'
86
-
71
+  shared_examples_for 'glance::registry::db RedHat' do
87 72
     context 'using pymysql driver' do
88 73
       let :params do
89 74
         { :database_connection     => 'mysql+pymysql://glance_registry:glance@localhost/glance', }
@@ -93,5 +78,19 @@ describe 'glance::registry::db' do
93 78
     end
94 79
   end
95 80
 
81
+
82
+  on_supported_os({
83
+    :supported_os   => OSDefaults.get_supported_os
84
+  }).each do |os,facts|
85
+    context "on #{os}" do
86
+      let (:facts) do
87
+        facts.merge!(OSDefaults.get_facts())
88
+      end
89
+
90
+      it_configures 'glance::registry::db'
91
+      it_configures "glance::registry::db #{facts[:osfamily]}"
92
+    end
93
+  end
94
+
96 95
 end
97 96
 

+ 9
- 18
spec/classes/glance_registry_logging_spec.rb View File

@@ -127,24 +127,15 @@ describe 'glance::registry::logging' do
127 127
       }
128 128
   end
129 129
 
130
-  context 'on Debian platforms' do
131
-    let :facts do
132
-      @default_facts.merge({
133
-        :osfamily       => 'Debian',
134
-      })
130
+  on_supported_os({
131
+    :supported_os   => OSDefaults.get_supported_os
132
+  }).each do |os,facts|
133
+    context "on #{os}" do
134
+      let (:facts) do
135
+        facts.merge!(OSDefaults.get_facts())
136
+      end
137
+
138
+      it_configures 'glance-registry-logging'
135 139
     end
136
-
137
-    it_configures 'glance-registry-logging'
138
-  end
139
-
140
-  context 'on RedHat platforms' do
141
-    let :facts do
142
-      @default_facts.merge({
143
-        :osfamily => 'RedHat',
144
-      })
145
-    end
146
-
147
-    it_configures 'glance-registry-logging'
148 140
   end
149
-
150 141
 end

+ 153
- 158
spec/classes/glance_registry_spec.rb View File

@@ -1,13 +1,5 @@
1 1
 
2 2
 describe 'glance::registry' do
3
-
4
-  let :facts do
5
-    @default_facts.merge({
6
-     :osfamily       => 'Debian',
7
-     :processorcount => '7',
8
-    })
9
-  end
10
-
11 3
   let :default_params do
12 4
     {
13 5
       :verbose                => false,
@@ -35,178 +27,174 @@ describe 'glance::registry' do
35 27
     }
36 28
   end
37 29
 
38
-  [
39
-    {:keystone_password => 'ChangeMe'},
40
-    {
41
-      :bind_host              => '127.0.0.1',
42
-      :bind_port              => '9111',
43
-      :workers                => '5',
44
-      :enabled                => false,
45
-      :auth_type              => 'keystone',
46
-      :auth_uri               => 'http://127.0.0.1:5000/v2.0',
47
-      :identity_uri           => 'http://127.0.0.1:35357/v2.0',
48
-      :keystone_tenant        => 'admin',
49
-      :keystone_user          => 'admin',
50
-      :keystone_password      => 'ChangeMe',
51
-      :sync_db                => false,
52
-      :os_region_name         => 'RegionOne2',
53
-      :signing_dir            => '/path/to/dir',
54
-      :token_cache_time       => '300',
55
-    }
56
-  ].each do |param_set|
30
+  shared_examples_for 'glance::registry' do
31
+    [
32
+      {:keystone_password => 'ChangeMe'},
33
+      {
34
+        :bind_host              => '127.0.0.1',
35
+        :bind_port              => '9111',
36
+        :workers                => '5',
37
+        :enabled                => false,
38
+        :auth_type              => 'keystone',
39
+        :auth_uri               => 'http://127.0.0.1:5000/v2.0',
40
+        :identity_uri           => 'http://127.0.0.1:35357/v2.0',
41
+        :keystone_tenant        => 'admin',
42
+        :keystone_user          => 'admin',
43
+        :keystone_password      => 'ChangeMe',
44
+        :sync_db                => false,
45
+        :os_region_name         => 'RegionOne2',
46
+        :signing_dir            => '/path/to/dir',
47
+        :token_cache_time       => '300',
48
+      }
49
+    ].each do |param_set|
57 50
 
58
-    describe "when #{param_set == {:keystone_password => 'ChangeMe'} ? "using default" : "specifying"} class parameters" do
59
-      let :param_hash do
60
-        default_params.merge(param_set)
61
-      end
51
+      describe "when #{param_set == {:keystone_password => 'ChangeMe'} ? "using default" : "specifying"} class parameters" do
52
+        let :param_hash do
53
+          default_params.merge(param_set)
54
+        end
62 55
 
63
-      let :params do
64
-        param_set
65
-      end
56
+        let :params do
57
+          param_set
58
+        end
66 59
 
67
-      it { is_expected.to contain_class 'glance::registry' }
68
-      it { is_expected.to contain_class 'glance::registry::db' }
69
-      it { is_expected.to contain_class 'glance::registry::logging' }
60
+        it { is_expected.to contain_class 'glance::registry' }
61
+        it { is_expected.to contain_class 'glance::registry::db' }
62
+        it { is_expected.to contain_class 'glance::registry::logging' }
63
+
64
+        it { is_expected.to contain_service('glance-registry').with(
65
+            'ensure'     => (param_hash[:manage_service] && param_hash[:enabled]) ? 'running' : 'stopped',
66
+            'enable'     => param_hash[:enabled],
67
+            'hasstatus'  => true,
68
+            'hasrestart' => true,
69
+            'subscribe'  => 'File[/etc/glance/glance-registry.conf]',
70
+            'require'    => 'Class[Glance]',
71
+            'tag'        => 'glance-service',
72
+        )}
70 73
 
71
-      it { is_expected.to contain_service('glance-registry').with(
72
-          'ensure'     => (param_hash[:manage_service] && param_hash[:enabled]) ? 'running' : 'stopped',
73
-          'enable'     => param_hash[:enabled],
74
-          'hasstatus'  => true,
75
-          'hasrestart' => true,
76
-          'subscribe'  => 'File[/etc/glance/glance-registry.conf]',
77
-          'require'    => 'Class[Glance]',
78
-          'tag'        => 'glance-service',
79
-      )}
80
-
81
-      it 'is_expected.to not sync the db if sync_db is set to false' do
82
-
83
-        if !param_hash[:sync_db]
84
-          is_expected.not_to contain_exec('glance-manage db_sync')
85
-        end
86
-      end
87
-      it 'is_expected.to configure itself' do
88
-        [
89
-         'workers',
90
-         'bind_port',
91
-         'bind_host',
92
-        ].each do |config|
93
-          is_expected.to contain_glance_registry_config("DEFAULT/#{config}").with_value(param_hash[config.intern])
94
-        end
95
-        [
96
-         'auth_uri',
97
-         'identity_uri'
98
-        ].each do |config|
99
-          is_expected.to contain_glance_registry_config("keystone_authtoken/#{config}").with_value(param_hash[config.intern])
74
+        it 'is_expected.to not sync the db if sync_db is set to false' do
75
+
76
+          if !param_hash[:sync_db]
77
+            is_expected.not_to contain_exec('glance-manage db_sync')
78
+          end
100 79
         end
101
-        if param_hash[:auth_type] == 'keystone'
102
-          is_expected.to contain_glance_registry_config("paste_deploy/flavor").with_value('keystone')
103
-          is_expected.to contain_glance_registry_config('keystone_authtoken/memcached_servers').with_value(param_hash[:memcached_servers])
104
-          is_expected.to contain_glance_registry_config("keystone_authtoken/admin_tenant_name").with_value(param_hash[:keystone_tenant])
105
-          is_expected.to contain_glance_registry_config("keystone_authtoken/admin_user").with_value(param_hash[:keystone_user])
106
-          is_expected.to contain_glance_registry_config("keystone_authtoken/admin_password").with_value(param_hash[:keystone_password])
107
-          is_expected.to contain_glance_registry_config("keystone_authtoken/admin_password").with_value(param_hash[:keystone_password]).with_secret(true)
108
-          is_expected.to contain_glance_registry_config("keystone_authtoken/token_cache_time").with_value(param_hash[:token_cache_time])
109
-          is_expected.to contain_glance_registry_config("keystone_authtoken/signing_dir").with_value(param_hash[:signing_dir])
80
+        it 'is_expected.to configure itself' do
81
+          [
82
+           'workers',
83
+           'bind_port',
84
+           'bind_host',
85
+          ].each do |config|
86
+            is_expected.to contain_glance_registry_config("DEFAULT/#{config}").with_value(param_hash[config.intern])
87
+          end
88
+          [
89
+           'auth_uri',
90
+           'identity_uri'
91
+          ].each do |config|
92
+            is_expected.to contain_glance_registry_config("keystone_authtoken/#{config}").with_value(param_hash[config.intern])
93
+          end
94
+          if param_hash[:auth_type] == 'keystone'
95
+            is_expected.to contain_glance_registry_config("paste_deploy/flavor").with_value('keystone')
96
+            is_expected.to contain_glance_registry_config('keystone_authtoken/memcached_servers').with_value(param_hash[: