serverspec 0.2.2 → 0.2.3
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.
- data/lib/serverspec/backend/exec.rb +5 -0
- data/lib/serverspec/commands/base.rb +4 -0
- data/lib/serverspec/matchers/be_installed.rb +21 -2
- data/lib/serverspec/matchers/be_installed_by_gem.rb +8 -0
- data/lib/serverspec/matchers/be_running.rb +16 -1
- data/lib/serverspec/version.rb +1 -1
- data/serverspec.gemspec +1 -1
- data/spec/debian/commands_spec.rb +4 -0
- data/spec/debian/matchers_spec.rb +3 -2
- data/spec/gentoo/commands_spec.rb +4 -0
- data/spec/gentoo/matchers_spec.rb +3 -2
- data/spec/redhat/commands_spec.rb +4 -0
- data/spec/redhat/matchers_spec.rb +4 -2
- data/spec/solaris/commads_spec.rb +4 -0
- data/spec/solaris/matchers_spec.rb +3 -2
- data/spec/support/shared_matcher_examples.rb +46 -8
- metadata +12 -12
@@ -79,6 +79,11 @@ module Serverspec
|
|
79
79
|
ret[:exit_code] == 0
|
80
80
|
end
|
81
81
|
|
82
|
+
def check_running_under_supervisor(process)
|
83
|
+
ret = do_check(commands.check_running_under_supervisor(process))
|
84
|
+
ret[:exit_code] == 0 && ret[:stdout] =~ /RUNNING/
|
85
|
+
end
|
86
|
+
|
82
87
|
def check_user(user)
|
83
88
|
check_zero(:check_user, user)
|
84
89
|
end
|
@@ -1,5 +1,24 @@
|
|
1
1
|
RSpec::Matchers.define :be_installed do
|
2
|
-
match do |
|
3
|
-
|
2
|
+
match do |name|
|
3
|
+
if @provider.nil?
|
4
|
+
backend.check_installed(name)
|
5
|
+
else
|
6
|
+
check_method = "check_installed_by_#{@provider}".to_sym
|
7
|
+
|
8
|
+
unless backend.respond_to?(check_method)
|
9
|
+
raise ArgumentError.new("`be_installed` matcher doesn't support #{@under}")
|
10
|
+
end
|
11
|
+
|
12
|
+
backend.send(check_method, name, @version)
|
13
|
+
end
|
4
14
|
end
|
15
|
+
|
16
|
+
chain :by do |provider|
|
17
|
+
@provider = provider
|
18
|
+
end
|
19
|
+
|
20
|
+
chain :with_version do |version|
|
21
|
+
@version = version
|
22
|
+
end
|
23
|
+
|
5
24
|
end
|
@@ -1,5 +1,13 @@
|
|
1
1
|
RSpec::Matchers.define :be_installed_by_gem do
|
2
2
|
match do |name|
|
3
|
+
puts <<EOF
|
4
|
+
|
5
|
+
***************************************************
|
6
|
+
The matcher be_isntalled_by_gem will be depricated.
|
7
|
+
Please use be_installed.by('gem') instead.
|
8
|
+
***************************************************
|
9
|
+
|
10
|
+
EOF
|
3
11
|
backend.check_installed_by_gem(name, @version)
|
4
12
|
end
|
5
13
|
chain :with_version do |version|
|
@@ -1,5 +1,20 @@
|
|
1
1
|
RSpec::Matchers.define :be_running do
|
2
2
|
match do |process|
|
3
|
-
|
3
|
+
if (@under)
|
4
|
+
check_method = "check_running_under_#{@under}".to_sym
|
5
|
+
|
6
|
+
unless backend.respond_to?(check_method)
|
7
|
+
raise ArgumentError.new("`be_running` matcher doesn't support #{@under}")
|
8
|
+
end
|
9
|
+
|
10
|
+
backend.send(check_method, process)
|
11
|
+
else
|
12
|
+
backend.check_running(process)
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
chain :under do |under|
|
18
|
+
@under = under
|
4
19
|
end
|
5
20
|
end
|
data/lib/serverspec/version.rb
CHANGED
data/serverspec.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_dependency "net-ssh"
|
22
|
+
spec.add_dependency "rspec"
|
22
23
|
spec.add_development_dependency "bundler", "~> 1.3"
|
23
|
-
spec.add_development_dependency "rspec"
|
24
24
|
spec.add_development_dependency "rake"
|
25
25
|
end
|
@@ -34,6 +34,10 @@ describe commands.check_running('httpd') do
|
|
34
34
|
it { should eq 'service httpd status' }
|
35
35
|
end
|
36
36
|
|
37
|
+
describe commands.check_running_under_supervisor('httpd') do
|
38
|
+
it { should eq 'supervisorctl status httpd' }
|
39
|
+
end
|
40
|
+
|
37
41
|
describe commands.check_process('httpd') do
|
38
42
|
it { should eq 'ps aux | grep -w httpd | grep -qv grep' }
|
39
43
|
end
|
@@ -4,6 +4,7 @@ describe 'Serverspec matchers of Debian family', :os => :debian do
|
|
4
4
|
it_behaves_like 'support be_enabled matcher', 'rc.local'
|
5
5
|
it_behaves_like 'support be_installed matcher', 'openssh-server'
|
6
6
|
it_behaves_like 'support be_running matcher', 'ssh'
|
7
|
+
it_behaves_like 'support be_running.under("supervisor") matcher', 'growthforecast'
|
7
8
|
it_behaves_like 'support be_listening matcher', 22
|
8
9
|
it_behaves_like 'support be_file matcher', '/etc/ssh/sshd_config'
|
9
10
|
it_behaves_like 'support contain matcher', '/etc/ssh/sshd_config', 'See the sshd_config(5) manpage'
|
@@ -26,8 +27,8 @@ describe 'Serverspec matchers of Debian family', :os => :debian do
|
|
26
27
|
|
27
28
|
it_behaves_like 'support be_linked_to matcher', '/etc/pam.d/system-auth', '/etc/pam.d/system-auth-ac'
|
28
29
|
|
29
|
-
it_behaves_like 'support
|
30
|
-
it_behaves_like 'support
|
30
|
+
it_behaves_like 'support be_installed.by(gem) matcher', 'jekyll'
|
31
|
+
it_behaves_like 'support be_installed.by(gem).with_version matcher', 'jekyll', '1.0.0'
|
31
32
|
|
32
33
|
it_behaves_like 'support belong_to_group matcher', 'root', 'root'
|
33
34
|
|
@@ -34,6 +34,10 @@ describe commands.check_running('httpd') do
|
|
34
34
|
it { should eq 'service httpd status' }
|
35
35
|
end
|
36
36
|
|
37
|
+
describe commands.check_running_under_supervisor('httpd') do
|
38
|
+
it { should eq 'supervisorctl status httpd' }
|
39
|
+
end
|
40
|
+
|
37
41
|
describe commands.check_process('httpd') do
|
38
42
|
it { should eq 'ps aux | grep -w httpd | grep -qv grep' }
|
39
43
|
end
|
@@ -4,6 +4,7 @@ describe 'Serverspec matchers of Gentoo family', :os => :gentoo do
|
|
4
4
|
it_behaves_like 'support be_enabled matcher', 'sshd'
|
5
5
|
it_behaves_like 'support be_installed matcher', 'openssh'
|
6
6
|
it_behaves_like 'support be_running matcher', 'sshd'
|
7
|
+
it_behaves_like 'support be_running.under("supervisor") matcher', 'growthforecast'
|
7
8
|
it_behaves_like 'support be_listening matcher', 22
|
8
9
|
it_behaves_like 'support be_file matcher', '/etc/ssh/sshd_config'
|
9
10
|
it_behaves_like 'support be_directory matcher', '/etc/ssh'
|
@@ -27,8 +28,8 @@ describe 'Serverspec matchers of Gentoo family', :os => :gentoo do
|
|
27
28
|
|
28
29
|
it_behaves_like 'support be_linked_to matcher', '/etc/pam.d/system-auth', '/etc/pam.d/system-auth-ac'
|
29
30
|
|
30
|
-
it_behaves_like 'support
|
31
|
-
it_behaves_like 'support
|
31
|
+
it_behaves_like 'support be_installed.by(gem) matcher', 'jekyll'
|
32
|
+
it_behaves_like 'support be_installed.by(gem).with_version matcher', 'jekyll', '1.0.0'
|
32
33
|
|
33
34
|
it_behaves_like 'support belong_to_group matcher', 'root', 'root'
|
34
35
|
|
@@ -34,6 +34,10 @@ describe commands.check_running('httpd') do
|
|
34
34
|
it { should eq 'service httpd status' }
|
35
35
|
end
|
36
36
|
|
37
|
+
describe commands.check_running_under_supervisor('httpd') do
|
38
|
+
it { should eq 'supervisorctl status httpd' }
|
39
|
+
end
|
40
|
+
|
37
41
|
describe commands.check_process('httpd') do
|
38
42
|
it { should eq 'ps aux | grep -w httpd | grep -qv grep' }
|
39
43
|
end
|
@@ -4,6 +4,8 @@ describe 'Serverspec matchers of Red Hat family', :os => :redhat do
|
|
4
4
|
it_behaves_like 'support be_enabled matcher', 'sshd'
|
5
5
|
it_behaves_like 'support be_installed matcher', 'openssh'
|
6
6
|
it_behaves_like 'support be_running matcher', 'sshd'
|
7
|
+
it_behaves_like 'support be_running.under("supervisor") matcher', 'growthforecast'
|
8
|
+
it_behaves_like 'support be_running.under("not implemented") matcher', 'growthforecast'
|
7
9
|
it_behaves_like 'support be_listening matcher', 22
|
8
10
|
it_behaves_like 'support be_file matcher', '/etc/ssh/sshd_config'
|
9
11
|
it_behaves_like 'support be_directory matcher', '/etc/ssh'
|
@@ -27,8 +29,8 @@ describe 'Serverspec matchers of Red Hat family', :os => :redhat do
|
|
27
29
|
|
28
30
|
it_behaves_like 'support be_linked_to matcher', '/etc/pam.d/system-auth', '/etc/pam.d/system-auth-ac'
|
29
31
|
|
30
|
-
it_behaves_like 'support
|
31
|
-
it_behaves_like 'support
|
32
|
+
it_behaves_like 'support be_installed.by(gem) matcher', 'jekyll'
|
33
|
+
it_behaves_like 'support be_installed.by(gem).with_version matcher', 'jekyll', '1.0.0'
|
32
34
|
|
33
35
|
it_behaves_like 'support belong_to_group matcher', 'root', 'root'
|
34
36
|
|
@@ -34,6 +34,10 @@ describe commands.check_running('httpd') do
|
|
34
34
|
it { should eq "svcs -l httpd status 2> /dev/null |grep 'state online'" }
|
35
35
|
end
|
36
36
|
|
37
|
+
describe commands.check_running_under_supervisor('httpd') do
|
38
|
+
it { should eq 'supervisorctl status httpd' }
|
39
|
+
end
|
40
|
+
|
37
41
|
describe commands.check_process('httpd') do
|
38
42
|
it { should eq 'ps aux | grep -w httpd | grep -qv grep' }
|
39
43
|
end
|
@@ -4,6 +4,7 @@ describe 'Serverspec matchers of Solaris family', :os => :solaris do
|
|
4
4
|
it_behaves_like 'support be_enabled matcher', 'svc:/network/ssh:default'
|
5
5
|
it_behaves_like 'support be_installed matcher', 'service/network/ssh'
|
6
6
|
it_behaves_like 'support be_running matcher', 'svc:/network/ssh:default'
|
7
|
+
it_behaves_like 'support be_running.under("supervisor") matcher', 'growthforecast'
|
7
8
|
it_behaves_like 'support be_listening matcher', 22
|
8
9
|
it_behaves_like 'support be_file matcher', '/etc/ssh/sshd_config'
|
9
10
|
it_behaves_like 'support be_directory matcher', '/etc/ssh'
|
@@ -27,8 +28,8 @@ describe 'Serverspec matchers of Solaris family', :os => :solaris do
|
|
27
28
|
|
28
29
|
it_behaves_like 'support be_linked_to matcher', '/etc/pam.d/system-auth', '/etc/pam.d/system-auth-ac'
|
29
30
|
|
30
|
-
it_behaves_like 'support
|
31
|
-
it_behaves_like 'support
|
31
|
+
it_behaves_like 'support be_installed.by(gem) matcher', 'jekyll'
|
32
|
+
it_behaves_like 'support be_installed.by(gem).with_version matcher', 'jekyll', '1.0.0'
|
32
33
|
|
33
34
|
it_behaves_like 'support belong_to_group matcher', 'root', 'root'
|
34
35
|
|
@@ -44,6 +44,44 @@ shared_examples_for 'support be_running matcher' do |valid_service|
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
+
shared_examples_for 'support be_running.under("supervisor") matcher' do |valid_service|
|
48
|
+
describe 'be_running.under("supervisor")' do
|
49
|
+
describe valid_service do
|
50
|
+
before :all do
|
51
|
+
RSpec.configure do |c|
|
52
|
+
c.stdout = "#{valid_service} RUNNING\r\n"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
it { should be_running.under('supervisor') }
|
57
|
+
end
|
58
|
+
|
59
|
+
describe valid_service do
|
60
|
+
before :all do
|
61
|
+
RSpec.configure do |c|
|
62
|
+
c.stdout = "#{valid_service} STOPPED\r\n"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
it { should_not be_running.under('supervisor') }
|
67
|
+
end
|
68
|
+
|
69
|
+
describe 'this-is-invalid-daemon' do
|
70
|
+
it { should_not be_running.under('supervisor') }
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
shared_examples_for 'support be_running.under("not implemented") matcher' do |valid_service|
|
76
|
+
describe 'be_running.under("not implemented")' do
|
77
|
+
it {
|
78
|
+
expect {
|
79
|
+
should be_running.under('not implemented')
|
80
|
+
}.to raise_error(ArgumentError, %r/\A`be_running` matcher doesn't support/)
|
81
|
+
}
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
47
85
|
shared_examples_for 'support be_listening matcher' do |valid_port|
|
48
86
|
describe 'be_listening' do
|
49
87
|
describe "port #{ valid_port }" do
|
@@ -224,20 +262,20 @@ shared_examples_for 'support be_linked_to matcher' do |file, target|
|
|
224
262
|
end
|
225
263
|
end
|
226
264
|
|
227
|
-
shared_examples_for 'support
|
228
|
-
describe '
|
265
|
+
shared_examples_for 'support be_installed.by(gem) matcher' do |name|
|
266
|
+
describe 'be_installed.by(gem)' do
|
229
267
|
describe name do
|
230
|
-
it { should
|
268
|
+
it { should be_installed.by('gem') }
|
231
269
|
end
|
232
270
|
|
233
271
|
describe 'invalid-gem' do
|
234
|
-
it { should_not
|
272
|
+
it { should_not be_installed.by('gem') }
|
235
273
|
end
|
236
274
|
end
|
237
275
|
end
|
238
276
|
|
239
|
-
shared_examples_for 'support
|
240
|
-
describe '
|
277
|
+
shared_examples_for 'support be_installed.by(gem).with_version matcher' do |name, version|
|
278
|
+
describe 'be_installed.by(gem).with_version' do
|
241
279
|
before :all do
|
242
280
|
RSpec.configure do |c|
|
243
281
|
c.stdout = "#{name} (#{version})"
|
@@ -245,11 +283,11 @@ shared_examples_for 'support be_installed_by_gem.with_version matcher' do |name,
|
|
245
283
|
end
|
246
284
|
|
247
285
|
describe name do
|
248
|
-
it { should
|
286
|
+
it { should be_installed.by('gem').with_version(version) }
|
249
287
|
end
|
250
288
|
|
251
289
|
describe name do
|
252
|
-
it { should_not
|
290
|
+
it { should_not be_installed.by('gem').with_version('invalid-version') }
|
253
291
|
end
|
254
292
|
end
|
255
293
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: serverspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -28,37 +28,37 @@ dependencies:
|
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
|
-
name:
|
31
|
+
name: rspec
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
none: false
|
34
34
|
requirements:
|
35
|
-
- -
|
35
|
+
- - ! '>='
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: '
|
38
|
-
type: :
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
|
-
- -
|
43
|
+
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: '
|
45
|
+
version: '0'
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
|
-
name:
|
47
|
+
name: bundler
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
49
49
|
none: false
|
50
50
|
requirements:
|
51
|
-
- -
|
51
|
+
- - ~>
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
53
|
+
version: '1.3'
|
54
54
|
type: :development
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
none: false
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '1.3'
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: rake
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|