specinfra 2.82.25 → 2.83.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/specinfra/command/darwin/base/inventory.rb +4 -0
- data/lib/specinfra/command/freebsd/base/service.rb +2 -2
- data/lib/specinfra/processor.rb +1 -1
- data/lib/specinfra/version.rb +1 -1
- data/spec/command/freebsd/service_spec.rb +72 -43
- data/spec/host_inventory/darwin/kernel_spec.rb +16 -0
- data/spec/processor_spec.rb +49 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: eb64f982a1db9c07f65e29062f40f76d2dbd06cc
|
4
|
+
data.tar.gz: 6e35fcccef10ee85f2798d5cd55dd35415a97007
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 667d26731d168fd905f3235f135bb7cf12098908b4114e3a7b2938518e5fb2e2574a12ae9f85006856a1ced27e708070d144f1e7ec299160482daadd9b91c247
|
7
|
+
data.tar.gz: cfe99453702b4169825605f8c98fba7bd7cbf35331df9fc142ee824acafb433a9c71800104e95446b8fa080b6797617bddf7d8629b1fb22fe24f78f9e48f36ae
|
@@ -3,8 +3,8 @@ class Specinfra::Command::Freebsd::Base::Service < Specinfra::Command::Base::Ser
|
|
3
3
|
def check_is_enabled(service, level=3)
|
4
4
|
"service #{escape(service)} enabled"
|
5
5
|
end
|
6
|
-
def
|
7
|
-
"service #{escape(service)}
|
6
|
+
def check_is_running(service)
|
7
|
+
"service #{escape(service)} onestatus"
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
data/lib/specinfra/processor.rb
CHANGED
@@ -10,7 +10,7 @@ module Specinfra
|
|
10
10
|
return false if ret.stdout =~ /stop(ped)?\/waiting/
|
11
11
|
|
12
12
|
# If the service is not registered, check by ps command
|
13
|
-
if ret.exit_status == 1
|
13
|
+
if ret.exit_status == 1 && !Specinfra.configuration.no_service_process_fallback
|
14
14
|
cmd = Specinfra.command.get(:check_process_is_running, service)
|
15
15
|
ret = Specinfra.backend.run_command(cmd)
|
16
16
|
end
|
data/lib/specinfra/version.rb
CHANGED
@@ -5,67 +5,96 @@ describe 'command/freebsd/service works correctly' do
|
|
5
5
|
property[:os] = nil
|
6
6
|
end
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
describe 'check_service_is_enabled' do
|
9
|
+
context 'freebsd-base' do
|
10
|
+
before do
|
11
|
+
set :os, :family => 'freebsd'
|
12
|
+
end
|
13
|
+
describe 'get_command(:check_service_is_enabled, "httpd")' do
|
14
|
+
it { expect(get_command(:check_service_is_enabled, 'httpd')).to eq 'service httpd enabled' }
|
15
|
+
end
|
14
16
|
end
|
15
|
-
end
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
context 'freebsd-6' do
|
19
|
+
before do
|
20
|
+
set :os, :family => 'freebsd', :release => '6'
|
21
|
+
end
|
22
|
+
describe 'get_command(:check_service_is_enabled, "httpd")' do
|
23
|
+
it { expect(get_command(:check_service_is_enabled, 'httpd')).to eq 'service -e | grep -- /httpd$' }
|
24
|
+
end
|
23
25
|
end
|
24
|
-
end
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
context 'freebsd-7' do
|
28
|
+
before do
|
29
|
+
set :os, :family => 'freebsd', :release => '7'
|
30
|
+
end
|
31
|
+
describe 'get_command(:check_service_is_enabled, "httpd")' do
|
32
|
+
it { expect(get_command(:check_service_is_enabled, 'httpd')).to eq 'service -e | grep -- /httpd$' }
|
33
|
+
end
|
32
34
|
end
|
33
|
-
end
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
|
36
|
+
context 'freebsd-8' do
|
37
|
+
before do
|
38
|
+
set :os, :family => 'freebsd', :release => '8'
|
39
|
+
end
|
40
|
+
describe 'get_command(:check_service_is_enabled, "httpd")' do
|
41
|
+
it { expect(get_command(:check_service_is_enabled, 'httpd')).to eq 'service -e | grep -- /httpd$' }
|
42
|
+
end
|
38
43
|
end
|
39
|
-
|
40
|
-
|
44
|
+
|
45
|
+
context 'freebsd-9' do
|
46
|
+
before do
|
47
|
+
set :os, :family => 'freebsd', :release => '9'
|
48
|
+
end
|
49
|
+
describe 'get_command(:check_service_is_enabled, "httpd")' do
|
50
|
+
it { expect(get_command(:check_service_is_enabled, 'httpd')).to eq 'service -e | grep -- /httpd$' }
|
51
|
+
end
|
41
52
|
end
|
42
|
-
end
|
43
53
|
|
44
|
-
|
45
|
-
|
46
|
-
|
54
|
+
context 'freebsd-10' do
|
55
|
+
before do
|
56
|
+
set :os, :family => 'freebsd', :release => '10'
|
57
|
+
end
|
58
|
+
describe 'get_command(:check_service_is_enabled, "httpd")' do
|
59
|
+
it { expect(get_command(:check_service_is_enabled, 'httpd')).to eq 'service httpd enabled' }
|
60
|
+
end
|
47
61
|
end
|
48
|
-
|
49
|
-
|
62
|
+
|
63
|
+
context 'freebsd-11' do
|
64
|
+
before do
|
65
|
+
set :os, :family => 'freebsd', :release => '11'
|
66
|
+
end
|
67
|
+
describe 'get_command(:check_service_is_enabled, "httpd")' do
|
68
|
+
it { expect(get_command(:check_service_is_enabled, 'httpd')).to eq 'service httpd enabled' }
|
69
|
+
end
|
50
70
|
end
|
51
|
-
end
|
52
71
|
|
53
|
-
|
54
|
-
|
55
|
-
|
72
|
+
context 'freebsd-12' do
|
73
|
+
before do
|
74
|
+
set :os, :family => 'freebsd', :release => '12'
|
75
|
+
end
|
76
|
+
describe 'get_command(:check_service_is_enabled, "httpd")' do
|
77
|
+
it { expect(get_command(:check_service_is_enabled, 'httpd')).to eq 'service httpd enabled' }
|
78
|
+
end
|
56
79
|
end
|
57
|
-
|
58
|
-
|
80
|
+
|
81
|
+
context 'freebsd-13' do
|
82
|
+
before do
|
83
|
+
set :os, :family => 'freebsd', :release => '13'
|
84
|
+
end
|
85
|
+
describe 'get_command(:check_service_is_enabled, "httpd")' do
|
86
|
+
it { expect(get_command(:check_service_is_enabled, 'httpd')).to eq 'service httpd enabled' }
|
87
|
+
end
|
59
88
|
end
|
60
89
|
end
|
61
90
|
|
62
|
-
|
91
|
+
describe 'check_service_is_running' do
|
63
92
|
before do
|
64
|
-
set :os, :family => 'freebsd'
|
93
|
+
set :os, :family => 'freebsd'
|
65
94
|
end
|
66
|
-
|
67
|
-
|
95
|
+
|
96
|
+
describe 'get_command(:check_service_is_running, "foobar")' do
|
97
|
+
it { expect(get_command(:check_service_is_running, 'foobar')).to eq 'service foobar onestatus' }
|
68
98
|
end
|
69
99
|
end
|
70
100
|
end
|
71
|
-
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Specinfra::HostInventory::Kernel do
|
4
|
+
describe "get" do
|
5
|
+
let(:host_inventory) { Specinfra::HostInventory.instance }
|
6
|
+
let(:command_class) { Specinfra::Command::Darwin::Base }
|
7
|
+
let(:error_message) { "get_kernel is not implemented in #{command_class}" }
|
8
|
+
let(:kernel_inventory) { Specinfra::HostInventory::Kernel.new(host_inventory) }
|
9
|
+
let(:result) { kernel_inventory.get }
|
10
|
+
example "it includes the value of os_info[:arch] in the key 'machine'" do
|
11
|
+
expect(result).to include(
|
12
|
+
"machine" => host_inventory.backend.os_info[:arch]
|
13
|
+
)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/spec/processor_spec.rb
CHANGED
@@ -60,4 +60,53 @@ describe Specinfra::Processor do
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
end
|
63
|
+
|
64
|
+
describe 'check_service_is_running' do
|
65
|
+
let(:service_command) { Specinfra.command.get(:check_service_is_running, 'service_name') }
|
66
|
+
let(:process_command) { Specinfra.command.get(:check_process_is_running, 'service_name') }
|
67
|
+
|
68
|
+
context 'default settings' do
|
69
|
+
it 'does not fall back to process checking if service checking succeeds' do
|
70
|
+
allow(Specinfra.backend).to receive(:run_command).with(service_command) { CommandResult.new :exit_status => 0 }
|
71
|
+
|
72
|
+
expect(Specinfra::Processor.check_service_is_running('service_name')).to eq(true)
|
73
|
+
end
|
74
|
+
|
75
|
+
context 'when service checking fails' do
|
76
|
+
it 'falls back to checking by process and returns true if that succeeds' do
|
77
|
+
allow(Specinfra.backend).to receive(:run_command).with(service_command) { CommandResult.new :exit_status => 1 }
|
78
|
+
|
79
|
+
expect(Specinfra.backend).to receive(:run_command).with(process_command) { CommandResult.new :exit_status => 0 }
|
80
|
+
|
81
|
+
expect(Specinfra::Processor.check_service_is_running('service_name')).to eq(true)
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'falls back to checking by process and returns false if that fails' do
|
85
|
+
allow(Specinfra.backend).to receive(:run_command).with(service_command) { CommandResult.new :exit_status => 1 }
|
86
|
+
|
87
|
+
expect(Specinfra.backend).to receive(:run_command).with(process_command) { CommandResult.new :exit_status => 1 }
|
88
|
+
|
89
|
+
expect(Specinfra::Processor.check_service_is_running('service_name')).to eq(false)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
context 'no_service_process_fallback set to true' do
|
95
|
+
it 'does not fall back to checking processes if service checking succeeds' do
|
96
|
+
Specinfra.configuration.no_service_process_fallback(true)
|
97
|
+
|
98
|
+
allow(Specinfra.backend).to receive(:run_command).with(service_command) { CommandResult.new :exit_status => 0 }
|
99
|
+
|
100
|
+
expect(Specinfra::Processor.check_service_is_running('service_name')).to eq(true)
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'does not fall back to checking processes if service checking fails' do
|
104
|
+
Specinfra.configuration.no_service_process_fallback(true)
|
105
|
+
|
106
|
+
allow(Specinfra.backend).to receive(:run_command).with(service_command) { CommandResult.new :exit_status => 1 }
|
107
|
+
|
108
|
+
expect(Specinfra::Processor.check_service_is_running('service_name')).to eq(false)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
63
112
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: specinfra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.83.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gosuke Miyashita
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-scp
|
@@ -600,6 +600,7 @@ files:
|
|
600
600
|
- spec/host_inventory/base/group_spec.rb
|
601
601
|
- spec/host_inventory/base/user_spec.rb
|
602
602
|
- spec/host_inventory/darwin/filesystem_spec.rb
|
603
|
+
- spec/host_inventory/darwin/kernel_spec.rb
|
603
604
|
- spec/host_inventory/freebsd/filesystem_spec.rb
|
604
605
|
- spec/host_inventory/linux/block_device_spec.rb
|
605
606
|
- spec/host_inventory/linux/cpu_spec.rb
|
@@ -633,7 +634,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
633
634
|
- !ruby/object:Gem::Version
|
634
635
|
version: '0'
|
635
636
|
requirements: []
|
636
|
-
|
637
|
+
rubyforge_project:
|
638
|
+
rubygems_version: 2.5.1
|
637
639
|
signing_key:
|
638
640
|
specification_version: 4
|
639
641
|
summary: Common layer for serverspec and itamae
|
@@ -741,6 +743,7 @@ test_files:
|
|
741
743
|
- spec/host_inventory/base/group_spec.rb
|
742
744
|
- spec/host_inventory/base/user_spec.rb
|
743
745
|
- spec/host_inventory/darwin/filesystem_spec.rb
|
746
|
+
- spec/host_inventory/darwin/kernel_spec.rb
|
744
747
|
- spec/host_inventory/freebsd/filesystem_spec.rb
|
745
748
|
- spec/host_inventory/linux/block_device_spec.rb
|
746
749
|
- spec/host_inventory/linux/cpu_spec.rb
|