Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rely on voxpupuli-test to mock the service_provider fact #351

Merged
merged 2 commits into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions spec/classes/broker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
describe 'kafka::broker', type: :class do
on_supported_os.each do |os, os_facts|
context "on #{os}" do
os_facts = os_facts.merge({ service_provider: 'systemd' })

let(:facts) do
os_facts
end
Expand Down Expand Up @@ -60,7 +58,7 @@
end

context 'defaults' do
if os_facts[:service_provider] == 'systemd'
if os_facts['service_provider'] == 'systemd'
it { is_expected.to contain_file('/etc/init.d/kafka').with_ensure('absent') }
it { is_expected.not_to contain_file('/etc/systemd/system/kafka.service').with_content %r{^LimitNOFILE=} }
it { is_expected.not_to contain_file('/etc/systemd/system/kafka.service').with_content %r{^LimitCORE=} }
Expand All @@ -74,7 +72,7 @@
context 'limit_nofile set' do
let(:params) { super().merge(limit_nofile: '65536') }

if os_facts[:service_provider] == 'systemd'
if os_facts['service_provider'] == 'systemd'
it { is_expected.to contain_file('/etc/systemd/system/kafka.service').with_content %r{^LimitNOFILE=65536$} }
else
it { is_expected.to contain_file('/etc/init.d/kafka').with_content %r{ulimit -n 65536$} }
Expand All @@ -84,14 +82,14 @@
context 'limit_core set' do
let(:params) { super().merge(limit_core: 'infinity') }

if os_facts[:service_provider] == 'systemd'
if os_facts['service_provider'] == 'systemd'
it { is_expected.to contain_file('/etc/systemd/system/kafka.service').with_content %r{^LimitCORE=infinity$} }
else
it { is_expected.to contain_file('/etc/init.d/kafka').with_content %r{ulimit -c infinity$} }
end
end

context 'service_requires set', if: os_facts[:service_provider] == 'systemd' do
context 'service_requires set', if: os_facts['service_provider'] == 'systemd' do
let(:params) { super().merge(service_requires: ['dummy.target']) }

it { is_expected.to contain_file('/etc/systemd/system/kafka.service').with_content %r{^After=dummy\.target$} }
Expand Down
4 changes: 1 addition & 3 deletions spec/classes/consumer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
describe 'kafka::consumer', type: :class do
on_supported_os.each do |os, os_facts|
context "on #{os}" do
os_facts = os_facts.merge({ service_provider: 'systemd' })

let(:facts) do
os_facts
end
Expand Down Expand Up @@ -53,7 +51,7 @@

describe 'kafka::consumer::service' do
context 'defaults' do
if os_facts[:service_provider] == 'systemd'
if os_facts['service_provider'] == 'systemd'
it { is_expected.to contain_file('/etc/systemd/system/kafka-consumer.service') }
else
it { is_expected.to contain_file('/etc/init.d/kafka-consumer') }
Expand Down
4 changes: 1 addition & 3 deletions spec/classes/mirror_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
describe 'kafka::mirror', type: :class do
on_supported_os.each do |os, os_facts|
context "on #{os}" do
os_facts = os_facts.merge({ service_provider: 'systemd' })

let(:facts) do
os_facts
end
Expand Down Expand Up @@ -50,7 +48,7 @@

describe 'kafka::mirror::service' do
context 'defaults' do
if os_facts[:service_provider] == 'systemd'
if os_facts['service_provider'] == 'systemd'
it { is_expected.to contain_file('/etc/init.d/kafka-mirror').with_ensure('absent') }
it { is_expected.to contain_file('/etc/systemd/system/kafka-mirror.service').with_content %r{/opt/kafka/config/(?=.*consumer)|(?=.*producer).propertie} }
else
Expand Down
6 changes: 2 additions & 4 deletions spec/classes/producer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
describe 'kafka::producer', type: :class do
on_supported_os.each do |os, os_facts|
context "on #{os}" do
os_facts = os_facts.merge({ service_provider: 'systemd' })

let(:facts) do
os_facts
end
Expand All @@ -22,8 +20,8 @@
}
end

if os_facts[:service_provider] == 'systemd'
it { is_expected.to raise_error(Puppet::Error, %r{Console Producer is not supported on systemd, because the stdin of the process cannot be redirected}) }
if os_facts['service_provider'] == 'systemd'
it { is_expected.to compile.and_raise_error(%r{Console Producer is not supported on systemd, because the stdin of the process cannot be redirected}) }
else
it { is_expected.to contain_class('kafka::producer::install').that_comes_before('Class[kafka::producer::config]') }
it { is_expected.to contain_class('kafka::producer::config').that_comes_before('Class[kafka::producer::service]') }
Expand Down