Skip to content

Commit

Permalink
Merge pull request #5152 from cliping/downtime
Browse files Browse the repository at this point in the history
migration: Add case about setmaxdowntime/getmaxdowntime
  • Loading branch information
chunfuwen authored Sep 19, 2023
2 parents f0d6846 + 8e3700e commit 00f6660
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
- migration.migration_cmd.setmaxdowntime_and_getmaxdowntime:
type = setmaxdowntime_and_getmaxdowntime
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
image_convert = 'no'
server_ip = "${migrate_dest_host}"
server_user = "root"
server_pwd = "${migrate_dest_pwd}"
status_error = "no"

variants vm_status:
- vm_running:
start_vm = "yes"
variants:
- downtime_100:
status_error = "no"
downtime = "100"
- downtime_0:
status_error = "yes"
downtime = "0"
err_msg = "migrate: Invalid downtime"
- vm_shutoff:
start_vm = "no"
status_error = "yes"
downtime = "100"
err_msg = "Requested operation is not valid: domain is not running"
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):
"""
To verify that vm max downtime during live migration can be set/got by
migrate-setmaxdowntime/getmaxdowntime.
:param test: test object
:param params: Dictionary with the test parameters
:param env: Dictionary with test environment.
"""

def run_test():
"""
Run test for setmaxdowntime/getmaxdowntime
"""
downtime = params.get("downtime")
status_error = "yes" == params.get('status_error', 'no')
error_msg = params.get("err_msg")
vm_status = params.get("vm_status")

test.log.info("Run test for migrate-setmaxdowntime/migrate-getmaxdowntime.")
if vm_status == "vm_running":
orig_maxdowntime = int(virsh.migrate_getmaxdowntime(vm_name).stdout_text.strip())
ret = virsh.migrate_setmaxdowntime(vm_name, downtime, debug=True)
if ret.exit_status:
if status_error and downtime == "0":
libvirt.check_result(ret, error_msg)
else:
test.fail("Set downtime fail.")
new_maxdowntime = int(virsh.migrate_getmaxdowntime(vm_name).stdout_text.strip())
if downtime == "0":
if orig_maxdowntime != new_maxdowntime:
test.fail("For downtime=0, maxdowntime should keep its original value.")
else:
if int(downtime) != new_maxdowntime:
test.fail("Set maxdowntime fail: %s" % new_maxdowntime)
elif vm_status == "vm_shutoff":
ret = virsh.migrate_getmaxdowntime(vm_name, debug=True)
if ret.exit_status:
libvirt.check_result(ret, error_msg)
else:
test.fail("Expect to fail but succeed: migrate_getmaxdowntime")
ret = virsh.migrate_setmaxdowntime(vm_name, downtime, debug=True)
if ret.exit_status:
libvirt.check_result(ret, error_msg)
else:
test.fail("Expect to fail but succeed: migrate_setmaxdowntime")

vm_name = params.get("migrate_main_vm")

vm = env.get_vm(vm_name)
migration_obj = base_steps.MigrationBase(test, vm, params)
migration_obj.setup_default()

try:
run_test()
finally:
migration_obj.cleanup_default()
1 change: 1 addition & 0 deletions spell.ignore
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ genid
getconf
getlink
Getlink
getmaxdowntime
getrandom
getspeed
gfxcard
Expand Down

0 comments on commit 00f6660

Please sign in to comment.