specinfra 2.82.23 → 2.83.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 2bb01e92f4048c67284e481792e819aa154976574ebecc5d0f08a3f619553dc7
4
- data.tar.gz: 4df996d6652f4cfaacef45d6ff7a35e0fec0d64951b0767a286325890ec837df
2
+ SHA1:
3
+ metadata.gz: 7f98623e6d0a234bd7fe4efe0a86e0cdc270a415
4
+ data.tar.gz: 42c023dec145584e4bc648127adc088b88f2f727
5
5
  SHA512:
6
- metadata.gz: f7b2e74dd455b7ce505871a08bf73b9b01a485233c20eaa2272c0b84dc76baf117fe60174e398081e76ff8701b40ddfb857b18b0c78ca79c563e6fff91cdf576
7
- data.tar.gz: 4a977f26975443d83927b4e06fb9265f1c251c4f62922f12f4530fabb6d2a8ced02a583ca3b85dfc0cbacdb0849f2b29b22a25a7256397971a3f70ce92dac148
6
+ metadata.gz: 05045bced49f00191b843da8fc16339f4209d543c04ae652a886feabe0ec346179da570168e4f16e0ddbe2c4a8e743203c49bc8665ce7bed3e64148f17917f53
7
+ data.tar.gz: fbb932813642ede8d94a754bd5a631ed8fe404b6489c2acc3c3539212638a0fe8c9cd53320d6996e105e5bec92fae48ca9e4387c35f7178451551fcf2c9b461d
@@ -1,7 +1,7 @@
1
1
  class Specinfra::Command::Darwin::Base::Package < Specinfra::Command::Base::Package
2
2
  class << self
3
3
  def check_is_installed(package, version=nil)
4
- escaped_package = escape(File.basename(package))
4
+ escaped_package = escape(::File.basename(package))
5
5
  if version
6
6
  cmd = %Q[brew info #{escaped_package} | grep -E "^$(brew --prefix)/Cellar/#{escaped_package}/#{escape(version)}"]
7
7
  else
@@ -13,7 +13,7 @@ class Specinfra::Command::Darwin::Base::Package < Specinfra::Command::Base::Pack
13
13
  alias :check_is_installed_by_homebrew :check_is_installed
14
14
 
15
15
  def check_is_installed_by_homebrew_cask(package, version=nil)
16
- escaped_package = escape(File.basename(package))
16
+ escaped_package = escape(::File.basename(package))
17
17
  if version
18
18
  cmd = "brew cask info #{escaped_package} | grep -E '^/opt/homebrew-cask/Caskroom/#{escaped_package}/#{escape(version)}'"
19
19
  else
@@ -1,10 +1,11 @@
1
1
  class Specinfra::Command::Debian::Base::Port < Specinfra::Command::Linux::Base::Port
2
2
  class << self
3
3
  def create(os_info=nil)
4
- if (os_info || os)[:release].to_i < 8
5
- self
6
- else
4
+ release = (os_info || os)[:release]
5
+ if ["testing", "unstable"].include?(release) || release.to_i >= 8
7
6
  Specinfra::Command::Debian::V8::Port
7
+ else
8
+ self
8
9
  end
9
10
  end
10
11
  end
@@ -1,10 +1,11 @@
1
1
  class Specinfra::Command::Debian::Base::Service < Specinfra::Command::Linux::Base::Service
2
2
  class << self
3
3
  def create(os_info=nil)
4
- if (os_info || os)[:release].to_i < 8
5
- self
6
- else
4
+ release = (os_info || os)[:release]
5
+ if ["testing", "unstable"].include?(release) || release.to_i >= 8
7
6
  Specinfra::Command::Debian::V8::Service
7
+ else
8
+ self
8
9
  end
9
10
  end
10
11
 
@@ -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 check_is_running_under_init(service)
7
- "service #{escape(service)} status | grep -E 'as (pid [0-9]+)'"
6
+ def check_is_running(service)
7
+ "service #{escape(service)} onestatus"
8
8
  end
9
9
  end
10
10
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Specinfra
2
- VERSION = "2.82.23"
2
+ VERSION = "2.83.1"
3
3
  end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ property[:os] = nil
4
+ set :os, :family => 'debian', :release => 'testing'
5
+
6
+ describe get_command(:check_port_is_listening, '80') do
7
+ it { should eq 'ss -tunl | grep -E -- :80\ ' }
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ property[:os] = nil
4
+ set :os, :family => 'debian', :release => 'testing'
5
+
6
+ describe get_command(:check_service_is_enabled, 'apache') do
7
+ it { should eq 'systemctl --quiet is-enabled apache||ls /etc/rc[S5].d/S??apache >/dev/null 2>/dev/null' }
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ property[:os] = nil
4
+ set :os, :family => 'debian', :release => 'unstable'
5
+
6
+ describe get_command(:check_port_is_listening, '80') do
7
+ it { should eq 'ss -tunl | grep -E -- :80\ ' }
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ property[:os] = nil
4
+ set :os, :family => 'debian', :release => 'unstable'
5
+
6
+ describe get_command(:check_service_is_enabled, 'apache') do
7
+ it { should eq 'systemctl --quiet is-enabled apache||ls /etc/rc[S5].d/S??apache >/dev/null 2>/dev/null' }
8
+ end
@@ -5,67 +5,96 @@ describe 'command/freebsd/service works correctly' do
5
5
  property[:os] = nil
6
6
  end
7
7
 
8
- context 'freebsd-base' do
9
- before do
10
- set :os, :family => 'freebsd'
11
- end
12
- describe 'get_command(:check_service_is_enabled, "httpd")' do
13
- it { expect(get_command(:check_service_is_enabled, 'httpd')).to eq 'service httpd enabled' }
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
- context 'freebsd-6' do
18
- before do
19
- set :os, :family => 'freebsd', :release => '6'
20
- end
21
- describe 'get_command(:check_service_is_enabled, "httpd")' do
22
- it { expect(get_command(:check_service_is_enabled, 'httpd')).to eq 'service -e | grep -- /httpd$' }
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
- context 'freebsd-7' do
27
- before do
28
- set :os, :family => 'freebsd', :release => '7'
29
- end
30
- describe 'get_command(:check_service_is_enabled, "httpd")' do
31
- it { expect(get_command(:check_service_is_enabled, 'httpd')).to eq 'service -e | grep -- /httpd$' }
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
- context 'freebsd-8' do
36
- before do
37
- set :os, :family => 'freebsd', :release => '8'
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
- describe 'get_command(:check_service_is_enabled, "httpd")' do
40
- it { expect(get_command(:check_service_is_enabled, 'httpd')).to eq 'service -e | grep -- /httpd$' }
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
- context 'freebsd-9' do
45
- before do
46
- set :os, :family => 'freebsd', :release => '9'
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
- describe 'get_command(:check_service_is_enabled, "httpd")' do
49
- it { expect(get_command(:check_service_is_enabled, 'httpd')).to eq 'service -e | grep -- /httpd$' }
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
- context 'freebsd-10' do
54
- before do
55
- set :os, :family => 'freebsd', :release => '10'
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
- describe 'get_command(:check_service_is_enabled, "httpd")' do
58
- it { expect(get_command(:check_service_is_enabled, 'httpd')).to eq 'service httpd enabled' }
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
- context 'freebsd-11' do
91
+ describe 'check_service_is_running' do
63
92
  before do
64
- set :os, :family => 'freebsd', :release => '11'
93
+ set :os, :family => 'freebsd'
65
94
  end
66
- describe 'get_command(:check_service_is_enabled, "httpd")' do
67
- it { expect(get_command(:check_service_is_enabled, 'httpd')).to eq 'service httpd enabled' }
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
-
@@ -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.82.23
4
+ version: 2.83.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gosuke Miyashita
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-13 00:00:00.000000000 Z
11
+ date: 2021-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-scp
@@ -537,6 +537,10 @@ files:
537
537
  - spec/command/debian8/port_spec.rb
538
538
  - spec/command/debian9/port_spec.rb
539
539
  - spec/command/debian9/service_spec.rb
540
+ - spec/command/debiantesting/port_spec.rb
541
+ - spec/command/debiantesting/service_spec.rb
542
+ - spec/command/debianunstable/port_spec.rb
543
+ - spec/command/debianunstable/service_spec.rb
540
544
  - spec/command/esxi/package_spec.rb
541
545
  - spec/command/factory_spec.rb
542
546
  - spec/command/freebsd/file_spec.rb
@@ -629,7 +633,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
629
633
  - !ruby/object:Gem::Version
630
634
  version: '0'
631
635
  requirements: []
632
- rubygems_version: 3.1.2
636
+ rubyforge_project:
637
+ rubygems_version: 2.5.1
633
638
  signing_key:
634
639
  specification_version: 4
635
640
  summary: Common layer for serverspec and itamae
@@ -674,6 +679,10 @@ test_files:
674
679
  - spec/command/debian8/port_spec.rb
675
680
  - spec/command/debian9/port_spec.rb
676
681
  - spec/command/debian9/service_spec.rb
682
+ - spec/command/debiantesting/port_spec.rb
683
+ - spec/command/debiantesting/service_spec.rb
684
+ - spec/command/debianunstable/port_spec.rb
685
+ - spec/command/debianunstable/service_spec.rb
677
686
  - spec/command/esxi/package_spec.rb
678
687
  - spec/command/factory_spec.rb
679
688
  - spec/command/freebsd/file_spec.rb