Skip to content

Commit 590456e

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 590456e

File tree

2 files changed

+112
-0
lines changed

2 files changed

+112
-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 = "17179869184"
35+
status_error = "yes"
36+
err_msg = "Parameter 'cache size' expects exceeds guest ram size"
37+
- vm_shutoff:
38+
start_vm = "no"
39+
compression_cache = "536870912"
40+
status_error = "yes"
41+
err_msg = "domain is not running"
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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("Get compression cache fail.")
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("Set compression cache fail.")
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("For failed setting, compression cache is not match with orig size.")
56+
else:
57+
test.log.info("For failed setting, check compression cache PASS.")
58+
else:
59+
value = new_size.split()[0].strip()
60+
unit = new_size.split()[-1].strip()
61+
value = int(float(value))
62+
if unit == "KiB":
63+
size = int(int(compression_cache) / 1024)
64+
elif unit == "MiB":
65+
size = int(int(compression_cache) / 1048576)
66+
elif unit == "GiB":
67+
size = int(int(compression_cache) / 1073741824)
68+
if value != size:
69+
test.fail("For successful setting, compression cache is not match with set.")
70+
else:
71+
test.log.info("For successful setting, check compression cache PASS.")

0 commit comments

Comments
 (0)