beaker 4.27.0 → 4.27.1
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/.rspec +1 -0
- data/CHANGELOG.md +13 -0
- data/beaker.gemspec +3 -3
- data/lib/beaker/host.rb +1 -0
- data/lib/beaker/host/pswindows/exec.rb +1 -1
- data/lib/beaker/host/unix/exec.rb +64 -31
- data/lib/beaker/version.rb +1 -1
- data/spec/beaker/host/pswindows/exec_spec.rb +5 -6
- data/spec/beaker/host/unix/exec_spec.rb +153 -83
- metadata +17 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1708680196db2be9b63b514162605faa19df47fb2b8f13bfd336af02b464118
|
4
|
+
data.tar.gz: 8ea244f5c438736aa003db09aa4d6f8bd7b96f3f99988c5bad0f6302a88f598c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3811e71f7e592d024150b6470610df72dbc466cc8bdfeea50e9eb4cd57227892d6bd005e071a710516992a4dc94e5a2c0009970674a8bc0ffd998f494ada76f
|
7
|
+
data.tar.gz: cce923c69673ab3e5aea1a7022a2b94ee9e5205b700885cf389b5734f71b60d78c617d4b44214ea8a3fc93614ff1be3f4d580d61e8381afe03d01dcb462d8c15
|
data/.rspec
CHANGED
data/CHANGELOG.md
CHANGED
@@ -22,6 +22,19 @@ The headers used in [Keep a Changelog](http://keepachangelog.com) are:
|
|
22
22
|
|
23
23
|
# [Unreleased](https://github.com/puppetlabs/beaker/compare/4.27.0...master)
|
24
24
|
|
25
|
+
# [4.27.1](https://github.com/puppetlabs/beaker/compare/4.27.0...4.27.1) - 09-29-2020
|
26
|
+
|
27
|
+
### Changed
|
28
|
+
|
29
|
+
- Update net-scp requirement from "~> 1.2" to ">= 1.2, < 4.0"
|
30
|
+
|
31
|
+
### Fixed
|
32
|
+
|
33
|
+
- Handle systems going back in time after reboot
|
34
|
+
- Enhanced error handling during the reboot sequence
|
35
|
+
- Fixed time check logic during reboot
|
36
|
+
- Wrap paths around "" on pswindows
|
37
|
+
|
25
38
|
# [4.27.0](https://github.com/puppetlabs/beaker/compare/4.26.0...4.27.0) - 07-24-2020
|
26
39
|
|
27
40
|
### Changed
|
data/beaker.gemspec
CHANGED
@@ -23,9 +23,9 @@ Gem::Specification.new do |s|
|
|
23
23
|
# Testing dependencies
|
24
24
|
s.add_development_dependency 'rspec', '~> 3.0'
|
25
25
|
s.add_development_dependency 'rspec-its'
|
26
|
-
s.add_development_dependency 'fakefs', '~>
|
26
|
+
s.add_development_dependency 'fakefs', '~> 1.2', '< 1.3.0'
|
27
27
|
s.add_development_dependency 'simplecov'
|
28
|
-
s.add_development_dependency 'rake', '~>
|
28
|
+
s.add_development_dependency 'rake', '~> 13.0'
|
29
29
|
|
30
30
|
# Provisioner dependencies - needed for acceptance tests
|
31
31
|
# TODO: figure out how to remove these
|
@@ -45,7 +45,7 @@ Gem::Specification.new do |s|
|
|
45
45
|
|
46
46
|
s.add_runtime_dependency 'hocon', '~> 1.0'
|
47
47
|
s.add_runtime_dependency 'net-ssh', '>= 5.0'
|
48
|
-
s.add_runtime_dependency 'net-scp', '
|
48
|
+
s.add_runtime_dependency 'net-scp', '>= 1.2', '< 4.0'
|
49
49
|
s.add_runtime_dependency 'inifile', '~> 3.0'
|
50
50
|
|
51
51
|
s.add_runtime_dependency 'rsync', '~> 1.0.9'
|
data/lib/beaker/host.rb
CHANGED
@@ -22,7 +22,7 @@ module PSWindows::Exec
|
|
22
22
|
def rm_rf path
|
23
23
|
# ensure that we have the right slashes for windows
|
24
24
|
path = path.gsub(/\//, '\\')
|
25
|
-
execute(
|
25
|
+
execute(%(del /s /q "#{path}"))
|
26
26
|
end
|
27
27
|
|
28
28
|
# Move the origin to destination. The destination is removed prior to moving.
|
@@ -16,66 +16,99 @@ module Unix::Exec
|
|
16
16
|
|
17
17
|
attempts = 0
|
18
18
|
|
19
|
+
# Some systems don't support 'last -F reboot' but it has second granularity
|
20
|
+
boot_time_cmd = 'last -F reboot || who -b'
|
21
|
+
|
22
|
+
# Try to match all of the common formats for 'last' and 'who'
|
23
|
+
current_year = Time.now.strftime("%Y")
|
24
|
+
boot_time_regex = Regexp.new(%{((?:#{(Date::ABBR_DAYNAMES + Date::ABBR_MONTHNAMES).compact.join('|')}|#{current_year}).+?(\\d+:\\d+)+?(?::(\\d+).+?#{current_year})?)})
|
25
|
+
|
19
26
|
original_boot_time_str = nil
|
20
27
|
original_boot_time_line = nil
|
21
28
|
begin
|
22
|
-
|
29
|
+
attempts += 1
|
30
|
+
# Number of seconds to sleep before rebooting.
|
31
|
+
reboot_sleep = 1
|
32
|
+
|
33
|
+
original_boot_time_str = exec(Beaker::Command.new(boot_time_cmd), {:max_connection_tries => max_connection_tries, :silent => true}).stdout
|
23
34
|
original_boot_time_line = original_boot_time_str.lines.grep(/boot/).first
|
24
35
|
|
25
|
-
raise Beaker::Host::
|
36
|
+
raise Beaker::Host::RebootWarning, "Could not find system boot time using '#{boot_time_cmd}': '#{original_boot_time_str}'" unless original_boot_time_line
|
26
37
|
|
27
|
-
|
38
|
+
original_boot_time_matches = original_boot_time_line.scan(boot_time_regex).last
|
28
39
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
else
|
36
|
-
raise
|
40
|
+
raise Beaker::Host::RebootWarning, "Found no valid times in '#{original_boot_time_line}'" unless original_boot_time_matches
|
41
|
+
|
42
|
+
original_boot_time = Time.parse(original_boot_time_matches.first)
|
43
|
+
|
44
|
+
unless original_boot_time_matches.last
|
45
|
+
reboot_sleep = (61 - Time.now.strftime("%S").to_i)
|
37
46
|
end
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
47
|
+
|
48
|
+
@logger.notify("Sleeping #{reboot_sleep} seconds before rebooting")
|
49
|
+
|
50
|
+
sleep(reboot_sleep)
|
51
|
+
|
52
|
+
exec(Beaker::Command.new('/bin/systemctl reboot -i || reboot || /sbin/shutdown -r now'), :expect_connection_failure => true)
|
42
53
|
rescue ArgumentError => e
|
43
54
|
raise Beaker::Host::RebootFailure, "Unable to parse time: #{e.message}"
|
55
|
+
rescue Beaker::Host::RebootWarning => e
|
56
|
+
raise if attempts > uptime_retries
|
57
|
+
@logger.warn(e.message)
|
58
|
+
@logger.warn("Retrying #{uptime_retries - attempts} more times.")
|
59
|
+
retry
|
60
|
+
rescue StandardError => e
|
61
|
+
raise if attempts > uptime_retries
|
62
|
+
@logger.warn("Unexpected Exception: #{e.message}")
|
63
|
+
@logger.warn("Retrying #{uptime_retries - attempts} more times.")
|
64
|
+
@logger.warn(e.backtrace[0,3].join("\n"))
|
65
|
+
@logger.debug(e.backtrace.join("\n"))
|
66
|
+
retry
|
44
67
|
end
|
45
68
|
|
46
69
|
attempts = 0
|
47
70
|
begin
|
71
|
+
attempts += 1
|
72
|
+
|
48
73
|
# give the host a little time to shutdown
|
49
74
|
@logger.debug("Waiting #{wait_time} for host to shut down.")
|
50
75
|
sleep wait_time
|
51
76
|
|
52
|
-
|
77
|
+
# Accept all exit codes because this may fail due to the parallel nature of systemd
|
78
|
+
current_boot_time_str = exec(Beaker::Command.new(boot_time_cmd), {:max_connection_tries => max_connection_tries, :silent => true, :accept_all_exit_codes => true}).stdout
|
53
79
|
current_boot_time_line = current_boot_time_str.lines.grep(/boot/).first
|
54
80
|
|
55
|
-
raise Beaker::Host::
|
81
|
+
raise Beaker::Host::RebootWarning, "Could not find system boot time using '#{boot_time_cmd}': '#{current_boot_time_str}'" unless current_boot_time_line
|
82
|
+
|
83
|
+
current_boot_time_matches = current_boot_time_line.scan(boot_time_regex).last
|
84
|
+
|
85
|
+
raise Beaker::Host::RebootWarning, "Found no valid times in '#{current_boot_time_line}'" unless current_boot_time_matches
|
56
86
|
|
57
|
-
current_boot_time = Time.parse(
|
87
|
+
current_boot_time = Time.parse(current_boot_time_matches.first)
|
58
88
|
|
59
89
|
@logger.debug("Original Boot Time: #{original_boot_time}")
|
60
90
|
@logger.debug("Current Boot Time: #{current_boot_time}")
|
61
91
|
|
62
|
-
|
92
|
+
# If this is *exactly* the same then there is really no good way to detect a reboot
|
93
|
+
if current_boot_time == original_boot_time
|
63
94
|
raise Beaker::Host::RebootFailure, "Boot time did not reset. Reboot appears to have failed."
|
64
95
|
end
|
65
|
-
rescue Beaker::Host::RebootFailure => e
|
66
|
-
attempts += 1
|
67
|
-
if attempts < uptime_retries
|
68
|
-
@logger.debug("Boot time did not reset. Will retry #{uptime_retries - attempts} more times.")
|
69
|
-
retry
|
70
|
-
else
|
71
|
-
raise
|
72
|
-
end
|
73
|
-
rescue Beaker::Host::CommandFailure => e
|
74
|
-
raise Beaker::Host::RebootFailure, "Command failed when attempting to reboot: #{e.message}"
|
75
|
-
rescue RuntimeError => e
|
76
|
-
raise Beaker::Host::RebootFailure, "Unexpected exception in reboot: #{e.message}"
|
77
96
|
rescue ArgumentError => e
|
78
97
|
raise Beaker::Host::RebootFailure, "Unable to parse time: #{e.message}"
|
98
|
+
rescue Beaker::Host::RebootFailure => e
|
99
|
+
raise
|
100
|
+
rescue Beaker::Host::RebootWarning => e
|
101
|
+
raise if attempts > uptime_retries
|
102
|
+
@logger.warn(e.message)
|
103
|
+
@logger.warn("Retrying #{uptime_retries - attempts} more times.")
|
104
|
+
retry
|
105
|
+
rescue StandardError => e
|
106
|
+
raise if attempts > uptime_retries
|
107
|
+
@logger.warn("Unexpected Exception: #{e.message}")
|
108
|
+
@logger.warn("Retrying #{uptime_retries - attempts} more times.")
|
109
|
+
@logger.warn(e.backtrace[0,3].join("\n"))
|
110
|
+
@logger.debug(e.backtrace.join("\n"))
|
111
|
+
retry
|
79
112
|
end
|
80
113
|
end
|
81
114
|
|
data/lib/beaker/version.rb
CHANGED
@@ -29,8 +29,8 @@ module Beaker
|
|
29
29
|
it "deletes" do
|
30
30
|
path = '/path/to/delete'
|
31
31
|
corrected_path = '\\path\\to\\delete'
|
32
|
-
expect(
|
33
|
-
expect(
|
32
|
+
expect(instance).to receive(:execute).with(%(del /s /q "#{corrected_path}")).and_return(0)
|
33
|
+
expect(instance.rm_rf(path)).to eq(0)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -39,10 +39,9 @@ module Beaker
|
|
39
39
|
let(:destination) { '/destination/path/of/content' }
|
40
40
|
|
41
41
|
it 'rm first' do
|
42
|
-
expect(
|
43
|
-
expect(
|
44
|
-
expect(
|
45
|
-
|
42
|
+
expect(instance).to receive(:execute).with("del /s /q \"\\destination\\path\\of\\content\"").and_return(0)
|
43
|
+
expect(instance).to receive(:execute).with("move /y #{origin.gsub(/\//, '\\')} #{destination.gsub(/\//, '\\')}").and_return(0)
|
44
|
+
expect(instance.mv(origin, destination)).to eq(0)
|
46
45
|
end
|
47
46
|
|
48
47
|
it 'does not rm' do
|
@@ -169,6 +169,64 @@ module Beaker
|
|
169
169
|
end
|
170
170
|
|
171
171
|
describe '#reboot' do
|
172
|
+
check_cmd_output = {
|
173
|
+
:centos6 => {
|
174
|
+
:who => {
|
175
|
+
:initial => ' system boot 2020-05-13 03:51',
|
176
|
+
:success => ' system boot 2020-05-13 03:52',
|
177
|
+
},
|
178
|
+
:last => {
|
179
|
+
:initial => <<~LAST_F,
|
180
|
+
reboot system boot 2.6.32-754.29.1. Tue May 5 17:34:52 2020 - Tue May 5 17:52:48 2020 (00:17)
|
181
|
+
reboot system boot 2.6.32-754.29.1. Mon May 4 18:45:43 2020 - Mon May 5 05:35:44 2020 (4+01:50)
|
182
|
+
LAST_F
|
183
|
+
:success => <<~LAST_F,
|
184
|
+
reboot system boot 2.6.32-754.29.1. Tue May 5 17:52:48 2020 - Tue May 5 17:52:49 2020 (00:17)
|
185
|
+
reboot system boot 2.6.32-754.29.1. Mon May 4 18:45:43 2020 - Mon May 5 05:35:44 2020 (4+01:50)
|
186
|
+
LAST_F
|
187
|
+
},
|
188
|
+
},
|
189
|
+
:centos7 => {
|
190
|
+
:who => {
|
191
|
+
:initial => ' system boot 2020-05-13 03:51',
|
192
|
+
:success => ' system boot 2020-05-13 03:52',
|
193
|
+
},
|
194
|
+
:last => {
|
195
|
+
:initial => <<~LAST_F,
|
196
|
+
reboot system boot 3.10.0-1127.el7. Tue May 5 17:34:52 2020 - Tue May 5 17:52:48 2020 (00:17)
|
197
|
+
reboot system boot 3.10.0-1127.el7. Mon May 4 18:45:43 2020 - Mon May 5 05:35:44 2020 (4+01:50)
|
198
|
+
LAST_F
|
199
|
+
:success => <<~LAST_F,
|
200
|
+
reboot system boot 3.10.0-1127.el7. Tue May 5 17:52:48 2020 - Tue May 5 17:52:49 2020 (00:17)
|
201
|
+
reboot system boot 3.10.0-1127.el7. Mon May 4 18:45:43 2020 - Mon May 5 05:35:44 2020 (4+01:50)
|
202
|
+
LAST_F
|
203
|
+
},
|
204
|
+
},
|
205
|
+
:centos8 => {
|
206
|
+
:who => {
|
207
|
+
:initial => ' system boot 2020-05-13 03:51',
|
208
|
+
:success => ' system boot 2020-05-13 03:52',
|
209
|
+
},
|
210
|
+
:last => {
|
211
|
+
:initial => <<~LAST_F,
|
212
|
+
reboot system boot 4.18.0-147.8.1.e Tue May 5 17:34:52 2020 still running
|
213
|
+
reboot system boot 4.18.0-147.8.1.e Mon May 4 17:41:27 2020 - Tue May 5 17:00:00 2020 (5+00:11)
|
214
|
+
LAST_F
|
215
|
+
:success => <<~LAST_F,
|
216
|
+
reboot system boot 4.18.0-147.8.1.e Tue May 5 17:34:53 2020 still running
|
217
|
+
reboot system boot 4.18.0-147.8.1.e Mon May 4 17:41:27 2020 - Tue May 5 17:00:00 2020 (5+00:11)
|
218
|
+
LAST_F
|
219
|
+
},
|
220
|
+
},
|
221
|
+
:freebsd => {
|
222
|
+
# last -F doesn't work on freebsd so no output will be returned
|
223
|
+
:who => {
|
224
|
+
:initial => ' system boot May 13 03:51',
|
225
|
+
:success => ' system boot May 13 03:52',
|
226
|
+
}
|
227
|
+
},
|
228
|
+
}
|
229
|
+
|
172
230
|
# no-op response
|
173
231
|
let (:response) { double( 'response' ) }
|
174
232
|
let (:boot_time_initial_response) { double( 'response' ) }
|
@@ -179,7 +237,7 @@ module Beaker
|
|
179
237
|
before :each do
|
180
238
|
# stubs enough to survive the first boot_time call & output parsing
|
181
239
|
# note: just stubs input-chain between calls, parsing methods still run
|
182
|
-
allow(Beaker::Command).to receive(:new).with('who -b').and_return(:boot_time_command_stub)
|
240
|
+
allow(Beaker::Command).to receive(:new).with('last -F reboot || who -b').and_return(:boot_time_command_stub)
|
183
241
|
|
184
242
|
allow(boot_time_initial_response).to receive(:stdout).and_return(boot_time_initial_stdout)
|
185
243
|
allow(boot_time_success_response).to receive(:stdout).and_return(boot_time_success_stdout)
|
@@ -190,116 +248,128 @@ module Beaker
|
|
190
248
|
end
|
191
249
|
|
192
250
|
context 'new boot time greater than old boot time' do
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
251
|
+
check_cmd_output.each do |check_os, cmd_opts|
|
252
|
+
cmd_opts.each do |cmd_name, cmd_outputs|
|
253
|
+
context "on '#{check_os}' with the '#{cmd_name}' command" do
|
254
|
+
let (:boot_time_initial_stdout) { cmd_outputs[:initial] }
|
255
|
+
let (:boot_time_success_stdout) { cmd_outputs[:success] }
|
256
|
+
|
257
|
+
it 'passes with defaults' do
|
258
|
+
expect(instance).to receive(:sleep).with(sleep_time)
|
259
|
+
# bypass shutdown command itself
|
260
|
+
expect(instance).to receive( :exec ).with(:shutdown_command_stub, anything).and_return(response)
|
261
|
+
# allow the second boot_time and the hash arguments in exec
|
262
|
+
expect(instance).to receive( :exec ).with(:boot_time_command_stub, anything).and_return(boot_time_initial_response).once
|
263
|
+
expect(instance).to receive( :exec ).with(:boot_time_command_stub, anything).and_return(boot_time_success_response).once
|
206
264
|
|
207
|
-
|
208
|
-
|
209
|
-
# bypass shutdown command itself
|
210
|
-
expect(instance).to receive( :exec ).with(:shutdown_command_stub, anything).and_return(response).once
|
211
|
-
expect(instance).to receive( :exec ).with(:boot_time_command_stub, anything).and_return(boot_time_initial_response).once
|
212
|
-
# allow the second boot_time and the hash arguments in exec
|
213
|
-
expect(instance).to receive( :exec ).with(:boot_time_command_stub, anything).and_return(boot_time_success_response).once
|
265
|
+
expect(instance.reboot).to be(nil)
|
266
|
+
end
|
214
267
|
|
215
|
-
|
216
|
-
|
268
|
+
it 'passes with wait_time_parameter' do
|
269
|
+
expect(instance).to receive(:sleep).with(10)
|
270
|
+
# bypass shutdown command itself
|
271
|
+
expect(instance).to receive( :exec ).with(:shutdown_command_stub, anything).and_return(response).once
|
272
|
+
expect(instance).to receive( :exec ).with(:boot_time_command_stub, anything).and_return(boot_time_initial_response).once
|
273
|
+
# allow the second boot_time and the hash arguments in exec
|
274
|
+
expect(instance).to receive( :exec ).with(:boot_time_command_stub, anything).and_return(boot_time_success_response).once
|
217
275
|
|
218
|
-
|
219
|
-
|
220
|
-
# bypass shutdown command itself
|
221
|
-
expect(instance).to receive( :exec ).with(:shutdown_command_stub, anything).and_return(response).once
|
222
|
-
expect(instance).to receive( :exec ).with(:boot_time_command_stub, anything).and_return(boot_time_initial_response).once
|
223
|
-
# allow the second boot_time and the hash arguments in exec
|
224
|
-
expect(instance).to receive( :exec ).with(:boot_time_command_stub, hash_including(:max_connection_tries => 20)).and_return(boot_time_success_response).once
|
276
|
+
expect(instance.reboot(10)).to be(nil)
|
277
|
+
end
|
225
278
|
|
226
|
-
|
227
|
-
|
279
|
+
it 'passes with max_connection_tries parameter' do
|
280
|
+
expect(instance).to receive(:sleep).with(sleep_time)
|
281
|
+
# bypass shutdown command itself
|
282
|
+
expect(instance).to receive( :exec ).with(:shutdown_command_stub, anything).and_return(response).once
|
283
|
+
expect(instance).to receive( :exec ).with(:boot_time_command_stub, anything).and_return(boot_time_initial_response).once
|
284
|
+
# allow the second boot_time and the hash arguments in exec
|
285
|
+
expect(instance).to receive( :exec ).with(:boot_time_command_stub, hash_including(:max_connection_tries => 20)).and_return(boot_time_success_response).once
|
228
286
|
|
229
|
-
|
230
|
-
|
231
|
-
allow(instance).to receive( :exec ).with(:boot_time_command_stub, anything).and_return(boot_time_initial_response).once
|
232
|
-
end
|
287
|
+
expect(instance.reboot(sleep_time, 20)).to be(nil)
|
288
|
+
end
|
233
289
|
|
234
|
-
|
235
|
-
|
236
|
-
|
290
|
+
context 'command errors' do
|
291
|
+
before :each do
|
292
|
+
allow(instance).to receive( :exec ).with(:boot_time_command_stub, anything).and_return(boot_time_initial_response).at_least(:once)
|
293
|
+
end
|
237
294
|
|
238
|
-
|
239
|
-
|
295
|
+
it 'raises a reboot failure when command fails' do
|
296
|
+
expect(instance).to receive(:sleep).at_least(:once)
|
297
|
+
expect(instance).to receive(:exec).with(:shutdown_command_stub, anything).and_raise(Host::CommandFailure).at_least(:once)
|
240
298
|
|
241
|
-
|
242
|
-
|
243
|
-
expect(instance).to receive(:exec).with(:shutdown_command_stub, anything).and_raise(Net::SSH::HostKeyError).once
|
299
|
+
expect{ instance.reboot }.to raise_error(Beaker::Host::CommandFailure)
|
300
|
+
end
|
244
301
|
|
245
|
-
|
246
|
-
|
302
|
+
it 'raises a reboot failure when we receive an unexpected error' do
|
303
|
+
expect(instance).to receive(:sleep).at_least(:once)
|
304
|
+
expect(instance).to receive(:exec).with(:shutdown_command_stub, anything).and_raise(Net::SSH::HostKeyError).at_least(:once)
|
247
305
|
|
248
|
-
|
249
|
-
|
250
|
-
let (:boot_time_initial_stdout) { 'boot bad' }
|
306
|
+
expect { instance.reboot }.to raise_error(Net::SSH::HostKeyError)
|
307
|
+
end
|
251
308
|
|
252
|
-
|
253
|
-
|
309
|
+
context 'incorrect time string' do
|
310
|
+
context 'original time' do
|
311
|
+
let (:boot_time_initial_stdout) { 'boot bad' }
|
254
312
|
|
255
|
-
|
256
|
-
|
257
|
-
|
313
|
+
it 'raises a reboot failure' do
|
314
|
+
# Handle the 'retry'
|
315
|
+
allow(instance).to receive( :exec ).with(:boot_time_command_stub, anything).and_return(boot_time_initial_response).at_least(:once)
|
258
316
|
|
259
|
-
|
260
|
-
let (:boot_time_success_stdout) { 'boot bad' }
|
317
|
+
expect(instance).not_to receive(:sleep)
|
261
318
|
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
319
|
+
expect { instance.reboot }.to raise_error(Beaker::Host::RebootWarning, /Found no valid times in .*/)
|
320
|
+
end
|
321
|
+
end
|
322
|
+
|
323
|
+
context 'current time' do
|
324
|
+
let (:boot_time_success_stdout) { 'boot bad' }
|
267
325
|
|
268
|
-
|
326
|
+
it 'raises a reboot failure' do
|
327
|
+
expect(instance).to receive(:exec).with(:shutdown_command_stub, anything).and_return(response).once
|
328
|
+
expect(instance).to receive( :exec ).with(:boot_time_command_stub, anything).and_return(boot_time_initial_response).once
|
329
|
+
# allow the second boot_time and the hash arguments in exec, repeated 10 times by default
|
330
|
+
expect(instance).to receive( :exec ).with(:boot_time_command_stub, anything).and_return(boot_time_success_response).at_least(:once)
|
331
|
+
|
332
|
+
expect { instance.reboot(10,9,1) }.to raise_error(Beaker::Host::RebootWarning, /Found no valid times in .*/)
|
333
|
+
end
|
334
|
+
end
|
335
|
+
end
|
269
336
|
end
|
270
337
|
end
|
271
338
|
end
|
272
339
|
end
|
273
340
|
end
|
274
341
|
|
275
|
-
context '
|
276
|
-
|
277
|
-
|
342
|
+
context 'system did not reboot' do
|
343
|
+
check_cmd_output.each do |check_os, cmd_opts|
|
344
|
+
cmd_opts.each do |cmd_name, cmd_outputs|
|
345
|
+
context "on '#{check_os}' with the '#{cmd_name}' command" do
|
346
|
+
let (:boot_time_initial_stdout) { cmd_outputs[:initial] }
|
347
|
+
let (:boot_time_success_stdout) { cmd_outputs[:initial] }
|
278
348
|
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
349
|
+
it 'raises RebootFailure' do
|
350
|
+
expect(instance).to receive(:sleep).with(sleep_time)
|
351
|
+
# bypass shutdown command itself
|
352
|
+
expect(instance).to receive( :exec ).with(:shutdown_command_stub, anything).and_return(response).once
|
283
353
|
|
284
|
-
|
285
|
-
|
286
|
-
expect(instance).to receive( :exec ).with(:boot_time_command_stub, anything).and_return(boot_time_success_response).exactly(18).times
|
354
|
+
expect(instance).to receive( :exec ).with(:boot_time_command_stub, anything).and_return(boot_time_initial_response).once
|
355
|
+
expect(instance).to receive( :exec ).with(:boot_time_command_stub, anything).and_return(boot_time_success_response).once
|
287
356
|
|
288
|
-
|
289
|
-
|
357
|
+
expect { instance.reboot }.to raise_error(Beaker::Host::RebootFailure, /Boot time did not reset/)
|
358
|
+
end
|
290
359
|
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
expect(instance).to receive( :exec ).with(:boot_time_command_stub, anything).and_return(boot_time_success_response).exactly(10).times
|
360
|
+
it 'raises RebootFailure if the number of retries is changed' do
|
361
|
+
expect(instance).to receive(:sleep).with(sleep_time)
|
362
|
+
# bypass shutdown command itself
|
363
|
+
expect(instance).to receive( :exec ).with(:shutdown_command_stub, anything).and_return(response).once
|
364
|
+
expect(instance).to receive( :exec ).with(:boot_time_command_stub, anything).and_return(boot_time_initial_response).once
|
365
|
+
expect(instance).to receive( :exec ).with(:boot_time_command_stub, anything).and_return(boot_time_success_response).once
|
298
366
|
|
299
|
-
|
367
|
+
expect { instance.reboot(wait_time=sleep_time, max_connection_tries=9, boot_time_retries=10) }.to raise_error(Beaker::Host::RebootFailure, /Boot time did not reset/)
|
368
|
+
end
|
369
|
+
end
|
370
|
+
end
|
300
371
|
end
|
301
372
|
end
|
302
|
-
|
303
373
|
end
|
304
374
|
|
305
375
|
describe '#enable_remote_rsyslog' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beaker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.27.
|
4
|
+
version: 4.27.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -44,20 +44,20 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '1.2'
|
48
48
|
- - "<"
|
49
49
|
- !ruby/object:Gem::Version
|
50
|
-
version:
|
50
|
+
version: 1.3.0
|
51
51
|
type: :development
|
52
52
|
prerelease: false
|
53
53
|
version_requirements: !ruby/object:Gem::Requirement
|
54
54
|
requirements:
|
55
55
|
- - "~>"
|
56
56
|
- !ruby/object:Gem::Version
|
57
|
-
version: '
|
57
|
+
version: '1.2'
|
58
58
|
- - "<"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version:
|
60
|
+
version: 1.3.0
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: simplecov
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -78,14 +78,14 @@ dependencies:
|
|
78
78
|
requirements:
|
79
79
|
- - "~>"
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version: '
|
81
|
+
version: '13.0'
|
82
82
|
type: :development
|
83
83
|
prerelease: false
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
86
|
- - "~>"
|
87
87
|
- !ruby/object:Gem::Version
|
88
|
-
version: '
|
88
|
+
version: '13.0'
|
89
89
|
- !ruby/object:Gem::Dependency
|
90
90
|
name: beaker-aws
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -230,16 +230,22 @@ dependencies:
|
|
230
230
|
name: net-scp
|
231
231
|
requirement: !ruby/object:Gem::Requirement
|
232
232
|
requirements:
|
233
|
-
- - "
|
233
|
+
- - ">="
|
234
234
|
- !ruby/object:Gem::Version
|
235
235
|
version: '1.2'
|
236
|
+
- - "<"
|
237
|
+
- !ruby/object:Gem::Version
|
238
|
+
version: '4.0'
|
236
239
|
type: :runtime
|
237
240
|
prerelease: false
|
238
241
|
version_requirements: !ruby/object:Gem::Requirement
|
239
242
|
requirements:
|
240
|
-
- - "
|
243
|
+
- - ">="
|
241
244
|
- !ruby/object:Gem::Version
|
242
245
|
version: '1.2'
|
246
|
+
- - "<"
|
247
|
+
- !ruby/object:Gem::Version
|
248
|
+
version: '4.0'
|
243
249
|
- !ruby/object:Gem::Dependency
|
244
250
|
name: inifile
|
245
251
|
requirement: !ruby/object:Gem::Requirement
|
@@ -702,7 +708,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
702
708
|
- !ruby/object:Gem::Version
|
703
709
|
version: '0'
|
704
710
|
requirements: []
|
705
|
-
rubygems_version: 3.0.
|
711
|
+
rubygems_version: 3.0.6
|
706
712
|
signing_key:
|
707
713
|
specification_version: 4
|
708
714
|
summary: Let's test Puppet!
|