Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add acceptance tests around halt behaviour
Ensure acceptance tests capture halt behaviour to prevent future regression around graceful and forced halt. Related-to: #1765
- Loading branch information
1 parent
271ca70
commit f87de11
Showing
2 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative '../spec_helper' | ||
|
||
describe 'shutdown and halt', acceptance: true do | ||
include_context 'libvirt_acceptance' | ||
|
||
before do | ||
environment.skeleton('default_settings') | ||
end | ||
|
||
after do | ||
assert_execute('vagrant', 'destroy', '--force') | ||
end | ||
|
||
context 'when system accessible' do | ||
it 'graceful shutdown should succeed' do | ||
status('Test: machine is created successfully') | ||
result = environment.execute('vagrant', 'up') | ||
expect(result).to exit_with(0) | ||
|
||
status('Test: Halt') | ||
result = environment.execute('vagrant', 'halt') | ||
expect(result).to exit_with(0) | ||
|
||
status('Test: validate output') | ||
expect(result.stdout).to match(/Attempting graceful shutdown of VM/) | ||
expect(result.stdout).to_not match(/Halting domain.../) | ||
end | ||
|
||
it 'forced halt should skip graceful and succeed' do | ||
status('Test: machine is created successfully') | ||
result = environment.execute('vagrant', 'up') | ||
expect(result).to exit_with(0) | ||
|
||
status('Test: Halt') | ||
result = environment.execute('vagrant', 'halt', '-f') | ||
expect(result).to exit_with(0) | ||
|
||
status('Test: validate output') | ||
expect(result.stdout).to_not match(/Attempting graceful shutdown of VM/) | ||
expect(result.stdout).to match(/Halting domain.../) | ||
end | ||
end | ||
|
||
context 'when system hung' do | ||
it 'should call halt after failed graceful' do | ||
status('Test: machine is created successfully') | ||
result = environment.execute('vagrant', 'up') | ||
expect(result).to exit_with(0) | ||
|
||
status('Test: Trigger crash to prevent graceful halt working') | ||
result = environment.execute('vagrant', 'ssh', '-c', 'nohup sudo sh -c \'echo -n c > /proc/sysrq-trigger\' >/dev/null 2>&1 </dev/null', '--', '-f') | ||
expect(result).to exit_with(0) | ||
|
||
status('Test: Halt') | ||
result = environment.execute('vagrant', 'halt') | ||
expect(result).to exit_with(0) | ||
|
||
status('Test: validate output') | ||
expect(result.stdout).to match(/Attempting graceful shutdown of VM/) | ||
expect(result.stdout).to match(/Guest communication could not be established/) | ||
expect(result.stdout).to match(/Halting domain.../) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters