3 describe 'systemd::service_limits' do
4 context 'supported operating systems' do
5 on_supported_os.each do |os, facts|
9 let(:title) { 'test.service' }
11 describe 'with limits and present' do
15 'LimitFSIZE' => 'infinity',
17 'LimitNOFILE' => '20:infinity',
21 {'/dev/weight' => 10},
22 {'/dev/weight2' => 20}
24 'IOReadBandwidthMax' => [
30 it { is_expected.to compile.with_all_deps }
31 it { is_expected.to create_file("/etc/systemd/system/#{title}.d/90-limits.conf").with(
33 :content => /LimitCPU=10m/,
36 it { is_expected.to create_file("/etc/systemd/system/#{title}.d/90-limits.conf").with(
37 :content => /LimitFSIZE=infinity/
39 it { is_expected.to create_file("/etc/systemd/system/#{title}.d/90-limits.conf").with(
40 :content => /LimitDATA=10K/
42 it { is_expected.to create_file("/etc/systemd/system/#{title}.d/90-limits.conf").with(
43 :content => /LimitNOFILE=20:infinity/
45 it { is_expected.to create_file("/etc/systemd/system/#{title}.d/90-limits.conf").with(
46 :content => /LimitNICE=-10/
48 it { is_expected.to create_file("/etc/systemd/system/#{title}.d/90-limits.conf").with(
49 :content => /LimitRTPRIO=50/
51 it { is_expected.to create_file("/etc/systemd/system/#{title}.d/90-limits.conf").with(
52 :content => %r(IODeviceWeight=/dev/weight 10)
54 it { is_expected.to create_file("/etc/systemd/system/#{title}.d/90-limits.conf").with(
55 :content => %r(IODeviceWeight=/dev/weight2 20)
57 it { is_expected.to create_file("/etc/systemd/system/#{title}.d/90-limits.conf").with(
58 :content => %r(IOReadBandwidthMax=/bw/max 10K)
60 it { is_expected.to create_exec("restart #{title} because limits").with(
61 :command => "systemctl restart #{title}",
66 describe 'ensured absent' do
71 it { is_expected.to compile.with_all_deps }
73 is_expected.to create_file("/etc/systemd/system/#{title}.d/90-limits.conf")
74 .with_ensure('absent')
75 .that_notifies("Exec[restart #{title} because limits]")
78 is_expected.to create_exec("restart #{title} because limits")
79 .with_command("systemctl restart #{title}")
80 .with_refreshonly(true)