-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
migration: Add case for offline migration
VIRT-XXXX - VM definition migration(offline migration) Signed-off-by: cliping <[email protected]>
- Loading branch information
Showing
3 changed files
with
123 additions
and
2 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
libvirt/tests/cfg/migration/offline_migration/offline_migration.cfg
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,52 @@ | ||
- migration.offline_migration: | ||
type = offline_migration | ||
migration_setup = 'yes' | ||
storage_type = 'nfs' | ||
setup_local_nfs = 'yes' | ||
disk_type = "file" | ||
disk_source_protocol = "netfs" | ||
mnt_path_name = ${nfs_mount_dir} | ||
# Console output can only be monitored via virsh console output | ||
only_pty = True | ||
take_regular_screendumps = no | ||
# Extra options to pass after <domain> <desturi> | ||
virsh_migrate_extra = '' | ||
# SSH connection time out | ||
ssh_timeout = 60 | ||
# Local URI | ||
virsh_migrate_connect_uri = 'qemu:///system' | ||
virsh_migrate_dest_state = "shut off" | ||
image_convert = 'no' | ||
server_ip = "${migrate_dest_host}" | ||
server_user = "root" | ||
server_pwd = "${migrate_dest_pwd}" | ||
status_error = "no" | ||
migrate_desturi_port = "16509" | ||
migrate_desturi_type = "tcp" | ||
virsh_migrate_desturi = "qemu+tcp://${migrate_dest_host}/system" | ||
|
||
variants: | ||
- p2p: | ||
virsh_migrate_options = '--p2p --verbose --offline --persistent' | ||
- non_p2p: | ||
virsh_migrate_options = '--verbose --offline --persistent' | ||
variants: | ||
- src_vm_running: | ||
start_vm = "yes" | ||
virsh_migrate_src_state = "running" | ||
variants: | ||
- with_undefinesource: | ||
virsh_migrate_extra = "--undefinesource" | ||
src_vm_persistency_state = "nonexist" | ||
- without_undefinesource: | ||
src_vm_persistency_state = "running" | ||
- src_vm_shutoff: | ||
start_vm = "no" | ||
variants: | ||
- with_undefinesource: | ||
virsh_migrate_extra = "--undefinesource" | ||
virsh_migrate_src_state = "failed to get domain" | ||
src_vm_persistency_state = "nonexist" | ||
- without_undefinesource: | ||
virsh_migrate_src_state = "shut off" | ||
src_vm_persistency_state = "shut off" |
65 changes: 65 additions & 0 deletions
65
libvirt/tests/src/migration/offline_migration/offline_migration.py
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,65 @@ | ||
from virttest import virsh | ||
|
||
from virttest.utils_test import libvirt | ||
|
||
from provider.migration import base_steps | ||
|
||
|
||
def run(test, params, env): | ||
""" | ||
Test offline migration. | ||
:param test: test object | ||
:param params: Dictionary with the test parameters | ||
:param env: Dictionary with test environment. | ||
""" | ||
def verify_test(): | ||
""" | ||
Verify steps | ||
""" | ||
desturi = params.get("virsh_migrate_desturi") | ||
virsh_migrate_extra = params.get("virsh_migrate_extra") | ||
virsh_migrate_src_state = params.get("virsh_migrate_src_state") | ||
src_vm_persistency_state = params.get("src_vm_persistency_state") | ||
|
||
test.log.info("Verify steps.") | ||
if virsh_migrate_src_state and "failed to get domain" in virsh_migrate_src_state: | ||
func_returns = dict(migration_obj.migration_test.func_ret) | ||
migration_obj.migration_test.func_ret.clear() | ||
test.log.debug("Migration returns function results:%s", func_returns) | ||
if int(migration_obj.migration_test.ret.exit_status) == 0: | ||
migration_obj.migration_test.post_migration_check([vm], params, | ||
dest_uri=desturi) | ||
result = virsh.domstate(vm_name, extra="--reason", uri=migration_obj.src_uri, debug=True) | ||
libvirt.check_result(result, expected_fails=virsh_migrate_src_state) | ||
else: | ||
migration_obj.verify_default() | ||
|
||
if src_vm_persistency_state: | ||
src_vm_persistency = virsh.dom_list(options="--all --persistent", debug=True) | ||
if src_vm_persistency_state == "nonexist": | ||
if vm_name in src_vm_persistency.stdout.strip(): | ||
test.fail("%s should not exist." % vm_name) | ||
else: | ||
pat_str = "%s.*%s" % (vm_name, src_vm_persistency_state) | ||
libvirt.check_result(src_vm_persistency, expected_match=pat_str) | ||
|
||
dest_vm_xml = virsh.dumpxml(vm_name, extra="--migratable --inactive", debug=True, uri=desturi).stdout.strip() | ||
test.log.debug("dest vm xml: %s", dest_vm_xml) | ||
if dest_vm_xml != src_vm_xml: | ||
test.fail("Check source and target vm xml failed.") | ||
|
||
vm_name = params.get("migrate_main_vm") | ||
|
||
vm = env.get_vm(vm_name) | ||
migration_obj = base_steps.MigrationBase(test, vm, params) | ||
|
||
try: | ||
migration_obj.setup_connection() | ||
src_vm_xml = virsh.dumpxml(vm_name, extra="--migratable --inactive", debug=True).stdout.strip() | ||
test.log.debug("src vm xml: %s", src_vm_xml) | ||
migration_obj.run_migration() | ||
verify_test() | ||
finally: | ||
migration_obj.cleanup_connection() |
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