]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/apache/spec/classes/mod/event_spec.rb
add Openstack modules to 3rdparty
[dsa-puppet.git] / 3rdparty / modules / apache / spec / classes / mod / event_spec.rb
1 require 'spec_helper'
2
3 describe 'apache::mod::event', :type => :class do
4   let :pre_condition do
5     'class { "apache": mpm_module => false, }'
6   end
7   context "on a FreeBSD OS" do
8     let :facts do
9       {
10         :osfamily               => 'FreeBSD',
11         :operatingsystemrelease => '9',
12         :concat_basedir         => '/dne',
13         :operatingsystem        => 'FreeBSD',
14         :id                     => 'root',
15         :kernel                 => 'FreeBSD',
16         :path                   => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
17         :is_pe                  => false,
18       }
19     end
20     it { is_expected.to contain_class("apache::params") }
21     it { is_expected.not_to contain_apache__mod('event') }
22     it { is_expected.to contain_file("/usr/local/etc/apache24/Modules/event.conf").with_ensure('file') }
23   end
24   context "on a Gentoo OS" do
25     let :facts do
26       {
27         :osfamily               => 'Gentoo',
28         :operatingsystem        => 'Gentoo',
29         :operatingsystemrelease => '3.16.1-gentoo',
30         :concat_basedir         => '/dne',
31         :id                     => 'root',
32         :kernel                 => 'Linux',
33         :path                   => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin',
34         :is_pe                  => false,
35       }
36     end
37     it { is_expected.to contain_class("apache::params") }
38     it { is_expected.not_to contain_apache__mod('event') }
39     it { is_expected.to contain_file("/etc/apache2/modules.d/event.conf").with_ensure('file') }
40   end
41   context "on a Debian OS" do
42     let :facts do
43       {
44         :lsbdistcodename        => 'squeeze',
45         :osfamily               => 'Debian',
46         :operatingsystemrelease => '6',
47         :concat_basedir         => '/dne',
48         :operatingsystem        => 'Debian',
49         :id                     => 'root',
50         :kernel                 => 'Linux',
51         :path                   => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
52         :is_pe                  => false,
53       }
54     end
55
56
57     it { is_expected.to contain_class("apache::params") }
58     it { is_expected.not_to contain_apache__mod('event') }
59     it { is_expected.to contain_file("/etc/apache2/mods-available/event.conf").with_ensure('file') }
60     it { is_expected.to contain_file("/etc/apache2/mods-enabled/event.conf").with_ensure('link') }
61
62     context "Test mpm_event params" do
63       let :params do
64         {
65           :serverlimit            => '0',
66           :startservers           => '1',
67           :maxclients             => '2',
68           :minsparethreads        => '3',
69           :maxsparethreads        => '4',
70           :threadsperchild        => '5',
71           :maxrequestsperchild    => '6',
72           :threadlimit            => '7',
73           :listenbacklog          => '8',
74           :maxrequestworkers      => '9',
75           :maxconnectionsperchild => '10',
76         }
77       end
78
79       it { is_expected.to contain_file("/etc/apache2/mods-available/event.conf").with_ensure('file').with_content(/^\s*ServerLimit\s*0/) }
80       it { is_expected.to contain_file("/etc/apache2/mods-available/event.conf").with_ensure('file').with_content(/^\s*StartServers\s*1/) }
81       it { is_expected.to contain_file("/etc/apache2/mods-available/event.conf").with_ensure('file').with_content(/^\s*MaxClients\s*2/) }
82       it { is_expected.to contain_file("/etc/apache2/mods-available/event.conf").with_ensure('file').with_content(/^\s*MinSpareThreads\s*3/) }
83       it { is_expected.to contain_file("/etc/apache2/mods-available/event.conf").with_ensure('file').with_content(/^\s*MaxSpareThreads\s*4/) }
84       it { is_expected.to contain_file("/etc/apache2/mods-available/event.conf").with_ensure('file').with_content(/^\s*ThreadsPerChild\s*5/) }
85       it { is_expected.to contain_file("/etc/apache2/mods-available/event.conf").with_ensure('file').with_content(/^\s*MaxRequestsPerChild\s*6/) }
86       it { is_expected.to contain_file("/etc/apache2/mods-available/event.conf").with_ensure('file').with_content(/^\s*ThreadLimit\s*7/) }
87       it { is_expected.to contain_file("/etc/apache2/mods-available/event.conf").with_ensure('file').with_content(/^\s*ListenBacklog\s*8/) }
88       it { is_expected.to contain_file("/etc/apache2/mods-available/event.conf").with_ensure('file').with_content(/^\s*MaxRequestWorkers\s*9/) }
89       it { is_expected.to contain_file("/etc/apache2/mods-available/event.conf").with_ensure('file').with_content(/^\s*MaxConnectionsPerChild\s*10/) }
90     end
91
92     context "with Apache version < 2.4" do
93       let :params do
94         {
95           :apache_version => '2.2',
96         }
97       end
98
99       it { is_expected.not_to contain_file("/etc/apache2/mods-available/event.load") }
100       it { is_expected.not_to contain_file("/etc/apache2/mods-enabled/event.load") }
101
102       it { is_expected.to contain_package("apache2-mpm-event") }
103     end
104
105     context "with Apache version >= 2.4" do
106       let :params do
107         {
108           :apache_version => '2.4',
109         }
110       end
111
112       it { is_expected.to contain_file("/etc/apache2/mods-available/event.load").with({
113         'ensure'  => 'file',
114         'content' => "LoadModule mpm_event_module /usr/lib/apache2/modules/mod_mpm_event.so\n"
115         })
116       }
117       it { is_expected.to contain_file("/etc/apache2/mods-enabled/event.load").with_ensure('link') }
118     end
119   end
120   context "on a RedHat OS" do
121     let :facts do
122       {
123         :osfamily               => 'RedHat',
124         :operatingsystemrelease => '6',
125         :concat_basedir         => '/dne',
126         :operatingsystem        => 'RedHat',
127         :id                     => 'root',
128         :kernel                 => 'Linux',
129         :path                   => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
130         :is_pe                  => false,
131       }
132     end
133
134     context "with Apache version >= 2.4" do
135       let :params do
136         {
137           :apache_version => '2.4',
138         }
139       end
140
141       it { is_expected.to contain_class("apache::params") }
142       it { is_expected.not_to contain_apache__mod('worker') }
143       it { is_expected.not_to contain_apache__mod('prefork') }
144
145       it { is_expected.to contain_file("/etc/httpd/conf.d/event.conf").with_ensure('file') }
146
147       it { is_expected.to contain_file("/etc/httpd/conf.d/event.load").with({
148         'ensure'  => 'file',
149         'content' => "LoadModule mpm_event_module modules/mod_mpm_event.so\n",
150         })
151       }
152     end
153   end
154 end