serverspec 1.4.2 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/Rakefile +1 -1
- data/lib/serverspec/helper/os.rb +2 -0
- data/lib/serverspec/setup.rb +11 -12
- data/lib/serverspec/version.rb +1 -1
- data/serverspec.gemspec +1 -1
- data/spec/fedora/cgroup_spec.rb +14 -0
- data/spec/fedora/command_spec.rb +67 -0
- data/spec/fedora/cron_spec.rb +21 -0
- data/spec/fedora/default_gateway_spec.rb +16 -0
- data/spec/fedora/file_spec.rb +413 -0
- data/spec/fedora/group_spec.rb +21 -0
- data/spec/fedora/host_spec.rb +58 -0
- data/spec/fedora/interface_spec.rb +24 -0
- data/spec/fedora/iptables_spec.rb +21 -0
- data/spec/fedora/kernel_module_spec.rb +12 -0
- data/spec/fedora/linux_kernel_parameter_spec.rb +36 -0
- data/spec/fedora/lxc_spec.rb +22 -0
- data/spec/fedora/mail_alias_spec.rb +12 -0
- data/spec/fedora/package_spec.rb +118 -0
- data/spec/fedora/php_config_spec.rb +36 -0
- data/spec/fedora/port_spec.rb +30 -0
- data/spec/fedora/process_spec.rb +41 -0
- data/spec/fedora/routing_table_spec.rb +120 -0
- data/spec/fedora/selinux_spec.rb +18 -0
- data/spec/fedora/service_spec.rb +188 -0
- data/spec/fedora/user_spec.rb +57 -0
- data/spec/fedora/yumrepo_spec.rb +25 -0
- data/spec/fedora/zfs_spec.rb +18 -0
- data/spec/redhat7/service_spec.rb +21 -0
- metadata +52 -4
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include SpecInfra::Helper::Fedora
|
4
|
+
|
5
|
+
describe group('root') do
|
6
|
+
it { should exist }
|
7
|
+
its(:command) { should eq "getent group | grep -wq -- root" }
|
8
|
+
end
|
9
|
+
|
10
|
+
describe group('invalid-group') do
|
11
|
+
it { should_not exist }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe group('root') do
|
15
|
+
it { should have_gid 0 }
|
16
|
+
its(:command) { should eq "getent group | grep -w -- \\^root | cut -f 3 -d ':' | grep -w -- 0" }
|
17
|
+
end
|
18
|
+
|
19
|
+
describe group('root') do
|
20
|
+
it { should_not have_gid 'invalid-gid' }
|
21
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include SpecInfra::Helper::Fedora
|
4
|
+
|
5
|
+
describe host('127.0.0.1') do
|
6
|
+
it { should be_resolvable }
|
7
|
+
its(:command) { should eq "getent hosts 127.0.0.1" }
|
8
|
+
end
|
9
|
+
|
10
|
+
describe host('invalid-name') do
|
11
|
+
it { should_not be_resolvable }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe host('127.0.0.1') do
|
15
|
+
it { should be_resolvable.by('hosts') }
|
16
|
+
its(:command) { should eq "grep -w -- 127.0.0.1 /etc/hosts" }
|
17
|
+
end
|
18
|
+
|
19
|
+
describe host('invalid-name') do
|
20
|
+
it { should_not be_resolvable.by('hosts') }
|
21
|
+
end
|
22
|
+
|
23
|
+
describe host('127.0.0.1') do
|
24
|
+
it { should be_resolvable.by('dns') }
|
25
|
+
its(:command) { should eq "nslookup -timeout=1 127.0.0.1" }
|
26
|
+
end
|
27
|
+
|
28
|
+
describe host('invalid-name') do
|
29
|
+
it { should_not be_resolvable.by('dns') }
|
30
|
+
end
|
31
|
+
|
32
|
+
describe host('127.0.0.1') do
|
33
|
+
it { should be_reachable }
|
34
|
+
its(:command) { should eq "ping -w 5 -c 2 -n 127.0.0.1" }
|
35
|
+
end
|
36
|
+
|
37
|
+
describe host('invalid-host') do
|
38
|
+
it { should_not be_reachable }
|
39
|
+
end
|
40
|
+
|
41
|
+
describe host('127.0.0.1') do
|
42
|
+
it { should be_reachable.with(:proto => "icmp", :timeout=> 1) }
|
43
|
+
its(:command) { should eq "ping -w 1 -c 2 -n 127.0.0.1" }
|
44
|
+
end
|
45
|
+
|
46
|
+
describe host('127.0.0.1') do
|
47
|
+
it { should be_reachable.with(:proto => "tcp", :port => 22, :timeout=> 1) }
|
48
|
+
its(:command) { should eq "nc -vvvvzt 127.0.0.1 22 -w 1" }
|
49
|
+
end
|
50
|
+
|
51
|
+
describe host('127.0.0.1') do
|
52
|
+
it { should be_reachable.with(:proto => "udp", :port => 53, :timeout=> 1) }
|
53
|
+
its(:command) { should eq "nc -vvvvzu 127.0.0.1 53 -w 1" }
|
54
|
+
end
|
55
|
+
|
56
|
+
describe host('invalid-host') do
|
57
|
+
it { should_not be_reachable.with(:proto => "udp", :port => 53, :timeout=> 1) }
|
58
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include SpecInfra::Helper::Fedora
|
4
|
+
|
5
|
+
describe interface('eth0') do
|
6
|
+
let(:stdout) { '1000' }
|
7
|
+
its(:speed) { should eq 1000 }
|
8
|
+
its(:command) { should eq "ethtool eth0 | grep Speed | gawk '{print gensub(/Speed: ([0-9]+)Mb\\/s/,\"\\\\1\",\"\")}'" }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe interface('eth0') do
|
12
|
+
it { should have_ipv4_address("192.168.10.10") }
|
13
|
+
its(:command) { should eq "ip addr show eth0 | grep 'inet 192\\.168\\.10\\.10/'" }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe interface('eth0') do
|
17
|
+
it { should have_ipv4_address("192.168.10.10/24") }
|
18
|
+
its(:command) { should eq "ip addr show eth0 | grep 'inet 192\\.168\\.10\\.10/24 '" }
|
19
|
+
end
|
20
|
+
|
21
|
+
describe interface('invalid-interface') do
|
22
|
+
let(:stdout) { '1000' }
|
23
|
+
its(:speed) { should_not eq 100 }
|
24
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include SpecInfra::Helper::Fedora
|
4
|
+
|
5
|
+
describe iptables do
|
6
|
+
it { should have_rule '-P INPUT ACCEPT' }
|
7
|
+
its(:command) { should eq "iptables -S | grep -- -P\\ INPUT\\ ACCEPT || iptables-save | grep -- -P\\ INPUT\\ ACCEPT" }
|
8
|
+
end
|
9
|
+
|
10
|
+
describe iptables do
|
11
|
+
it { should_not have_rule 'invalid-rule' }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe iptables do
|
15
|
+
it { should have_rule('-P INPUT ACCEPT').with_table('mangle').with_chain('INPUT') }
|
16
|
+
its(:command) { should eq "iptables -t mangle -S INPUT | grep -- -P\\ INPUT\\ ACCEPT || iptables-save -t mangle | grep -- -P\\ INPUT\\ ACCEPT" }
|
17
|
+
end
|
18
|
+
|
19
|
+
describe iptables do
|
20
|
+
it { should_not have_rule('invalid-rule').with_table('mangle').with_chain('INPUT') }
|
21
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include SpecInfra::Helper::Fedora
|
4
|
+
|
5
|
+
describe kernel_module('lp') do
|
6
|
+
it { should be_loaded }
|
7
|
+
its(:command) { should eq "lsmod | grep ^lp" }
|
8
|
+
end
|
9
|
+
|
10
|
+
describe kernel_module('invalid-module') do
|
11
|
+
it { should_not be_loaded }
|
12
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include SpecInfra::Helper::Fedora
|
4
|
+
|
5
|
+
describe linux_kernel_parameter('net.ipv4.tcp_syncookies') do
|
6
|
+
let(:stdout) { "1\n" }
|
7
|
+
its(:value) { should eq 1 }
|
8
|
+
its(:command) { should eq "/sbin/sysctl -q -n net.ipv4.tcp_syncookies" }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe linux_kernel_parameter('net.ipv4.tcp_syncookies') do
|
12
|
+
let(:stdout) { "1\n" }
|
13
|
+
its(:value) { should_not eq 2 }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe linux_kernel_parameter('kernel.osrelease') do
|
17
|
+
let(:stdout) { "2.6.32-131.0.15.el6.x86_64\n" }
|
18
|
+
its(:value) { should eq "2.6.32-131.0.15.el6.x86_64" }
|
19
|
+
its(:command) { should eq "/sbin/sysctl -q -n kernel.osrelease" }
|
20
|
+
end
|
21
|
+
|
22
|
+
describe linux_kernel_parameter('kernel.osrelease') do
|
23
|
+
let(:stdout) { "2.6.32-131.0.15.el6.x86_64\n" }
|
24
|
+
its(:value) { should_not eq "2.6.32-131.0.15.el6.i386" }
|
25
|
+
end
|
26
|
+
|
27
|
+
describe linux_kernel_parameter('net.ipv4.tcp_wmem') do
|
28
|
+
let(:stdout) { "4096 16384 4194304\n" }
|
29
|
+
its(:value) { should match /16384/ }
|
30
|
+
its(:command) { should eq "/sbin/sysctl -q -n net.ipv4.tcp_wmem" }
|
31
|
+
end
|
32
|
+
|
33
|
+
describe linux_kernel_parameter('net.ipv4.tcp_wmem') do
|
34
|
+
let(:stdout) { "4096 16384 4194304\n" }
|
35
|
+
its(:value) { should_not match /123456/ }
|
36
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include SpecInfra::Helper::Fedora
|
4
|
+
|
5
|
+
describe lxc('ct01') do
|
6
|
+
it { should exist }
|
7
|
+
its(:command) { should eq "lxc-ls -1 | grep -w ct01" }
|
8
|
+
end
|
9
|
+
|
10
|
+
describe lxc('invalid-ct') do
|
11
|
+
it { should_not exist }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe lxc('ct01') do
|
15
|
+
it { should be_running }
|
16
|
+
its(:command) { should eq "lxc-info -n ct01 -t RUNNING"}
|
17
|
+
end
|
18
|
+
|
19
|
+
describe lxc('invalid-ct') do
|
20
|
+
it { should_not be_running }
|
21
|
+
end
|
22
|
+
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include SpecInfra::Helper::Fedora
|
4
|
+
|
5
|
+
describe mail_alias('daemon') do
|
6
|
+
it { should be_aliased_to "root" }
|
7
|
+
its(:command) { should eq "getent aliases daemon | grep -- \\[\\[:space:\\]\\]root$" }
|
8
|
+
end
|
9
|
+
|
10
|
+
describe mail_alias('invalid-recipient') do
|
11
|
+
it { should_not be_aliased_to "foo" }
|
12
|
+
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include SpecInfra::Helper::Fedora
|
4
|
+
|
5
|
+
describe package('httpd') do
|
6
|
+
it { should be_installed }
|
7
|
+
its(:command) { should eq "rpm -q httpd" }
|
8
|
+
end
|
9
|
+
|
10
|
+
describe package('invalid-package') do
|
11
|
+
it { should_not be_installed }
|
12
|
+
end
|
13
|
+
|
14
|
+
package('invalid-package') do
|
15
|
+
it { should_not be_installed.by('rpm') }
|
16
|
+
end
|
17
|
+
|
18
|
+
describe package('httpd') do
|
19
|
+
it { should be_installed.with_version('2.2.15-28.el6') }
|
20
|
+
its(:command) { should eq "rpm -q httpd | grep -w -- 2.2.15-28.el6" }
|
21
|
+
end
|
22
|
+
|
23
|
+
describe package('httpd') do
|
24
|
+
it { should be_installed.by('rpm').with_version('2.2.15-28.el6') }
|
25
|
+
its(:command) { should eq "rpm -q httpd | grep -w -- 2.2.15-28.el6" }
|
26
|
+
end
|
27
|
+
|
28
|
+
describe package('httpd') do
|
29
|
+
it { should_not be_installed.with_version('invalid-version') }
|
30
|
+
end
|
31
|
+
|
32
|
+
describe package('jekyll') do
|
33
|
+
it { should be_installed.by('gem') }
|
34
|
+
its(:command) { should eq "gem list --local | grep -w -- \\^jekyll" }
|
35
|
+
end
|
36
|
+
|
37
|
+
describe package('invalid-gem') do
|
38
|
+
it { should_not be_installed.by('gem') }
|
39
|
+
end
|
40
|
+
|
41
|
+
describe package('jekyll') do
|
42
|
+
it { should be_installed.by('gem').with_version('1.1.1') }
|
43
|
+
its(:command) { should eq "gem list --local | grep -w -- \\^jekyll | grep -w -- 1.1.1" }
|
44
|
+
end
|
45
|
+
|
46
|
+
describe package('jekyll') do
|
47
|
+
it { should_not be_installed.by('gem').with_version('invalid-version') }
|
48
|
+
end
|
49
|
+
|
50
|
+
describe package('bower') do
|
51
|
+
it { should be_installed.by('npm') }
|
52
|
+
its(:command) { should eq "npm ls bower -g" }
|
53
|
+
end
|
54
|
+
|
55
|
+
describe package('invalid-npm-package') do
|
56
|
+
it { should_not be_installed.by('npm') }
|
57
|
+
end
|
58
|
+
|
59
|
+
describe package('bower') do
|
60
|
+
it { should be_installed.by('npm').with_version('0.9.2') }
|
61
|
+
its(:command) { should eq "npm ls bower -g | grep -w -- 0.9.2" }
|
62
|
+
end
|
63
|
+
|
64
|
+
describe package('bower') do
|
65
|
+
it { should_not be_installed.by('npm').with_version('invalid-version') }
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
describe package('mongo') do
|
70
|
+
it { should be_installed.by('pecl') }
|
71
|
+
its(:command) { should eq "pecl list | grep -w -- \\^mongo" }
|
72
|
+
end
|
73
|
+
|
74
|
+
describe package('invalid-pecl') do
|
75
|
+
it { should_not be_installed.by('pecl') }
|
76
|
+
end
|
77
|
+
|
78
|
+
describe package('mongo') do
|
79
|
+
it { should be_installed.by('pecl').with_version('1.4.1') }
|
80
|
+
its(:command) { should eq "pecl list | grep -w -- \\^mongo | grep -w -- 1.4.1" }
|
81
|
+
end
|
82
|
+
|
83
|
+
describe package('mongo') do
|
84
|
+
it { should_not be_installed.by('pecl').with_version('invalid-version') }
|
85
|
+
end
|
86
|
+
|
87
|
+
describe package('XML_Util') do
|
88
|
+
it { should be_installed.by('pear').with_version('1.2.1') }
|
89
|
+
its(:command) { should eq "pear list | grep -w -- \\^XML_Util | grep -w -- 1.2.1" }
|
90
|
+
end
|
91
|
+
|
92
|
+
describe package('supervisor') do
|
93
|
+
it { should be_installed.by('pip').with_version('3.0') }
|
94
|
+
its(:command) { should eq "pip list | grep -w -- \\^supervisor | grep -w -- 3.0" }
|
95
|
+
end
|
96
|
+
|
97
|
+
describe package('invalid-pip') do
|
98
|
+
it { should_not be_installed.by('pip').with_version('invalid-version') }
|
99
|
+
end
|
100
|
+
|
101
|
+
describe package('App::Ack') do
|
102
|
+
it { should be_installed.by('cpan') }
|
103
|
+
its(:command) { should eq "cpan -l | grep -w -- \\^App::Ack" }
|
104
|
+
end
|
105
|
+
|
106
|
+
describe package('App::Ack') do
|
107
|
+
it { should be_installed.by('cpan').with_version('2.04') }
|
108
|
+
its(:command) { should eq "cpan -l | grep -w -- \\^App::Ack | grep -w -- 2.04" }
|
109
|
+
end
|
110
|
+
|
111
|
+
describe package('httpd') do
|
112
|
+
let(:stdout) { "2.2.15\n" }
|
113
|
+
its(:version) { should eq '2.2.15' }
|
114
|
+
its(:version) { should > '2.2.14' }
|
115
|
+
its(:version) { should < '2.2.16' }
|
116
|
+
its(:version) { should > '2.2.9' }
|
117
|
+
its(:command) { should eq "rpm -qi httpd | grep Version | awk '{print $3}'" }
|
118
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include SpecInfra::Helper::Fedora
|
4
|
+
|
5
|
+
describe php_config('default_mimetype') do
|
6
|
+
let(:stdout) { 'text/html' }
|
7
|
+
its(:value) { should eq 'text/html' }
|
8
|
+
its(:command) { should eq "php -r 'echo get_cfg_var( \"default_mimetype\" );'" }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe php_config('default_mimetype') do
|
12
|
+
let(:stdout) { 'text/html' }
|
13
|
+
its(:value) { should_not eq 'text/plain' }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe php_config('session.cache_expire') do
|
17
|
+
let(:stdout) { '180' }
|
18
|
+
its(:value) { should eq 180 }
|
19
|
+
its(:command) { should eq "php -r 'echo get_cfg_var( \"session.cache_expire\" );'" }
|
20
|
+
end
|
21
|
+
|
22
|
+
describe php_config('session.cache_expire') do
|
23
|
+
let(:stdout) { '180' }
|
24
|
+
its(:value) { should_not eq 360 }
|
25
|
+
end
|
26
|
+
|
27
|
+
describe php_config('mbstring.http_output_conv_mimetypes') do
|
28
|
+
let(:stdout) { 'application' }
|
29
|
+
its(:value) { should match /application/ }
|
30
|
+
its(:command) { should eq "php -r 'echo get_cfg_var( \"mbstring.http_output_conv_mimetypes\" );'" }
|
31
|
+
end
|
32
|
+
|
33
|
+
describe php_config('mbstring.http_output_conv_mimetypes') do
|
34
|
+
let(:stdout) { 'application' }
|
35
|
+
its(:value) { should_not match /html/ }
|
36
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include SpecInfra::Helper::Fedora
|
4
|
+
|
5
|
+
describe port(80) do
|
6
|
+
it { should be_listening }
|
7
|
+
its(:command) { should eq 'netstat -tunl | grep -- :80\\ ' }
|
8
|
+
end
|
9
|
+
|
10
|
+
describe port('invalid') do
|
11
|
+
it { should_not be_listening }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe port(80) do
|
15
|
+
it { should be_listening.with("tcp") }
|
16
|
+
its(:command) { should eq 'netstat -tunl | grep -- \\^tcp\\ .\\*:80\\ ' }
|
17
|
+
end
|
18
|
+
|
19
|
+
describe port(123) do
|
20
|
+
it { should be_listening.with("udp") }
|
21
|
+
its(:command) { should eq 'netstat -tunl | grep -- \\^udp\\ .\\*:123\\ ' }
|
22
|
+
end
|
23
|
+
|
24
|
+
describe port(80) do
|
25
|
+
it {
|
26
|
+
expect {
|
27
|
+
should be_listening.with('not implemented')
|
28
|
+
}.to raise_error(ArgumentError, %r/\A`be_listening` matcher doesn\'t support/)
|
29
|
+
}
|
30
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include SpecInfra::Helper::Fedora
|
4
|
+
|
5
|
+
describe process("memcached") do
|
6
|
+
let(:stdout) { " 1407\n" }
|
7
|
+
its(:pid) { should eq 1407 }
|
8
|
+
its(:command) { should eq "ps -C memcached -o pid= | head -1" }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe process("memcached") do
|
12
|
+
let(:stdout) { "/usr/bin/memcached -m 14386 -p 11211 -u nobody -l 10.11.1.53 -c 30000\n" }
|
13
|
+
its(:args) { should match /-c 30000\b/ }
|
14
|
+
its(:command) { should eq "ps -C memcached -o args= | head -1" }
|
15
|
+
end
|
16
|
+
|
17
|
+
describe process("memcached") do
|
18
|
+
let(:stdout) { "nobody\n" }
|
19
|
+
its(:user) { should eq "nobody" }
|
20
|
+
its(:command) { should eq "ps -C memcached -o user= | head -1" }
|
21
|
+
end
|
22
|
+
|
23
|
+
describe process("memcached") do
|
24
|
+
let(:stdout) { "nobody\n" }
|
25
|
+
its(:group) { should eq "nobody" }
|
26
|
+
its(:command) { should eq "ps -C memcached -o group= | head -1" }
|
27
|
+
end
|
28
|
+
|
29
|
+
describe process("memcached") do
|
30
|
+
context "when running" do
|
31
|
+
let(:stdout) { " 1407\n" }
|
32
|
+
it { should be_running }
|
33
|
+
its(:command) { should eq "ps -C memcached -o pid= | head -1" }
|
34
|
+
end
|
35
|
+
|
36
|
+
context "when not running" do
|
37
|
+
let(:stdout) { " 1407\n" }
|
38
|
+
it { should be_running }
|
39
|
+
its(:command) { should eq "ps -C memcached -o pid= | head -1" }
|
40
|
+
end
|
41
|
+
end
|