forked from aws/opsworks-cookbooks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathraids_spec.rb
67 lines (57 loc) · 2.11 KB
/
raids_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
require 'minitest/spec'
describe_recipe 'ebs::raids' do
include MiniTest::Chef::Resources
include MiniTest::Chef::Assertions
describe 'packages' do
it 'installs packages for software RAID and volume management' do
package('mdadm').must_be_installed
package('lvm2').must_be_installed
end
end
describe 'kernel modules' do
it 'loads device-mapper' do
assert system("cat /proc/misc | grep -q device-mapper"), "device-mapper wasn't loaded"
end
it 'uses the raid personality' do
node[:ebs][:raids].each do |_, options|
assert system("cat /proc/mdstat | grep -q 'Personalities.*[raid#{options[:raid_level]}]'"), "personality raid#{options} isn't used"
end
end
end
describe 'files' do
it 'creates mdadm.conf' do
case node[:platform_family]
when 'rhel'
file('/etc/mdadm.conf').must_exist.with(:mode, '644').and(:owner, 'root').and(
:group, 'root')
when 'debian'
file('/etc/mdadm/mdadm.conf').must_exist.with(:mode, '644').and(
:owner, 'root').and(:group, 'root')
end
end
describe 'rc.local' do
it 'replaces rc.local with mdadm specific things' do
file('/etc/rc.local').must_include 'modprobe dm-mod'
file('/etc/rc.local').must_include 'vgchange -ay'
end
it 'will touch /var/lock/subsys/local if it is a RHEL based machine, will not touch the file if it is not' do
case node[:platform_family]
when 'rhel'
file('/etc/rc.local').must_include "/var/lock/subsys/local"
when 'debian'
file('/etc/rc.local').wont_include '/var/lock/subsys/local'
end
end
end
end
describe 'mount points' do
it 'mounts LVMs to mount points' do
node[:ebs][:raids].each do |raid_device, options|
mount_point = options[:mount_point]
device = "/dev/mapper/lvm--raid--#{raid_device.match(/\d+/)[0]}-lvm#{raid_device.match(/\d+/)[0]}"
mount(mount_point, :device => device).must_be_mounted
file('/proc/mounts').must_include("#{device} #{mount_point} #{options[:fstype]}")
end
end
end
end