提交 b1d9db90 编写于 作者: P peixiu

Add iozone/reboot/shutdown test after hotplug a data disk

Run iozone test on hotpluged data disk on windows guests.
Add test case reboot and shutdown guest after hotplug a data disk.
Signed-off-by: Npeixiu <phou@redhat.com>
上级 f03446c4
...@@ -5,11 +5,10 @@ import time ...@@ -5,11 +5,10 @@ import time
from virttest import data_dir from virttest import data_dir
from virttest import storage from virttest import storage
from virttest import error_context from virttest import error_context
from virttest import utils_misc
from virttest import utils_test from virttest import utils_test
from virttest.qemu_devices import qdevices from virttest.qemu_devices import qdevices
from avocado.core import exceptions
@error_context.context_aware @error_context.context_aware
def run(test, params, env): def run(test, params, env):
...@@ -39,9 +38,11 @@ def run(test, params, env): ...@@ -39,9 +38,11 @@ def run(test, params, env):
""" """
if params.get("os_type") == "linux": if params.get("os_type") == "linux":
pattern = params.get("get_disk_pattern", "^/dev/vd[a-z]*$") pattern = params.get("get_disk_pattern", "^/dev/vd[a-z]*$")
else: elif params.get("os_type") == "windows":
pattern = "^\d+" pattern = "^\d+"
cmd = params.get("get_disk_index", "wmic diskdrive get index") cmd = params.get("get_disk_index", "wmic diskdrive get index")
else:
test.cancel("Unsupported OS type '%s'" % params.get("os_type"))
session = vm.wait_for_login(timeout=timeout) session = vm.wait_for_login(timeout=timeout)
output = session.cmd_output_safe(cmd) output = session.cmd_output_safe(cmd)
...@@ -67,12 +68,14 @@ def run(test, params, env): ...@@ -67,12 +68,14 @@ def run(test, params, env):
get_disk_cmd = params.get("get_disk_cmd") get_disk_cmd = params.get("get_disk_cmd")
context_msg = "Running sub test '%s' %s" context_msg = "Running sub test '%s' %s"
device_list = [] device_list = []
disk_index = params.objects("disk_index")
disk_letter = params.objects("disk_letter")
vm = env.get_vm(params["main_vm"]) vm = env.get_vm(params["main_vm"])
vm.verify_alive() vm.verify_alive()
for i in xrange(repeat_times): for iteration in xrange(repeat_times):
error_context.context("Hotplug block device (iteration %d)" % i, error_context.context("Hotplug block device (iteration %d)" % iteration,
logging.info) logging.info)
sub_type = params.get("sub_type_before_plug") sub_type = params.get("sub_type_before_plug")
...@@ -91,7 +94,7 @@ def run(test, params, env): ...@@ -91,7 +94,7 @@ def run(test, params, env):
ver_out = controller.verify_hotplug("", vm.monitor) ver_out = controller.verify_hotplug("", vm.monitor)
if not ver_out: if not ver_out:
err = "%s is not in qtree after hotplug" % controller_model err = "%s is not in qtree after hotplug" % controller_model
raise exceptions.TestFail(err) test.fail(err)
disks_before_plug = find_disk(vm, get_disk_cmd) disks_before_plug = find_disk(vm, get_disk_cmd)
...@@ -107,7 +110,7 @@ def run(test, params, env): ...@@ -107,7 +110,7 @@ def run(test, params, env):
ver_out = device.verify_hotplug("", vm.monitor) ver_out = device.verify_hotplug("", vm.monitor)
if not ver_out: if not ver_out:
err = "%s is not in qtree after hotplug" % pci_type err = "%s is not in qtree after hotplug" % pci_type
raise exceptions.TestFail(err) test.fail(err)
time.sleep(pause) time.sleep(pause)
disks_after_plug = find_disk(vm, get_disk_cmd) disks_after_plug = find_disk(vm, get_disk_cmd)
...@@ -121,33 +124,45 @@ def run(test, params, env): ...@@ -121,33 +124,45 @@ def run(test, params, env):
device_list.append(device) device_list.append(device)
if not new_disks: if not new_disks:
raise exceptions.TestFail("Cannot find new disk after hotplug.") test.fail("Cannot find new disk after hotplug.")
if params.get("need_plug") == "yes": if params.get("need_plug") == "yes":
disk = new_disks[0] disk = new_disks[0]
else: else:
disk = new_disks[num] disk = new_disks[num]
session = vm.wait_for_login(timeout=timeout)
if params.get("os_type") == "windows":
if iteration == 0:
error_context.context("Format disk", logging.info)
utils_misc.format_windows_disk(session, disk_index[num],
mountpoint=disk_letter[num])
error_context.context("Check block device after hotplug.", error_context.context("Check block device after hotplug.",
logging.info) logging.info)
if params.get("pci_test_cmd"): if params.get("disk_op_cmd"):
if params.get("os_type") == "linux": if params.get("os_type") == "linux":
test_cmd = params.get("pci_test_cmd") % (disk, disk) test_cmd = params.get("disk_op_cmd") % (disk, disk)
elif params.get("os_type") == "windows":
test_cmd = params.get("disk_op_cmd") % (disk_letter[num],
disk_letter[num])
test_cmd = utils_misc.set_winutils_letter(session, test_cmd)
else: else:
test_cmd = re.sub("PCI_NUM", "%s" % (num + 1), test.cancel("Unsupported OS type '%s'" % params.get("os_type"))
params.get("pci_test_cmd"))
session = vm.wait_for_login(timeout=timeout) status, output = session.cmd_status_output(test_cmd,
s, o = session.cmd_status_output(test_cmd, timeout=disk_op_timeout) timeout=disk_op_timeout)
if status:
test.fail("Check for block device failed "
"after hotplug, Output: %r" % output)
session.close() session.close()
if s:
raise exceptions.TestFail("Check for block device failed "
"after hotplug, Output: %r" % o)
sub_type = params.get("sub_type_after_plug") sub_type = params.get("sub_type_after_plug")
if sub_type: if sub_type:
error_context.context(context_msg % (sub_type, "after hotplug"), error_context.context(context_msg % (sub_type, "after hotplug"),
logging.info) logging.info)
utils_test.run_virt_sub_test(test, params, env, sub_type) utils_test.run_virt_sub_test(test, params, env, sub_type)
if vm.is_dead():
return
sub_type = params.get("sub_type_before_unplug") sub_type = params.get("sub_type_before_unplug")
if sub_type: if sub_type:
...@@ -156,7 +171,7 @@ def run(test, params, env): ...@@ -156,7 +171,7 @@ def run(test, params, env):
utils_test.run_virt_sub_test(test, params, env, sub_type) utils_test.run_virt_sub_test(test, params, env, sub_type)
for num in xrange(blk_num): for num in xrange(blk_num):
error_context.context("Unplug block device (iteration %d)" % i, error_context.context("Unplug block device (iteration %d)" % iteration,
logging.info) logging.info)
device_list[num].unplug(vm.monitor) device_list[num].unplug(vm.monitor)
device_list[num].verify_unplug("", vm.monitor) device_list[num].verify_unplug("", vm.monitor)
......
...@@ -11,10 +11,16 @@ ...@@ -11,10 +11,16 @@
remove_image_stg0 = yes remove_image_stg0 = yes
force_create_image_stg0 = yes force_create_image_stg0 = yes
get_disk_cmd = "ls /dev/[hsv]d[a-z]* | sort" get_disk_cmd = "ls /dev/[hsv]d[a-z]* | sort"
pci_test_cmd = "dd if=%s of=/dev/null bs=1k count=1000 iflag=direct &&" disk_op_cmd = "dd if=%s of=/dev/null bs=1k count=1000 iflag=direct &&"
pci_test_cmd += " dd if=/dev/zero of=%s bs=1k count=1000 oflag=direct" disk_op_cmd += " dd if=/dev/zero of=%s bs=1k count=1000 oflag=direct"
kill_vm_on_error = yes kill_vm_on_error = yes
Windows:
disk_index = "1 2"
disk_letter = "I J"
disk_op_cmd = "WIN_UTILS:\Iozone\iozone.exe -azR -r 64k -n 125M -g 512M -M -i 0"
disk_op_cmd += " -i 1 -b %s:\iozone_test -f %s:\testfile"
variants: variants:
- one_pci: - one_pci:
blk_num = 1 blk_num = 1
...@@ -34,9 +40,14 @@ ...@@ -34,9 +40,14 @@
- with_repetition: - with_repetition:
repeat_times = 300 repeat_times = 300
- with_reboot: - with_reboot:
sub_type_after_plug = boot
sub_type_after_unplug = boot sub_type_after_unplug = boot
reboot_method = shell reboot_method = shell
- with_shutdown: - with_shutdown:
variants:
- after_plug:
sub_type_after_plug = shutdown
- after_unplug:
sub_type_after_unplug = shutdown sub_type_after_unplug = shutdown
shutdown_method = shell shutdown_method = shell
check_img = yes check_img = yes
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册