Skip to content

Commit

Permalink
migration: Add bandwidth limit case
Browse files Browse the repository at this point in the history
VIRT-297906 - VM live migration with copy storage - bandwidth limit

Signed-off-by: lcheng <[email protected]>
  • Loading branch information
cliping committed Oct 26, 2023
1 parent bef0af4 commit 462199b
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
- migration_with_copy_storage.migration_bandwidth_limit:
type = migration_bandwidth_limit
migration_setup = 'yes'
# 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
start_vm = "yes"
# Local URI
virsh_migrate_connect_uri = qemu:///system"
virsh_migrate_dest_state = "running"
virsh_migrate_src_state = "shut off"
image_convert = "no"
server_ip = "${migrate_dest_host}"
server_user = "root"
server_pwd = "${migrate_dest_pwd}"
client_ip = "${migrate_source_host}"
client_user = "root"
client_pwd = "${migrate_source_pwd}"
status_error = "no"
simple_disk_check_after_mig = "no"
migrate_desturi_port = "16509"
migrate_desturi_type = "tcp"
virsh_migrate_desturi = "qemu+tcp://${migrate_dest_host}/system"
setup_nfs = "no"
nfs_mount_dir =
bandwidth = "20"
jobinfo_item = "Memory bandwidth:"
precopy_bandwidth = "${bandwidth}"
compare_to_value = "${bandwidth}"
action_during_mig = '[{"func": "check_bandwidth_by_blockjob", "after_event": "block-job", "before_event": "migration-iteration", "func_param": "params", "wait_for_event_timeout": "600"}, {"func": "check_domjobinfo_during_mig", "after_event": "migration-iteration", "func_param": "params"}]'
migrate_start_state = "running"
variants:
- p2p:
virsh_migrate_options = "--live --p2p --verbose"
- non_p2p:
virsh_migrate_options = "--live --verbose"
variants set_bandwidth:
- bandwidth:
virsh_migrate_extra = "--bandwidth ${bandwidth}"
- setspeed_before_migration:
- setspeed_during_migration:
virsh_migrate_extra = "--bandwidth 30"
action_during_mig = '[{"func": "set_bandwidth", "after_event": "block-job", "func_param": "params", "wait_for_event_timeout": "600"}, {"func": "check_bandwidth_by_blockjob", "func_param": "params"}, {"func": "check_domjobinfo_during_mig", "func_param": "params"}]'
variants:
- copy_storage_all:
copy_storage_option = "--copy-storage-all"
- copy_storage_inc:
copy_storage_option = "--copy-storage-inc"
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright Redhat
#
# SPDX-License-Identifier: GPL-2.0

# Author: Liping Cheng <[email protected]>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

from virttest import virsh

from provider.migration import base_steps


def run(test, params, env):
"""
To verify that bandwidth limit can take effect for storage copying during
migration.
:param test: test object
:param params: Dictionary with the test parameters
:param env: Dictionary with test environment.
"""
def setup_setspeed_before_migration():
"""
Setup for setspeed_before_migration
"""
bandwidth = params.get("bandwidth")

test.log.info("Setup bandwidth limit before migration.")
migration_obj.setup_connection()
virsh.migrate_setspeed(vm_name, bandwidth, debug=True)

def cleanup_test():
"""
Cleanup steps
"""
migration_obj.cleanup_connection()
base_steps.cleanup_disks_remote(params, vm)

set_bandwidth = params.get('set_bandwidth', '')
vm_name = params.get("migrate_main_vm")

vm = env.get_vm(vm_name)
params.update({'vm_obj': vm})
migration_obj = base_steps.MigrationBase(test, vm, params)
setup_test = eval("setup_%s" % set_bandwidth) if "setup_%s" % set_bandwidth in \
locals() else migration_obj.setup_connection

try:
setup_test()
base_steps.prepare_disks_remote(params, vm)
migration_obj.run_migration()
migration_obj.verify_default()
finally:
cleanup_test()
14 changes: 14 additions & 0 deletions provider/migration/migration_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def parse_funcs(action_during_mig, test, params):
'before_event': one_action.get('before_event'),
'before_pause': one_action.get('before_pause'),
'need_sleep_time': one_action.get('need_sleep_time'),
'wait_for_event_timeout': one_action.get('wait_for_event_timeout'),
'func_param': func_param})
action_during_mig.append(act_dict)
return action_during_mig
Expand Down Expand Up @@ -726,3 +727,16 @@ def get_vm_serial_session_on_dest(params):
vm_session = migration_obj.vm.wait_for_serial_login(timeout=120)
params.update({"vm_session": vm_session})
migration_obj.vm.connect_uri = backup_uri


def check_bandwidth_by_blockjob(params):
"""
Check bandwidth by blockjob
:param params: dictionary with the test parameter, get vm name and bandwidth
"""
vm_name = params.get("main_vm")
bandwidth = params.get("bandwidth")

if not utils_misc.wait_for(lambda: libvirt.check_blockjob(vm_name, 'vda', "bandwidth", str(int(bandwidth)*1024*1024)), 10, step=2):
raise exceptions.TestFail("Check bandwidth failed.")

0 comments on commit 462199b

Please sign in to comment.