2015-10-23 11:44:20 +00:00
|
|
|
# encoding: utf-8
|
2016-08-03 15:41:27 +00:00
|
|
|
if ENV['DOCKER']
|
|
|
|
STDERR.puts "\033[1;33mTODO: Not running #{__FILE__.split("/").last} because we are running in docker\033[0m"
|
|
|
|
return
|
|
|
|
end
|
2016-05-10 17:23:11 +00:00
|
|
|
|
2015-10-23 11:44:20 +00:00
|
|
|
# prepare values
|
2016-09-01 16:27:00 +00:00
|
|
|
if ['ubuntu', 'centos', 'fedora', 'opensuse', 'debian', 'suse'].include?(os[:name])
|
2015-10-23 11:44:20 +00:00
|
|
|
test_values = {
|
|
|
|
kernel_panic: 0,
|
|
|
|
ip_local_port_range: "32768\t61000",
|
|
|
|
forwarding: 0,
|
|
|
|
sched_autogroup_enabled: 1,
|
|
|
|
nf_log: 'NONE',
|
|
|
|
}
|
|
|
|
|
|
|
|
# configue parameter derivations for different OS
|
2016-09-01 16:27:00 +00:00
|
|
|
test_values[:sched_autogroup_enabled] = 0 if ['centos', 'debian'].include?(os[:name])
|
2015-10-23 11:44:20 +00:00
|
|
|
|
2016-09-01 16:27:00 +00:00
|
|
|
if (os[:name] == 'ubuntu' && os[:release].to_f == 10.04) ||
|
|
|
|
(os[:name] == 'debian' && os[:release].to_i == 6) ||
|
|
|
|
(os[:name] == 'centos' && os[:release].to_i == 5) ||
|
|
|
|
(os[:name] == 'opensuse') ||
|
|
|
|
(os[:name] == 'suse')
|
2015-10-23 11:44:20 +00:00
|
|
|
test_values[:sched_autogroup_enabled] = nil
|
|
|
|
end
|
|
|
|
|
2016-09-01 16:27:00 +00:00
|
|
|
test_values[:nf_log] = nil if os[:name] == 'centos' && os[:release].to_i == 5
|
|
|
|
test_values[:kernel_panic] = 90 if os[:name] == 'opensuse'
|
2015-10-23 11:44:20 +00:00
|
|
|
|
|
|
|
else
|
|
|
|
test_values = {}
|
|
|
|
end
|
|
|
|
|
|
|
|
# test on all linux systems
|
|
|
|
if os.linux?
|
|
|
|
describe kernel_parameter('kernel.panic') do
|
2016-05-03 22:14:33 +00:00
|
|
|
its('value') { should eq test_values[:kernel_panic] }
|
2015-10-23 11:44:20 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
describe kernel_parameter('net.netfilter.nf_log.0') do
|
2016-05-03 22:14:33 +00:00
|
|
|
its('value') { should eq test_values[:nf_log] }
|
2015-10-23 11:44:20 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
describe kernel_parameter('kernel.sched_autogroup_enabled') do
|
2016-05-03 22:14:33 +00:00
|
|
|
its('value') { should eq test_values[:sched_autogroup_enabled] }
|
2015-10-23 11:44:20 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
describe kernel_parameter('net.ipv4.ip_local_port_range') do
|
2016-05-03 22:14:33 +00:00
|
|
|
its('value') { should eq test_values[:ip_local_port_range] }
|
2015-10-23 11:44:20 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
describe kernel_parameter('net.ipv4.conf.all.forwarding') do
|
2016-05-03 22:14:33 +00:00
|
|
|
its('value') { should eq test_values[:forwarding] }
|
2015-10-23 11:44:20 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# serverspec compatability
|
|
|
|
describe linux_kernel_parameter('net.ipv4.conf.all.forwarding') do
|
2016-05-03 22:14:33 +00:00
|
|
|
its('value') { should eq test_values[:forwarding] }
|
2015-10-23 11:44:20 +00:00
|
|
|
end
|
|
|
|
end
|