-
Notifications
You must be signed in to change notification settings - Fork 168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Abort the managedsave process and check the events #6104
Open
yalzhang
wants to merge
1
commit into
autotest:master
Choose a base branch
from
yalzhang:abort_managedsave
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,9 @@ | ||
- save_and_restore.abort_managedsave: | ||
type = abort_managedsave | ||
save_opt = | ||
start_vm = no | ||
default_path = "/var/lib/libvirt/qemu/save" | ||
event_cmd = "event --loop --all" | ||
expected_event = ["Suspended Paused", "Resumed Unpaused"] | ||
|
||
|
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,73 @@ | ||
import logging | ||
import re | ||
import os | ||
|
||
from virttest import virsh | ||
from virttest.libvirt_xml import vm_xml | ||
from provider.save import save_base | ||
Comment on lines
+6
to
+7
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need a blank between this two lines |
||
|
||
LOG = logging.getLogger('avocado.test.' + __name__) | ||
VIRSH_ARGS = {'debug': True, 'ignore_status': False} | ||
|
||
|
||
def run(test, params, env): | ||
""" | ||
Test the scenario to abort the vm ManagedSave process | ||
Steps: | ||
1. Start the vm, run stress in the vm to slow down the ManagedSave process; | ||
2. Run "virsh managedsave" to save the vm; | ||
3. During the managedsave process, run domjobabort; | ||
4. Check the VM's states after the abort operation and check the events; | ||
""" | ||
|
||
vm_name = params.get('main_vm') | ||
vm = env.get_vm(vm_name) | ||
default_path = params.get('default_path') | ||
file_path = default_path + vm_name + '.save' | ||
vmxml = vm_xml.VMXML.new_from_inactive_dumpxml(vm_name) | ||
bkxml = vmxml.copy() | ||
event_cmd = params.get("event_cmd") | ||
expected_event = eval(params.get('expected_event')) | ||
try: | ||
vm.start() | ||
session = vm.wait_for_login() | ||
pid_ping, upsince = save_base.pre_save_setup(vm) | ||
LOG.debug(f'Step1: run stress on the vm:') | ||
sh_cmd1 = "dnf install -y stress" | ||
session.cmd(sh_cmd1, ignore_all_errors=True) | ||
sh_cmd2 = "stress --cpu 8 --io 4 --vm 2 --vm-bytes 128M --vm-keep" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Could this stress cmd be in cfg file, it would be more easier to find when we want to increase or reduce stress |
||
session.cmd(sh_cmd2, ignore_all_errors=True, timeout=10) | ||
LOG.debug(f'Step2: ManagedSave the VM:') | ||
# Start event session to catch the events | ||
event_session = virsh.EventTracker.start_get_event(vm_name, event_cmd=event_cmd) | ||
cmd = "managedsave %s" % vm_name | ||
virsh_session = virsh.VirshSession(virsh_exec=virsh.VIRSH_EXEC, | ||
auto_close=False) | ||
virsh_session.sendline(cmd) | ||
LOG.debug(f'Step3: Abort the ManagedSave process') | ||
# check if the save process is succeed, cancel the test if save succeed | ||
st = virsh.domjobinfo(vm_name, ignore_status=True).stdout_text.strip() | ||
LOG.debug("domjobinfo: %s", st) | ||
if not re.search("Unbounded", st): | ||
test.cancel("Test cancel since managedsave process completed before abort.") | ||
virsh.domjobabort(vm_name).stdout_text.strip() | ||
LOG.debug(f"Check the VM's state details after save abort") | ||
save_base.post_save_check(vm, pid_ping, upsince) | ||
# check the events for abort | ||
LOG.debug("Step4: Check the event:") | ||
event_output = virsh.EventTracker.finish_get_event(event_session) | ||
for event in expected_event: | ||
if not re.search(event, event_output): | ||
test.fail('Not find: %s from event output:%s' % (event, event_output)) | ||
# check VM states details | ||
outputs_ = virsh.domstate(vm_name, "--reason").stdout_text.strip() | ||
LOG.debug("Step5: check the domstate: %s and ensure no saved file", outputs_) | ||
if not re.search("save canceled", outputs_): | ||
test.fail(f"There is no 'save canceled' words in the domstate outputs!") | ||
if os.path.exists(file_path): | ||
test.fail("There should not be the save file since managedsave aborted") | ||
virsh.shutdown(vm_name, **VIRSH_ARGS) | ||
finally: | ||
bkxml.sync() | ||
if os.path.exists(file_path): | ||
os.remove(file_path) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be in order alpha