-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathevent_spec.rb
138 lines (118 loc) · 7.26 KB
/
event_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# frozen_string_literal: true
require 'spec_helper'
describe 'apache::mod::event', type: :class do
let :pre_condition do
'class { "apache": mpm_module => false, }'
end
context 'on a FreeBSD OS' do
include_examples 'FreeBSD 9'
it { is_expected.to contain_class('apache::params') }
it { is_expected.not_to contain_apache__mod('event') }
it { is_expected.to contain_file('/usr/local/etc/apache24/Modules/event.conf').with_ensure('file') }
end
context 'on a Gentoo OS' do
include_examples 'Gentoo'
it { is_expected.to contain_class('apache::params') }
it { is_expected.not_to contain_apache__mod('event') }
it { is_expected.to contain_file('/etc/apache2/modules.d/event.conf').with_ensure('file') }
end
context 'on a Debian OS' do
include_examples 'Debian 11'
let(:loadcontent) do
"# Conflicts: mpm_worker mpm_prefork\n"\
"LoadModule mpm_event_module /usr/lib/apache2/modules/mod_mpm_event.so\n"
end
it { is_expected.to contain_class('apache::params') }
it { is_expected.not_to contain_apache__mod('event') }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file') }
it { is_expected.to contain_file('/etc/apache2/mods-enabled/mpm_event.conf').with_ensure('link') }
context 'Test mpm_event new params' do
let :params do
{
serverlimit: 0,
startservers: 1,
minsparethreads: 3,
maxsparethreads: 4,
threadsperchild: 5,
threadlimit: 7,
listenbacklog: 8,
maxrequestworkers: 9,
maxconnectionsperchild: 10
}
end
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').with_content(%r{^\s*ServerLimit\s*0}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').with_content(%r{^\s*StartServers\s*1}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').with_content(%r{^\s*MinSpareThreads\s*3}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').with_content(%r{^\s*MaxSpareThreads\s*4}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').with_content(%r{^\s*ThreadsPerChild\s*5}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').with_content(%r{^\s*ThreadLimit\s*7}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').with_content(%r{^\s*ListenBacklog\s*8}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').with_content(%r{^\s*MaxRequestWorkers\s*9}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').with_content(%r{^\s*MaxConnectionsPerChild\s*10}) }
end
context 'Test mpm_event old style params' do
let :params do
{
serverlimit: 0,
startservers: 1,
minsparethreads: 3,
maxsparethreads: 4,
threadsperchild: 5,
threadlimit: 7,
listenbacklog: 8,
maxrequestworkers: :undef,
maxconnectionsperchild: :undef
}
end
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').with_content(%r{^\s*ServerLimit\s*0}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').with_content(%r{^\s*StartServers\s*1}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').with_content(%r{^\s*MinSpareThreads\s*3}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').with_content(%r{^\s*MaxSpareThreads\s*4}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').with_content(%r{^\s*ThreadsPerChild\s*5}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').with_content(%r{^\s*ThreadLimit\s*7}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').with_content(%r{^\s*ListenBacklog\s*8}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').without_content(%r{^\s*MaxRequestWorkers}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').without_content(%r{^\s*MaxConnectionsPerChild}) }
end
context 'Test mpm_event false params' do
let :params do
{
serverlimit: false,
startservers: false,
minsparethreads: false,
maxsparethreads: false,
threadsperchild: false,
threadlimit: false,
listenbacklog: false,
maxrequestworkers: false,
maxconnectionsperchild: false
}
end
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').without_content(%r{^\s*ServerLimit}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').without_content(%r{^\s*StartServers}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').without_content(%r{^\s*MinSpareThreads}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').without_content(%r{^\s*MaxSpareThreads}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').without_content(%r{^\s*ThreadsPerChild}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').without_content(%r{^\s*ThreadLimit}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').without_content(%r{^\s*ListenBacklog}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').without_content(%r{^\s*MaxRequestWorkers}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').without_content(%r{^\s*MaxConnectionsPerChild}) }
end
it {
expect(subject).to contain_file('/etc/apache2/mods-available/mpm_event.load').with('ensure' => 'file',
'content' => loadcontent)
}
it { is_expected.to contain_file('/etc/apache2/mods-enabled/mpm_event.load').with_ensure('link') }
end
context 'on a RedHat OS' do
include_examples 'RedHat 8'
it { is_expected.to contain_class('apache::params') }
it { is_expected.not_to contain_apache__mod('worker') }
it { is_expected.not_to contain_apache__mod('prefork') }
it { is_expected.to contain_file('/etc/httpd/conf.modules.d/event.conf').with_ensure('file') }
it {
expect(subject).to contain_file('/etc/httpd/conf.modules.d/event.load').with('ensure' => 'file',
'content' => "LoadModule mpm_event_module modules/mod_mpm_event.so\n")
}
end
end