]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/keystone/spec/classes/keystone_wsgi_apache_spec.rb
try with modules from master
[dsa-puppet.git] / 3rdparty / modules / keystone / spec / classes / keystone_wsgi_apache_spec.rb
1 require 'spec_helper'
2
3 describe 'keystone::wsgi::apache' do
4
5   let :global_facts do
6     {
7       :processorcount => 42,
8       :concat_basedir => '/var/lib/puppet/concat',
9       :fqdn           => 'some.host.tld'
10     }
11   end
12
13   let :pre_condition do
14     [
15      'class { keystone: admin_token => "dummy", service_name => "httpd", enable_ssl => true }'
16     ]
17   end
18
19   shared_examples_for 'apache serving keystone with mod_wsgi' do
20     it { is_expected.to contain_service('httpd').with_name(platform_parameters[:httpd_service_name]) }
21     it { is_expected.to contain_class('keystone::params') }
22     it { is_expected.to contain_class('apache') }
23     it { is_expected.to contain_class('apache::mod::wsgi') }
24     it { is_expected.to contain_class('keystone::db::sync') }
25
26     describe 'with default parameters' do
27
28       it { is_expected.to contain_file("#{platform_parameters[:wsgi_script_path]}").with(
29         'ensure'  => 'directory',
30         'owner'   => 'keystone',
31         'group'   => 'keystone',
32         'require' => 'Package[httpd]'
33       )}
34
35       it { is_expected.to contain_file('keystone_wsgi_admin').with(
36         'ensure'  => 'file',
37         'path'    => "#{platform_parameters[:wsgi_script_path]}/admin",
38         'source'  => platform_parameters[:wsgi_script_source],
39         'owner'   => 'keystone',
40         'group'   => 'keystone',
41         'mode'    => '0644',
42         'require' => ["File[#{platform_parameters[:wsgi_script_path]}]", "Package[keystone]"]
43       )}
44
45       it { is_expected.to contain_file('keystone_wsgi_main').with(
46         'ensure'  => 'file',
47         'path'    => "#{platform_parameters[:wsgi_script_path]}/main",
48         'source'  => platform_parameters[:wsgi_script_source],
49         'owner'   => 'keystone',
50         'group'   => 'keystone',
51         'mode'    => '0644',
52         'require' => ["File[#{platform_parameters[:wsgi_script_path]}]", "Package[keystone]"]
53       )}
54
55       it { is_expected.to contain_apache__vhost('keystone_wsgi_admin').with(
56         'servername'                  => 'some.host.tld',
57         'ip'                          => nil,
58         'port'                        => '35357',
59         'docroot'                     => "#{platform_parameters[:wsgi_script_path]}",
60         'docroot_owner'               => 'keystone',
61         'docroot_group'               => 'keystone',
62         'ssl'                         => 'true',
63         'wsgi_daemon_process'         => 'keystone_admin',
64         'wsgi_daemon_process_options' => {
65           'user'         => 'keystone',
66           'group'        => 'keystone',
67           'processes'    => '1',
68           'threads'      => '42',
69           'display-name' => 'keystone-admin',
70         },
71         'wsgi_process_group'          => 'keystone_admin',
72         'wsgi_script_aliases'         => { '/' => "#{platform_parameters[:wsgi_script_path]}/admin" },
73         'require'                     => 'File[keystone_wsgi_admin]'
74       )}
75
76       it { is_expected.to contain_apache__vhost('keystone_wsgi_main').with(
77         'servername'                  => 'some.host.tld',
78         'ip'                          => nil,
79         'port'                        => '5000',
80         'docroot'                     => "#{platform_parameters[:wsgi_script_path]}",
81         'docroot_owner'               => 'keystone',
82         'docroot_group'               => 'keystone',
83         'ssl'                         => 'true',
84         'wsgi_daemon_process'         => 'keystone_main',
85         'wsgi_daemon_process_options' => {
86           'user'         => 'keystone',
87           'group'        => 'keystone',
88           'processes'    => '1',
89           'threads'      => '42',
90           'display-name' => 'keystone-main',
91         },
92         'wsgi_process_group'          => 'keystone_main',
93         'wsgi_script_aliases'         => { '/' => "#{platform_parameters[:wsgi_script_path]}/main" },
94         'require'                     => 'File[keystone_wsgi_main]'
95       )}
96       it { is_expected.to contain_file("#{platform_parameters[:httpd_ports_file]}") }
97     end
98
99     describe 'when overriding parameters using different ports' do
100       let :params do
101         {
102           :servername  => 'dummy.host',
103           :bind_host   => '10.42.51.1',
104           :public_port => 12345,
105           :admin_port  => 4142,
106           :ssl         => false,
107           :workers     => 37,
108         }
109       end
110
111       it { is_expected.to contain_apache__vhost('keystone_wsgi_admin').with(
112         'servername'                  => 'dummy.host',
113         'ip'                          => '10.42.51.1',
114         'port'                        => '4142',
115         'docroot'                     => "#{platform_parameters[:wsgi_script_path]}",
116         'docroot_owner'               => 'keystone',
117         'docroot_group'               => 'keystone',
118         'ssl'                         => 'false',
119         'wsgi_daemon_process'         => 'keystone_admin',
120         'wsgi_daemon_process_options' => {
121                   'user' => 'keystone',
122                  'group' => 'keystone',
123              'processes' => '37',
124                'threads' => '42',
125           'display-name' => 'keystone-admin',
126         },
127         'wsgi_process_group'          => 'keystone_admin',
128         'wsgi_script_aliases'         => { '/' => "#{platform_parameters[:wsgi_script_path]}/admin" },
129         'require'                     => 'File[keystone_wsgi_admin]'
130       )}
131
132       it { is_expected.to contain_apache__vhost('keystone_wsgi_main').with(
133         'servername'                  => 'dummy.host',
134         'ip'                          => '10.42.51.1',
135         'port'                        => '12345',
136         'docroot'                     => "#{platform_parameters[:wsgi_script_path]}",
137         'docroot_owner'               => 'keystone',
138         'docroot_group'               => 'keystone',
139         'ssl'                         => 'false',
140         'wsgi_daemon_process'         => 'keystone_main',
141         'wsgi_daemon_process_options' => {
142                   'user' => 'keystone',
143                  'group' => 'keystone',
144              'processes' => '37',
145                'threads' => '42',
146           'display-name' => 'keystone-main',
147         },
148         'wsgi_process_group'          => 'keystone_main',
149         'wsgi_script_aliases'         => { '/' => "#{platform_parameters[:wsgi_script_path]}/main" },
150         'require'                     => 'File[keystone_wsgi_main]'
151       )}
152
153       it { is_expected.to contain_file("#{platform_parameters[:httpd_ports_file]}") }
154     end
155
156     describe 'when overriding parameters using same port' do
157       let :params do
158         {
159           :servername  => 'dummy.host',
160           :public_port => 4242,
161           :admin_port  => 4242,
162           :public_path => '/main/endpoint/',
163           :admin_path  => '/admin/endpoint/',
164           :ssl         => true,
165           :workers     => 37,
166         }
167       end
168
169       it { is_expected.to_not contain_apache__vhost('keystone_wsgi_admin') }
170
171       it { is_expected.to contain_apache__vhost('keystone_wsgi_main').with(
172         'servername'                  => 'dummy.host',
173         'ip'                          => nil,
174         'port'                        => '4242',
175         'docroot'                     => "#{platform_parameters[:wsgi_script_path]}",
176         'docroot_owner'               => 'keystone',
177         'docroot_group'               => 'keystone',
178         'ssl'                         => 'true',
179         'wsgi_daemon_process'         => 'keystone_main',
180         'wsgi_daemon_process_options' => {
181                   'user' => 'keystone',
182                  'group' => 'keystone',
183              'processes' => '37',
184                'threads' => '42',
185           'display-name' => 'keystone-main',
186         },
187         'wsgi_process_group'          => 'keystone_main',
188         'wsgi_script_aliases'         => {
189         '/main/endpoint'  => "#{platform_parameters[:wsgi_script_path]}/main",
190         '/admin/endpoint' => "#{platform_parameters[:wsgi_script_path]}/admin"
191         },
192         'require'                     => 'File[keystone_wsgi_main]'
193       )}
194     end
195
196     describe 'when overriding parameters using same port and same path' do
197       let :params do
198         {
199           :servername  => 'dummy.host',
200           :public_port => 4242,
201           :admin_port  => 4242,
202           :public_path => '/endpoint/',
203           :admin_path  => '/endpoint/',
204           :ssl         => true,
205           :workers     => 37,
206         }
207       end
208
209       it_raises 'a Puppet::Error', /When using the same port for public & private endpoints, public_path and admin_path should be different\./
210     end
211
212     describe 'when overriding parameters using symlink and custom file source' do
213       let :params do
214         {
215           :wsgi_script_ensure => 'link',
216           :wsgi_script_source => '/opt/keystone/httpd/keystone.py',
217         }
218       end
219
220       it { is_expected.to contain_file('keystone_wsgi_admin').with(
221         'ensure'  => 'link',
222         'path'    => "#{platform_parameters[:wsgi_script_path]}/admin",
223         'target'  => '/opt/keystone/httpd/keystone.py',
224         'owner'   => 'keystone',
225         'group'   => 'keystone',
226         'mode'    => '0644',
227         'require' => ["File[#{platform_parameters[:wsgi_script_path]}]", "Package[keystone]"]
228       )}
229
230       it { is_expected.to contain_file('keystone_wsgi_main').with(
231         'ensure'  => 'link',
232         'path'    => "#{platform_parameters[:wsgi_script_path]}/main",
233         'target'  => '/opt/keystone/httpd/keystone.py',
234         'owner'   => 'keystone',
235         'group'   => 'keystone',
236         'mode'    => '0644',
237         'require' => ["File[#{platform_parameters[:wsgi_script_path]}]", "Package[keystone]"]
238       )}
239     end
240   end
241
242   context 'on RedHat platforms' do
243     let :facts do
244       global_facts.merge({
245         :osfamily               => 'RedHat',
246         :operatingsystemrelease => '6.0'
247       })
248     end
249
250     let :platform_parameters do
251       {
252         :httpd_service_name => 'httpd',
253         :httpd_ports_file   => '/etc/httpd/conf/ports.conf',
254         :wsgi_script_path   => '/var/www/cgi-bin/keystone',
255         :wsgi_script_source => '/usr/share/keystone/keystone.wsgi'
256       }
257     end
258
259     it_configures 'apache serving keystone with mod_wsgi'
260   end
261
262   context 'on Debian platforms' do
263     let :facts do
264       global_facts.merge({
265         :osfamily               => 'Debian',
266         :operatingsystem        => 'Debian',
267         :operatingsystemrelease => '7.0'
268       })
269     end
270
271     let :platform_parameters do
272       {
273         :httpd_service_name => 'apache2',
274         :httpd_ports_file   => '/etc/apache2/ports.conf',
275         :wsgi_script_path   => '/usr/lib/cgi-bin/keystone',
276         :wsgi_script_source => '/usr/share/keystone/wsgi.py'
277       }
278     end
279
280     it_configures 'apache serving keystone with mod_wsgi'
281   end
282 end