]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/apache/spec/classes/mod/passenger_spec.rb
add Openstack modules to 3rdparty
[dsa-puppet.git] / 3rdparty / modules / apache / spec / classes / mod / passenger_spec.rb
1 require 'spec_helper'
2
3 describe 'apache::mod::passenger', :type => :class do
4   let :pre_condition do
5     'include apache'
6   end
7   context "on a Debian OS" do
8     let :facts do
9       {
10         :osfamily               => 'Debian',
11         :operatingsystemrelease => '6',
12         :kernel                 => 'Linux',
13         :concat_basedir         => '/dne',
14         :lsbdistcodename        => 'squeeze',
15         :operatingsystem        => 'Debian',
16         :id                     => 'root',
17         :kernel                 => 'Linux',
18         :path                   => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
19         :is_pe                  => false,
20       }
21     end
22     it { is_expected.to contain_class("apache::params") }
23     it { is_expected.to contain_apache__mod('passenger') }
24     it { is_expected.to contain_package("libapache2-mod-passenger") }
25     it { is_expected.to contain_file('zpassenger.load').with({
26       'path' => '/etc/apache2/mods-available/zpassenger.load',
27     }) }
28     it { is_expected.to contain_file('passenger.conf').with({
29       'path' => '/etc/apache2/mods-available/passenger.conf',
30     }) }
31     describe "with passenger_root => '/usr/lib/example'" do
32       let :params do
33         { :passenger_root => '/usr/lib/example' }
34       end
35       it { is_expected.to contain_file('passenger.conf').with_content(%r{PassengerRoot "/usr/lib/example"}) }
36     end
37     describe "with passenger_ruby => /usr/lib/example/ruby" do
38       let :params do
39         { :passenger_ruby => '/usr/lib/example/ruby' }
40       end
41       it { is_expected.to contain_file('passenger.conf').with_content(%r{PassengerRuby "/usr/lib/example/ruby"}) }
42     end
43     describe "with passenger_default_ruby => /usr/lib/example/ruby1.9.3" do
44       let :params do
45         { :passenger_ruby => '/usr/lib/example/ruby1.9.3' }
46       end
47       it { is_expected.to contain_file('passenger.conf').with_content(%r{PassengerRuby "/usr/lib/example/ruby1.9.3"}) }
48     end
49     describe "with passenger_high_performance => on" do
50       let :params do
51         { :passenger_high_performance => 'on' }
52       end
53       it { is_expected.to contain_file('passenger.conf').with_content(/^  PassengerHighPerformance on$/) }
54     end
55     describe "with passenger_pool_idle_time => 1200" do
56       let :params do
57         { :passenger_pool_idle_time => 1200 }
58       end
59       it { is_expected.to contain_file('passenger.conf').with_content(/^  PassengerPoolIdleTime 1200$/) }
60     end
61     describe "with passenger_max_requests => 20" do
62       let :params do
63         { :passenger_max_requests => 20 }
64       end
65       it { is_expected.to contain_file('passenger.conf').with_content(/^  PassengerMaxRequests 20$/) }
66     end
67     describe "with passenger_stat_throttle_rate => 10" do
68       let :params do
69         { :passenger_stat_throttle_rate => 10 }
70       end
71       it { is_expected.to contain_file('passenger.conf').with_content(/^  PassengerStatThrottleRate 10$/) }
72     end
73     describe "with passenger_max_pool_size => 16" do
74       let :params do
75         { :passenger_max_pool_size => 16 }
76       end
77       it { is_expected.to contain_file('passenger.conf').with_content(/^  PassengerMaxPoolSize 16$/) }
78     end
79     describe "with passenger_min_instances => 5" do
80       let :params do
81         { :passenger_min_instances => 5 }
82       end
83       it { is_expected.to contain_file('passenger.conf').with_content(/^  PassengerMinInstances 5$/) }
84     end
85     describe "with rack_autodetect => on" do
86       let :params do
87         { :rack_autodetect => 'on' }
88       end
89       it { is_expected.to contain_file('passenger.conf').with_content(/^  RackAutoDetect on$/) }
90     end
91     describe "with rails_autodetect => on" do
92       let :params do
93         { :rails_autodetect => 'on' }
94       end
95       it { is_expected.to contain_file('passenger.conf').with_content(/^  RailsAutoDetect on$/) }
96     end
97     describe "with passenger_use_global_queue => on" do
98       let :params do
99         { :passenger_use_global_queue => 'on' }
100       end
101       it { is_expected.to contain_file('passenger.conf').with_content(/^  PassengerUseGlobalQueue on$/) }
102     end
103     describe "with passenger_app_env => 'foo'" do
104       let :params do
105         { :passenger_app_env => 'foo' }
106       end
107       it { is_expected.to contain_file('passenger.conf').with_content(/^  PassengerAppEnv foo$/) }
108     end
109     describe "with mod_path => '/usr/lib/foo/mod_foo.so'" do
110       let :params do
111         { :mod_path => '/usr/lib/foo/mod_foo.so' }
112       end
113       it { is_expected.to contain_file('zpassenger.load').with_content(/^LoadModule passenger_module \/usr\/lib\/foo\/mod_foo\.so$/) }
114     end
115     describe "with mod_lib_path => '/usr/lib/foo'" do
116       let :params do
117         { :mod_lib_path => '/usr/lib/foo' }
118       end
119       it { is_expected.to contain_file('zpassenger.load').with_content(/^LoadModule passenger_module \/usr\/lib\/foo\/mod_passenger\.so$/) }
120     end
121     describe "with mod_lib => 'mod_foo.so'" do
122       let :params do
123         { :mod_lib => 'mod_foo.so' }
124       end
125       it { is_expected.to contain_file('zpassenger.load').with_content(/^LoadModule passenger_module \/usr\/lib\/apache2\/modules\/mod_foo\.so$/) }
126     end
127     describe "with mod_id => 'mod_foo'" do
128       let :params do
129         { :mod_id => 'mod_foo' }
130       end
131       it { is_expected.to contain_file('zpassenger.load').with_content(/^LoadModule mod_foo \/usr\/lib\/apache2\/modules\/mod_passenger\.so$/) }
132     end
133
134     context "with Ubuntu 12.04 defaults" do
135       let :facts do
136         {
137           :osfamily               => 'Debian',
138           :operatingsystemrelease => '12.04',
139           :kernel                 => 'Linux',
140           :operatingsystem        => 'Ubuntu',
141           :lsbdistrelease         => '12.04',
142           :concat_basedir         => '/dne',
143           :id                     => 'root',
144           :path                   => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
145           :is_pe                  => false,
146         }
147       end
148
149       it { is_expected.to contain_file('passenger.conf').with_content(%r{PassengerRoot "/usr"}) }
150       it { is_expected.to contain_file('passenger.conf').with_content(%r{PassengerRuby "/usr/bin/ruby"}) }
151       it { is_expected.to contain_file('passenger.conf').without_content(/PassengerDefaultRuby/) }
152     end
153
154     context "with Ubuntu 14.04 defaults" do
155       let :facts do
156         {
157           :osfamily               => 'Debian',
158           :operatingsystemrelease => '14.04',
159           :operatingsystem        => 'Ubuntu',
160           :kernel                 => 'Linux',
161           :lsbdistrelease         => '14.04',
162           :concat_basedir         => '/dne',
163           :id                     => 'root',
164           :path                   => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
165           :is_pe                  => false,
166         }
167       end
168
169       it { is_expected.to contain_file('passenger.conf').with_content(%r{PassengerRoot "/usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini"}) }
170       it { is_expected.to contain_file('passenger.conf').without_content(/PassengerRuby/) }
171       it { is_expected.to contain_file('passenger.conf').with_content(%r{PassengerDefaultRuby "/usr/bin/ruby"}) }
172     end
173
174     context "with Debian 7 defaults" do
175       let :facts do
176         {
177           :osfamily               => 'Debian',
178           :operatingsystemrelease => '7.3',
179           :operatingsystem        => 'Debian',
180           :kernel                 => 'Linux',
181           :lsbdistcodename        => 'wheezy',
182           :concat_basedir         => '/dne',
183           :id                     => 'root',
184           :path                   => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
185           :is_pe                  => false,
186         }
187       end
188
189       it { is_expected.to contain_file('passenger.conf').with_content(%r{PassengerRoot "/usr"}) }
190       it { is_expected.to contain_file('passenger.conf').with_content(%r{PassengerRuby "/usr/bin/ruby"}) }
191       it { is_expected.to contain_file('passenger.conf').without_content(/PassengerDefaultRuby/) }
192     end
193
194     context "with Debian 8 defaults" do
195       let :facts do
196         {
197           :osfamily               => 'Debian',
198           :operatingsystemrelease => '8.0',
199           :operatingsystem        => 'Debian',
200           :kernel                 => 'Linux',
201           :lsbdistcodename        => 'jessie',
202           :concat_basedir         => '/dne',
203           :id                     => 'root',
204           :path                   => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
205           :is_pe                  => false,
206         }
207       end
208
209       it { is_expected.to contain_file('passenger.conf').with_content(%r{PassengerRoot "/usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini"}) }
210       it { is_expected.to contain_file('passenger.conf').without_content(/PassengerRuby/) }
211       it { is_expected.to contain_file('passenger.conf').with_content(%r{PassengerDefaultRuby "/usr/bin/ruby"}) }
212     end
213   end
214
215   context "on a RedHat OS" do
216     let :facts do
217       {
218         :osfamily               => 'RedHat',
219         :operatingsystemrelease => '6',
220         :concat_basedir         => '/dne',
221         :operatingsystem        => 'RedHat',
222         :id                     => 'root',
223         :kernel                 => 'Linux',
224         :path                   => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
225         :is_pe                  => false,
226       }
227     end
228     it { is_expected.to contain_class("apache::params") }
229     it { is_expected.to contain_apache__mod('passenger') }
230     it { is_expected.to contain_package("mod_passenger") }
231     it { is_expected.to contain_file('passenger_package.conf').with({
232       'path' => '/etc/httpd/conf.d/passenger.conf',
233     }) }
234     it { is_expected.to contain_file('passenger_package.conf').without_content }
235     it { is_expected.to contain_file('passenger_package.conf').without_source }
236     it { is_expected.to contain_file('zpassenger.load').with({
237       'path' => '/etc/httpd/conf.d/zpassenger.load',
238     }) }
239     it { is_expected.to contain_file('passenger.conf').without_content(/PassengerRoot/) }
240     it { is_expected.to contain_file('passenger.conf').without_content(/PassengerRuby/) }
241     describe "with passenger_root => '/usr/lib/example'" do
242       let :params do
243         { :passenger_root => '/usr/lib/example' }
244       end
245       it { is_expected.to contain_file('passenger.conf').with_content(/^  PassengerRoot "\/usr\/lib\/example"$/) }
246     end
247     describe "with passenger_ruby => /usr/lib/example/ruby" do
248       let :params do
249         { :passenger_ruby => '/usr/lib/example/ruby' }
250       end
251       it { is_expected.to contain_file('passenger.conf').with_content(/^  PassengerRuby "\/usr\/lib\/example\/ruby"$/) }
252     end
253   end
254   context "on a FreeBSD OS" do
255     let :facts do
256       {
257         :osfamily               => 'FreeBSD',
258         :operatingsystemrelease => '9',
259         :concat_basedir         => '/dne',
260         :operatingsystem        => 'FreeBSD',
261         :id                     => 'root',
262         :kernel                 => 'FreeBSD',
263         :path                   => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
264         :is_pe                  => false,
265       }
266     end
267     it { is_expected.to contain_class("apache::params") }
268     it { is_expected.to contain_apache__mod('passenger') }
269     it { is_expected.to contain_package("www/rubygem-passenger") }
270   end
271   context "on a Gentoo OS" do
272     let :facts do
273       {
274         :osfamily               => 'Gentoo',
275         :operatingsystem        => 'Gentoo',
276         :operatingsystemrelease => '3.16.1-gentoo',
277         :concat_basedir         => '/dne',
278         :id                     => 'root',
279         :kernel                 => 'Linux',
280         :path                   => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin',
281         :is_pe                  => false,
282       }
283     end
284     it { is_expected.to contain_class("apache::params") }
285     it { is_expected.to contain_apache__mod('passenger') }
286     it { is_expected.to contain_package("www-apache/passenger") }
287   end
288 end