end
end
+ # TODO: get Archlinux & OpenBSD facts from facterdb
+
on_supported_os.each do |os, facts|
context "on #{os}" do
- systemd_facts = os_specific_facts(facts)
- facts = facts.merge(systemd_facts)
- let :facts do
- facts
- end
-
- name = case facts[:osfamily]
- when 'Archlinux', 'OpenBSD', 'FreeBSD'
- 'rabbitmq'
- else
- 'rabbitmq-server'
- end
+ let(:facts) { facts }
+
+ packagename = case facts[:osfamily]
+ when 'Archlinux'
+ 'rabbitmq'
+ else
+ 'rabbitmq-server'
+ end
+ has_systemd = (
+ (facts[:os]['family'] == 'RedHat' && facts[:os]['release']['major'].to_i >= 7) ||
+ (facts[:os]['family'] == 'Debian' && facts[:os]['release']['full'] == '16.04') ||
+ (facts[:os]['family'] == 'Archlinux')
+ )
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_class('rabbitmq::install') }
- it { is_expected.to contain_class('rabbitmq::config').that_notifies('Class[rabbitmq::service]') }
+ it { is_expected.to contain_class('rabbitmq::config') }
it { is_expected.to contain_class('rabbitmq::service') }
- it { is_expected.to contain_package(name).with_ensure('installed').with_name(name) }
+ it { is_expected.to contain_package(packagename).with_ensure('installed').with_name(packagename) }
if facts[:os]['family'] == 'Suse'
it { is_expected.to contain_package('rabbitmq-server-plugins') }
end
it { is_expected.not_to contain_yumrepo('rabbitmq') }
end
- context 'with service_restart => false' do
- let(:params) { { service_restart: false } }
-
- it { is_expected.not_to contain_class('rabbitmq::config').that_notifies('Class[rabbitmq::service]') }
- end
-
context 'with repos_ensure => true' do
let(:params) { { repos_ensure: true } }
end
end
- ['infinity', -1, 1234].each do |value|
+ ['unlimited', 'infinity', -1, 1234].each do |value|
context "with file_limit => '#{value}'" do
let(:params) { { file_limit: value } }
it { is_expected.not_to contain_file('/etc/default/rabbitmq-server') }
end
- if facts[:systemd]
+ if has_systemd
it do
- is_expected.to contain_systemd__service_limits("#{name}.service").
- with_limits('LimitNOFILE' => value).
- with_restart_service(false)
+ is_expected.to contain_file("/etc/systemd/system/#{packagename}.service.d/limits.conf").
+ with_owner('0').
+ with_group('0').
+ with_mode('0644').
+ that_notifies('Exec[rabbitmq-systemd-reload]').
+ with_content("[Service]\nLimitNOFILE=#{value}\n")
end
else
- it { is_expected.not_to contain_systemd__service_limits("#{name}.service") }
+ it { is_expected.not_to contain_file('/etc/systemd/system/rabbitmq-server.service.d/limits.conf') }
end
end
end
- [-42, '-42', 'foo'].each do |value|
+ [-42, '-42', 'foo', '42'].each do |value|
context "with file_limit => '#{value}'" do
let(:params) { { file_limit: value } }
end
end
- context 'on systems with systemd', if: facts[:systemd] do
- it do
- is_expected.to contain_systemd__service_limits("#{name}.service").
- with_restart_service(false)
- end
+ context 'on systems with systemd', if: has_systemd do
+ it {
+ is_expected.to contain_file("/etc/systemd/system/#{packagename}.service.d").with(
+ 'ensure' => 'directory',
+ 'owner' => '0',
+ 'group' => '0',
+ 'mode' => '0755',
+ 'selinux_ignore_defaults' => true
+ )
+ }
+
+ it { is_expected.to contain_file("/etc/systemd/system/#{packagename}.service.d/limits.conf") }
+
+ it {
+ is_expected.to contain_exec('rabbitmq-systemd-reload').with(
+ command: '/bin/systemctl daemon-reload',
+ notify: 'Class[Rabbitmq::Service]',
+ refreshonly: true
+ )
+ }
end
- context 'on systems without systemd', unless: facts[:systemd] do
- it { is_expected.not_to contain_systemd__service_limits("#{name}.service") }
+ context 'on systems without systemd', unless: has_systemd do
+ it { is_expected.not_to contain_file('/etc/systemd/system/rabbitmq-server.service.d') }
+ it { is_expected.not_to contain_file('/etc/systemd/system/rabbitmq-server.service.d/limits.conf') }
+ it { is_expected.not_to contain_exec('rabbitmq-systemd-reload') }
end
context 'with admin_enable set to true' do
end
end
- describe 'rabbitmq-loopback_users by default' do
- it 'sets the loopback_users parameter in the config file' do
- is_expected.to contain_file('rabbitmq.config'). \
- with_content(%r{\{loopback_users, \[<<"guest">>\]\}})
- end
- end
-
- describe 'rabbitmq-loopback_users allow connections via loopback interfaces' do
- let(:params) { { loopback_users: [] } }
-
- it 'sets the loopback_users parameter in the config file' do
- is_expected.to contain_file('rabbitmq.config'). \
- with_content(%r{\{loopback_users, \[\]\}})
- end
- end
-
- describe 'rabbitmq-loopback_users allow connections via loopback interfaces to a group of users' do
- let(:params) { { loopback_users: %w[user1 user2] } }
-
- it 'sets the loopback_users parameter in the config file' do
- is_expected.to contain_file('rabbitmq.config'). \
- with_content(%r{\{loopback_users, \[<<\"user1\">>, <<\"user2\">>\]\}})
- end
- end
-
##
## rabbitmq::service
##
'ensure' => 'running',
'enable' => 'true',
'hasstatus' => 'true',
- 'hasrestart' => 'true',
- 'name' => name
+ 'hasrestart' => 'true'
)
}
end
- context 'on systems with systemd', if: facts[:systemd] do
- it do
- is_expected.to contain_service('rabbitmq-server').
- that_requires('Class[systemd::systemctl::daemon_reload]')
- end
- end
-
describe 'service with ensure stopped' do
let :params do
{ service_ensure: 'stopped' }