提交 5b19239f 编写于 作者: V vivianQizhu

Update drive_mirror test cases

上级 d47a7de5
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
no Host_RHEL.m5 no Host_RHEL.m5
no Host_RHEL.m6.u1 no Host_RHEL.m6.u1
no Host_RHEL.m6.u2 no Host_RHEL.m6.u2
no raw qed vmdk no qed vmdk
type = drive_mirror type = drive_mirror_simple
monitor_type = qmp monitor_type = qmp
monitors = qmp1 monitors = qmp1
main_monitor = qmp1 main_monitor = qmp1
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
# config file if that is going to be tested # config file if that is going to be tested
#block_mirror_cmd = "__com.redhat_drive-mirror" #block_mirror_cmd = "__com.redhat_drive-mirror"
#block_reopen_cmd = "__com.redhat_drive-reopen" #block_reopen_cmd = "__com.redhat_drive-reopen"
wait_timeout = 3600 wait_timeout = 6000
# wait_timeout: wait xx seconds for block mirror job go into steady status, aka offset equal image length # wait_timeout: wait xx seconds for block mirror job go into steady status, aka offset equal image length
source_images = "image1" source_images = "image1"
target_image_image1 = "target" target_image_image1 = "target"
...@@ -26,66 +26,74 @@ ...@@ -26,66 +26,74 @@
#for full image or top most #for full image or top most
default_speed_image1 = 0 default_speed_image1 = 0
# default speed unit is B/s, for 10MB/s please set speed to '10M' # default speed unit is B/s, for 10MB/s please set speed to '10M'
image_format_target = "qcow2"
create_mode_target = "absolute-paths" create_mode_target = "absolute-paths"
image_name_target = "images/target1" image_name_target = "images/target1"
check_event = no check_event = no
tmp_dir = "/tmp" tmp_dir = "/tmp"
repeat_times = 3
cancel_timeout = 5
variants: variants:
- simple_test: - 2qcow2:
type = drive_mirror_simple image_format_target = "qcow2"
repeat_times = 3 - 2raw:
cancel_timeout = 5 image_format_target = "raw"
variants:
- @on_localfs:
boot_target_image = no
- on_nfs:
image_type_target = nfs
nfs_mount_dir = "/mnt/nfs"
image_name_target = "${nfs_mount_dir}/target1"
nfs_mount_options = "rw"
export_dir = "/home/nfs"
export_options = "rw,no_root_squash,async"
setup_local_nfs = yes
boot_target_image = yes
start_firewall_cmd = "iptables -A INPUT -p tcp -d 127.0.0.1 --dport 2049 -j DROP"
- on_iscsi:
image_format_target = raw
# target_image will ingore, target_image will generate automatically
image_type_target = iscsi
force_cleanup_target = yes
host_setup_flag_target = 2
boot_target_image = yes
# Please replace below iscsi connection params before start your testing
portal_ip_target = "192.168.1.2"
initiator_target = "iqn.2010-07.test.org:kvmautotest"
target_target = "iqn.2001-05.com.equallogic:0-8a0906-db31f7d03-470263b05654c204-kvm-test"
start_firewall_cmd = "iptables -A INPUT -p tcp -d ${portal_ip_target} --dport 3260 -j DROP"
# End
variants:
- job_cancel:
before_steady = "cancel"
cancel_timeout_image1 = 3
- set_job_speed:
max_speed_image1 = 10M
before_steady = "set_speed"
- reset_job_speed:
default_speed_image1 = 10M
max_speed_image1 = 1M
before_steady = "set_speed"
- query_job_status:
before_steady = "query_status"
default_speed_image1 = 3M
max_speed_image1 = 10M
- job_complete:
type = drive_mirror_complete
boot_target_image = no
variants: variants:
- cancel: - granularity:
before_steady = "cancel" when_steady = check_granularity
cancel_timeout_image1 = 3
- set_speed:
max_speed_image1 = 10M
before_steady = "set_speed"
- reset_speed:
default_speed_image1 = 10M
max_speed_image1 = 1M
before_steady = "set_speed"
- query:
before_steady = "query_status"
default_speed_image1 = 3M
max_speed_image1 = 10M
- mirroring:
variants:
- block_job_complete:
type = drive_mirror_complete
variants:
- target_in_localfs:
boot_target_image = no
- target_in_nfs:
image_type_target = nfs
nfs_mount_dir = "/mnt/nfs"
image_name_target = "${nfs_mount_dir}/target1"
nfs_mount_options = "rw"
export_dir = "/home/nfs"
export_options = "rw,no_root_squash,async"
setup_local_nfs = yes
boot_target_image = yes
- target_to_iscsi:
image_format_target = qcow2
# target_image will ingore, target_image will generate automatically
image_type_target = iscsi
force_cleanup_target = yes
host_setup_flag_target = 2
boot_target_image = yes
# Please replace below iscsi connection params before start your testing
portal_ip_target = "192.168.1.2"
initiator_target = "iqn.2010-07.test.org:kvmautotest"
target_target = "iqn.2001-05.com.equallogic:0-8a0906-db31f7d03-470263b05654c204-kvm-test"
# End
- negative_test:
negative_test = yes
variants: variants:
- readonly_target: - 512:
create_mode_target = existing granularity = 512
before_start = readonly_target buf_count = 10
before_cleanup = clear_readonly_bit - 67108864:
granularity = 67108864
buf_count = 2
- node_name:
after_reopen = check_node_name
node_name = "node2"
- with_stress: - with_stress:
type = drive_mirror_stress type = drive_mirror_stress
reopen_timeout = 600 reopen_timeout = 600
...@@ -140,29 +148,3 @@ ...@@ -140,29 +148,3 @@
before_start = "load_stress" before_start = "load_stress"
when_steady = "powerdown" when_steady = "powerdown"
after_reopen ="verify_alive" after_reopen ="verify_alive"
- cancel_blocked_jobs:
type = drive_mirror_cancel
cancel_timeout = 10
pre_command = "service iptables restart || systemctl restart iptables.service"
stop_firewall_cmd = "iptables -F"
post_command = "iptables -F"
variants:
- target_in_nfs:
image_type_target = nfs
nfs_mount_dir = "/mnt/nfs"
image_name_target = "${nfs_mount_dir}/target1"
nfs_mount_options = "rw"
export_dir = "/home/nfs"
export_options = "rw,no_root_squash,async"
setup_local_nfs = yes
start_firewall_cmd = "iptables -A INPUT -p tcp -d 127.0.0.1 --dport 2049 -j DROP"
- target_to_iscsi:
# target_image will ingore, target_image will generate automatically
image_type_target = iscsi
force_cleanup_target = yes
host_setup_flag_target = 2
# Please replace below iscsi connection params before start your testing
portal_ip_target = "192.168.1.2"
initiator_target = "iqn.2010-07.test.org:kvmautotest"
target_target = "iqn.2001-05.com.equallogic:0-8a0906-db31f7d03-470263b05654c204-kvm-test"
start_firewall_cmd = "iptables -A INPUT -p tcp -d ${portal_ip_target} --dport 3260 -j DROP"
- drive_mirror_negtive_tests:
no Host_RHEL.m5
no Host_RHEL.m6.u1
no Host_RHEL.m6.u2
no qed vmdk
type = drive_mirror_simple
monitor_type = qmp
monitors = qmp1
main_monitor = qmp1
backup_image_before_testing = yes
restore_image_after_testing = yes
# Recent QEMU upstream (and the variants shipped by recent distros) use
# drive-mirror and block-job-complete
block_mirror_cmd = drive-mirror
block_reopen_cmd = block-job-complete
# RHEL6 does use some different, internal commands, need to adjust on your
# config file if that is going to be tested
#block_mirror_cmd = "__com.redhat_drive-mirror"
#block_reopen_cmd = "__com.redhat_drive-reopen"
wait_timeout = 6000
# wait_timeout: wait xx seconds for block mirror job go into steady status, aka offset equal image length
source_images = "image1"
target_image_image1 = "target"
# source_images: set which image will be mirroring to target, now only a image at one time;
full_copy_image1 = "full"
#for full image or top most
default_speed_image1 = 0
# default speed unit is B/s, for 10MB/s please set speed to '10M'
create_mode_target = "absolute-paths"
image_name_target = "images/target1"
check_event = no
tmp_dir = "/tmp"
repeat_times = 3
cancel_timeout = 5
negative_test = yes
variants:
- 2qcow2:
image_format_target = "qcow2"
- 2raw:
image_format_target = "raw"
variants:
- @on_localfs:
boot_target_image = no
- on_nfs:
image_type_target = nfs
nfs_mount_dir = "/mnt/nfs"
image_name_target = "${nfs_mount_dir}/target1"
nfs_mount_options = "rw"
export_dir = "/home/nfs"
export_options = "rw,no_root_squash,async"
setup_local_nfs = yes
boot_target_image = yes
start_firewall_cmd = "iptables -A INPUT -p tcp -d 127.0.0.1 --dport 2049 -j DROP"
- on_iscsi:
image_format_target = raw
# target_image will ingore, target_image will generate automatically
image_type_target = iscsi
force_cleanup_target = yes
host_setup_flag_target = 2
boot_target_image = yes
# Please replace below iscsi connection params before start your testing
portal_ip_target = "192.168.1.2"
initiator_target = "iqn.2010-07.test.org:kvmautotest"
target_target = "iqn.2001-05.com.equallogic:0-8a0906-db31f7d03-470263b05654c204-kvm-test"
start_firewall_cmd = "iptables -A INPUT -p tcp -d ${portal_ip_target} --dport 3260 -j DROP"
# End
variants:
- readonly_target:
only on_localfs
create_mode_target = existing
before_start = readonly_target
before_cleanup = clear_readonly_bit
- cancel_blocked_jobs:
no on_localfs
type = drive_mirror_cancel
cancel_timeout = 10
pre_command = "service iptables restart || systemctl restart iptables.service"
stop_firewall_cmd = "iptables -F"
post_command = "iptables -F"
- cancel_blocked_jobs:
no on_localfs
type = drive_mirror_cancel
cancel_timeout = 10
pre_command = "service iptables restart || systemctl restart iptables.service"
stop_firewall_cmd = "iptables -F"
post_command = "iptables -F"
...@@ -65,6 +65,37 @@ class DriveMirror(block_copy.BlockCopy): ...@@ -65,6 +65,37 @@ class DriveMirror(block_copy.BlockCopy):
image_file = storage.get_image_filename(params, self.data_dir) image_file = storage.get_image_filename(params, self.data_dir)
return self.vm.get_block({"file": image_file}) return self.vm.get_block({"file": image_file})
@error.context_aware
def check_granularity(self):
"""
Check granularity value as set.
"""
device_id = self.get_device()
info = self.vm.monitor.info_block().get(device_id)
if "granularity" in self.params:
target_gran = int(self.params["granularity"])
dirty_bitmap = info.get("dirty-bitmaps", "0")
granularity = int(dirty_bitmap[0].get("granularity", "0"))
if granularity != target_gran:
raise error.TestFail(
"Granularity unmatched. Target is %d, result is %d" %
(target_gran, granularity))
@error.context_aware
def check_node_name(self):
"""
Check node name as set, after block job complete.
"""
device_id = self.vm.get_block({"file": self.target_image})
info = self.vm.monitor.info_block().get(device_id)
if "node_name" in self.params:
node_name_exp = self.params["node_name"]
node_name = info.get("node-name", "")
if node_name != node_name_exp:
raise error.TestFail(
"node-name is: %s, while set value is: %s" %
(node_name, node_name_exp))
@error.context_aware @error.context_aware
def start(self): def start(self):
""" """
...@@ -77,10 +108,18 @@ class DriveMirror(block_copy.BlockCopy): ...@@ -77,10 +108,18 @@ class DriveMirror(block_copy.BlockCopy):
target_format = params["image_format"] target_format = params["image_format"]
create_mode = params["create_mode"] create_mode = params["create_mode"]
full_copy = params["full_copy"] full_copy = params["full_copy"]
args = {"mode": create_mode, "speed": default_speed,
"format": target_format}
if 'granularity' and 'buf_count' in params:
granularity = int(params["granularity"])
buf_size = granularity * int(params["buf_count"])
args.update({"granularity": granularity,
"buf-size": buf_size})
if 'node_name' in params:
args.update({"node-name": params.get("node_name")})
error.context("Start to mirror block device", logging.info) error.context("Start to mirror block device", logging.info)
self.vm.block_mirror(device, target_image, default_speed, self.vm.block_mirror(device, target_image, full_copy,
full_copy, target_format, create_mode) **args)
if not self.get_status(): if not self.get_status():
raise error.TestFail("No active mirroring job found") raise error.TestFail("No active mirroring job found")
if params.get("image_type") != "iscsi": if params.get("image_type") != "iscsi":
......
...@@ -24,7 +24,7 @@ def run_drive_mirror_cancel(test, params, env): ...@@ -24,7 +24,7 @@ def run_drive_mirror_cancel(test, params, env):
bg = utils.InterruptedThread(mirror_test.cancel,) bg = utils.InterruptedThread(mirror_test.cancel,)
bg.start() bg.start()
job = mirror_test.get_status() job = mirror_test.get_status()
if job["type"] != "mirror": if job.get("type", "0") != "mirror":
raise error.TestFail("Job cancel immediacatly") raise error.TestFail("Job cancel immediacatly")
error.context("Cleanup rules in iptables", logging.info) error.context("Cleanup rules in iptables", logging.info)
utils.run(params["stop_firewall_cmd"]) utils.run(params["stop_firewall_cmd"])
......
...@@ -31,9 +31,10 @@ def run(test, params, env): ...@@ -31,9 +31,10 @@ def run(test, params, env):
source_image = mirror_test.get_image_file() source_image = mirror_test.get_image_file()
target_image = mirror_test.get_target_image() target_image = mirror_test.get_target_image()
mirror_test.start() mirror_test.start()
mirror_test.wait_for_steady() mirror_test.action_when_steady()
mirror_test.vm.pause() mirror_test.vm.pause()
mirror_test.reopen() mirror_test.reopen()
mirror_test.action_after_reopen()
device_id = mirror_test.vm.get_block({"file": target_image}) device_id = mirror_test.vm.get_block({"file": target_image})
if device_id != mirror_test.device: if device_id != mirror_test.device:
raise error.TestError("Mirrored image not being used by guest") raise error.TestError("Mirrored image not being used by guest")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册