|
248 | 248 | end |
249 | 249 | end |
250 | 250 |
|
| 251 | + context 'on RedHat 7.0 or more' do |
| 252 | + let(:facts) {{ :osfamily => 'RedHat', :operatingsystemmajrelease => '7' }} |
| 253 | + |
| 254 | + it { should contain_file('/etc/systemd/system/rabbitmq-server.service.d').with( |
| 255 | + 'ensure' => 'directory', |
| 256 | + 'owner' => '0', |
| 257 | + 'group' => '0', |
| 258 | + 'mode' => '0755' |
| 259 | + ) } |
| 260 | + |
| 261 | + it { should contain_exec('rabbitmq-systemd-reload').with( |
| 262 | + 'command' => '/usr/bin/systemctl daemon-reload', |
| 263 | + 'notify' => 'Class[Rabbitmq::Service]', |
| 264 | + 'refreshonly' => true |
| 265 | + ) } |
| 266 | + context 'with file_limit => unlimited' do |
| 267 | + let(:params) {{ :file_limit => 'unlimited' }} |
| 268 | + it { should contain_file('/etc/systemd/system/rabbitmq-server.service.d/limits.conf').with( |
| 269 | + 'owner' => '0', |
| 270 | + 'group' => '0', |
| 271 | + 'mode' => '0644', |
| 272 | + 'notify' => 'Exec[rabbitmq-systemd-reload]', |
| 273 | + 'content' => '[Service] |
| 274 | +LimitNOFILE=unlimited |
| 275 | +' |
| 276 | + ) } |
| 277 | + end |
| 278 | + |
| 279 | + context 'with file_limit => infinity' do |
| 280 | + let(:params) {{ :file_limit => 'infinity' }} |
| 281 | + it { should contain_file('/etc/systemd/system/rabbitmq-server.service.d/limits.conf').with( |
| 282 | + 'owner' => '0', |
| 283 | + 'group' => '0', |
| 284 | + 'mode' => '0644', |
| 285 | + 'notify' => 'Exec[rabbitmq-systemd-reload]', |
| 286 | + 'content' => '[Service] |
| 287 | +LimitNOFILE=infinity |
| 288 | +' |
| 289 | + ) } |
| 290 | + end |
| 291 | + |
| 292 | + context 'with file_limit => -1' do |
| 293 | + let(:params) {{ :file_limit => -1 }} |
| 294 | + it { should contain_file('/etc/systemd/system/rabbitmq-server.service.d/limits.conf').with( |
| 295 | + 'owner' => '0', |
| 296 | + 'group' => '0', |
| 297 | + 'mode' => '0644', |
| 298 | + 'notify' => 'Exec[rabbitmq-systemd-reload]', |
| 299 | + 'content' => '[Service] |
| 300 | +LimitNOFILE=-1 |
| 301 | +' |
| 302 | + ) } |
| 303 | + end |
| 304 | + |
| 305 | + context 'with file_limit => \'1234\'' do |
| 306 | + let(:params) {{ :file_limit => '1234' }} |
| 307 | + it { should contain_file('/etc/systemd/system/rabbitmq-server.service.d/limits.conf').with( |
| 308 | + 'owner' => '0', |
| 309 | + 'group' => '0', |
| 310 | + 'mode' => '0644', |
| 311 | + 'notify' => 'Exec[rabbitmq-systemd-reload]', |
| 312 | + 'content' => '[Service] |
| 313 | +LimitNOFILE=1234 |
| 314 | +' |
| 315 | + ) } |
| 316 | + end |
| 317 | + |
| 318 | + context 'with file_limit => foo' do |
| 319 | + let(:params) {{ :file_limit => 'foo' }} |
| 320 | + it 'does not compile' do |
| 321 | + expect { catalogue }.to raise_error(Puppet::Error, /\$file_limit must be an integer, 'unlimited', or 'infinity'/) |
| 322 | + end |
| 323 | + end |
| 324 | + end |
| 325 | + |
| 326 | + context 'on RedHat before 7.0' do |
| 327 | + let(:facts) {{ :osfamily => 'RedHat', :operatingsystemmajrelease => '6' }} |
| 328 | + |
| 329 | + context 'with file_limit => unlimited' do |
| 330 | + let(:params) {{ :file_limit => 'unlimited' }} |
| 331 | + it { should contain_file('/etc/security/limits.d/rabbitmq-server.conf').with( |
| 332 | + 'owner' => '0', |
| 333 | + 'group' => '0', |
| 334 | + 'mode' => '0644', |
| 335 | + 'notify' => 'Class[Rabbitmq::Service]', |
| 336 | + 'content' => 'rabbitmq soft nofile unlimited |
| 337 | +rabbitmq hard nofile unlimited |
| 338 | +' |
| 339 | + ) } |
| 340 | + end |
| 341 | + |
| 342 | + context 'with file_limit => infinity' do |
| 343 | + let(:params) {{ :file_limit => 'infinity' }} |
| 344 | + it { should contain_file('/etc/security/limits.d/rabbitmq-server.conf').with( |
| 345 | + 'owner' => '0', |
| 346 | + 'group' => '0', |
| 347 | + 'mode' => '0644', |
| 348 | + 'notify' => 'Class[Rabbitmq::Service]', |
| 349 | + 'content' => 'rabbitmq soft nofile infinity |
| 350 | +rabbitmq hard nofile infinity |
| 351 | +' |
| 352 | + ) } |
| 353 | + end |
| 354 | + |
| 355 | + context 'with file_limit => -1' do |
| 356 | + let(:params) {{ :file_limit => -1 }} |
| 357 | + it { should contain_file('/etc/security/limits.d/rabbitmq-server.conf').with( |
| 358 | + 'owner' => '0', |
| 359 | + 'group' => '0', |
| 360 | + 'mode' => '0644', |
| 361 | + 'notify' => 'Class[Rabbitmq::Service]', |
| 362 | + 'content' => 'rabbitmq soft nofile -1 |
| 363 | +rabbitmq hard nofile -1 |
| 364 | +' |
| 365 | + ) } |
| 366 | + end |
| 367 | + |
| 368 | + context 'with file_limit => \'1234\'' do |
| 369 | + let(:params) {{ :file_limit => '1234' }} |
| 370 | + it { should contain_file('/etc/security/limits.d/rabbitmq-server.conf').with( |
| 371 | + 'owner' => '0', |
| 372 | + 'group' => '0', |
| 373 | + 'mode' => '0644', |
| 374 | + 'notify' => 'Class[Rabbitmq::Service]', |
| 375 | + 'content' => 'rabbitmq soft nofile 1234 |
| 376 | +rabbitmq hard nofile 1234 |
| 377 | +' |
| 378 | + ) } |
| 379 | + end |
| 380 | + |
| 381 | + context 'with file_limit => foo' do |
| 382 | + let(:params) {{ :file_limit => 'foo' }} |
| 383 | + it 'does not compile' do |
| 384 | + expect { catalogue }.to raise_error(Puppet::Error, /\$file_limit must be an integer, 'unlimited', or 'infinity'/) |
| 385 | + end |
| 386 | + end |
| 387 | + end |
| 388 | + |
251 | 389 | ['Debian', 'RedHat', 'SUSE', 'Archlinux'].each do |distro| |
252 | 390 | context "on #{distro}" do |
253 | 391 | let(:facts) {{ |
|
0 commit comments