|
119 | 119 | end
|
120 | 120 |
|
121 | 121 | ['infinity', -1, 1234].each do |value|
|
122 |
| - context "with file_limit => '#{value}'" do |
| 122 | + context "with file_limit => '#{value}'", if: os_facts['systemd'] do |
123 | 123 | let(:params) { { file_limit: value } }
|
124 | 124 |
|
125 |
| - if os_facts[:os]['family'] == 'RedHat' |
126 |
| - it do |
127 |
| - is_expected.to contain_file('/etc/security/limits.d/rabbitmq-server.conf'). |
128 |
| - with_owner('0'). |
129 |
| - with_group('0'). |
130 |
| - with_mode('0644'). |
131 |
| - that_notifies('Class[Rabbitmq::Service]'). |
132 |
| - with_content("rabbitmq soft nofile #{value}\nrabbitmq hard nofile #{value}\n") |
133 |
| - end |
134 |
| - else |
135 |
| - it { is_expected.not_to contain_file('/etc/security/limits.d/rabbitmq-server.conf') } |
136 |
| - end |
| 125 | + selinux_ignore_defaults = os_facts[:os]['family'] == 'RedHat' |
137 | 126 |
|
138 |
| - if os_facts[:os]['family'] == 'Debian' |
139 |
| - it { is_expected.to contain_file('/etc/default/rabbitmq-server').with_content(%r{ulimit -n #{value}}) } |
140 |
| - else |
141 |
| - it { is_expected.not_to contain_file('/etc/default/rabbitmq-server') } |
142 |
| - end |
143 |
| - |
144 |
| - if os_facts['systemd'] |
145 |
| - selinux_ignore_defaults = os_facts[:os]['family'] == 'RedHat' |
146 |
| - |
147 |
| - it do |
148 |
| - is_expected.to contain_systemd__service_limits("#{name}.service"). |
149 |
| - with_selinux_ignore_defaults(selinux_ignore_defaults). |
150 |
| - with_limits({ 'LimitNOFILE' => value, 'OOMScoreAdjust' => 0 }). |
151 |
| - with_restart_service(false) |
152 |
| - end |
153 |
| - else |
154 |
| - it { is_expected.not_to contain_systemd__service_limits("#{name}.service") } |
| 127 | + it do |
| 128 | + is_expected.to contain_systemd__service_limits("#{name}.service"). |
| 129 | + with_selinux_ignore_defaults(selinux_ignore_defaults). |
| 130 | + with_limits({ 'LimitNOFILE' => value, 'OOMScoreAdjust' => 0 }). |
| 131 | + with_restart_service(false) |
155 | 132 | end
|
156 | 133 | end
|
157 | 134 | end
|
|
167 | 144 | end
|
168 | 145 |
|
169 | 146 | [-1000, 0, 1000].each do |value|
|
170 |
| - context "with oom_score_adj => '#{value}'" do |
| 147 | + context "with oom_score_adj => '#{value}'", if: os_facts['systemd'] do |
171 | 148 | let(:params) { { oom_score_adj: value } }
|
172 | 149 |
|
173 |
| - if os_facts[:os]['family'] == 'Debian' |
174 |
| - it { is_expected.to contain_file('/etc/default/rabbitmq-server').with_content(%r{^echo #{value} > /proc/\$\$/oom_score_adj$}) } |
175 |
| - else |
176 |
| - it { is_expected.not_to contain_file('/etc/default/rabbitmq-server') } |
177 |
| - end |
178 |
| - |
179 |
| - if os_facts['systemd'] |
180 |
| - it do |
181 |
| - is_expected.to contain_systemd__service_limits("#{name}.service"). |
182 |
| - with_limits({ 'LimitNOFILE' => 16_384, 'OOMScoreAdjust' => value }). |
183 |
| - with_restart_service(false) |
184 |
| - end |
185 |
| - else |
186 |
| - it { is_expected.not_to contain_systemd__service_limits("#{name}.service") } |
| 150 | + it do |
| 151 | + is_expected.to contain_systemd__service_limits("#{name}.service"). |
| 152 | + with_limits({ 'LimitNOFILE' => 16_384, 'OOMScoreAdjust' => value }). |
| 153 | + with_restart_service(false) |
187 | 154 | end
|
188 | 155 | end
|
189 | 156 | end
|
|
0 commit comments