Skip to content

Commit f2bff01

Browse files
committed
migration: Add case about migrate-compcache
To test that memory compression cache size can be set/got by migrate-compcache. VIRT-298168 - [migrate-compcache] set/get cache size for migration memory compression Signed-off-by: lcheng <[email protected]>
1 parent d4a34d0 commit f2bff01

File tree

2 files changed

+115
-0
lines changed

2 files changed

+115
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
- migration.migration_cmd.migrate_compcache:
2+
type = migrate_compcache
3+
migration_setup = 'no'
4+
disk_type = "file"
5+
# Console output can only be monitored via virsh console output
6+
only_pty = True
7+
take_regular_screendumps = no
8+
# Extra options to pass after <domain> <desturi>
9+
virsh_migrate_extra = ''
10+
# SSH connection time out
11+
ssh_timeout = 60
12+
image_convert = 'no'
13+
server_ip = "${migrate_dest_host}"
14+
server_user = "root"
15+
server_pwd = "${migrate_dest_pwd}"
16+
status_error = "no"
17+
variants vm_status:
18+
- vm_running:
19+
start_vm = "yes"
20+
variants:
21+
- compcache_512M:
22+
compression_cache = "536870912"
23+
- compcache_256M:
24+
compression_cache = "268435456"
25+
- compcache_1K:
26+
compression_cache = "1024"
27+
status_error = "yes"
28+
err_msg = "Parameter 'xbzrle_cache_size' expects a power of two no less than the target page size"
29+
- compcache_0:
30+
compression_cache = "0"
31+
status_error = "yes"
32+
err_msg = "Parameter 'xbzrle_cache_size' expects a power of two no less than the target page size"
33+
- compcache_large:
34+
compression_cache = "18446744073709551616"
35+
status_error = "yes"
36+
err_msg = "for <size> option is malformed or out of range"
37+
- vm_shutoff:
38+
start_vm = "no"
39+
compression_cache = "536870912"
40+
status_error = "yes"
41+
err_msg = "domain is not running"
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2+
#
3+
# Copyright Redhat
4+
#
5+
# SPDX-License-Identifier: GPL-2.0
6+
#
7+
# Author: Liping Cheng <[email protected]>
8+
#
9+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10+
11+
from virttest import virsh
12+
13+
from virttest.utils_test import libvirt
14+
15+
16+
def run(test, params, env):
17+
"""
18+
To verify that memory compression cache size can be set/got by
19+
migrate-compcache.
20+
21+
:param test: test object
22+
:param params: Dictionary with the test parameters
23+
:param env: Dictionary with test environment.
24+
"""
25+
vm_name = params.get("migrate_main_vm")
26+
compression_cache = params.get("compression_cache")
27+
status_error = "yes" == params.get("status_error", "no")
28+
err_msg = params.get("err_msg")
29+
vm_status = params.get("vm_status")
30+
vm = env.get_vm(vm_name)
31+
32+
test.log.info("Run test for migrate-compcache/migrate-compcache.")
33+
34+
ret = virsh.migrate_compcache(vm_name, debug=True)
35+
orig_size = None
36+
if ret.exit_status:
37+
if vm_status == "vm_shutoff":
38+
libvirt.check_result(ret, err_msg)
39+
else:
40+
test.fail(f"Failed to get compression cache size: {ret.stdout_text}")
41+
else:
42+
orig_size = ret.stdout_text.strip().split(":")[-1]
43+
44+
ret = virsh.migrate_compcache(vm_name, size=compression_cache, debug=True)
45+
if ret.exit_status:
46+
if status_error:
47+
libvirt.check_result(ret, err_msg)
48+
else:
49+
test.fail(f"Failed to set compression cache size: {ret.stdout_text}")
50+
51+
if vm_status != "vm_shutoff":
52+
new_size = virsh.migrate_compcache(vm_name, debug=True).stdout_text.strip().split(":")[-1]
53+
if status_error:
54+
if orig_size.split()[0].strip() != new_size.split()[0].strip():
55+
test.fail(f"For negative testing, compression cache size is modified: {new_size}")
56+
else:
57+
test.log.info(f"For negative testing, compression cache size "
58+
"remains the same as before.")
59+
else:
60+
value = new_size.split()[0].strip()
61+
unit = new_size.split()[-1].strip()
62+
value = int(float(value))
63+
if unit == "KiB":
64+
size = int(int(compression_cache) / 1024)
65+
elif unit == "MiB":
66+
size = int(int(compression_cache) / 1048576)
67+
elif unit == "GiB":
68+
size = int(int(compression_cache) / 1073741824)
69+
if value != size:
70+
test.fail(f"For positive testing, failed to set the compression "
71+
"cache size: expected {size}, actual {value}")
72+
else:
73+
test.log.info(f"For positive testing, the compression cache "
74+
"size was set successfully.")

0 commit comments

Comments
 (0)