未验证 提交 6d5b5dcd 编写于 作者: Y YongxueHong 提交者: GitHub

Merge pull request #1376 from XueqiangWei/multi_disk

qemu.test: Update multi_disk related cases
......@@ -6,10 +6,20 @@
remove_image_image1 = no
cmd_timeout = 1000
black_list = C:
vt_ulimit_nofile = 8192
labeltype = mbr
Linux:
labeltype = gpt
file_system = "xfs ext4"
RHEL.6:
file_system = "ext4 ext3"
start_vm = no
kill_vm = yes
stg_image_name = "images/%s"
check_guest_proc_scsi = no
dd_test = no
need_reboot = no
need_shutdown = no
virtio_scsi:
Linux:
check_guest_proc_scsi = yes
......@@ -30,6 +40,7 @@
stg_image_size = 1G
stg_params = "image_format:qcow2,qcow2,raw "
virtio_blk, virtio_scsi:
no spapr_vscsi
usbs = ""
usb_devices = ""
soundcards = ""
......@@ -37,14 +48,18 @@
stg_image_num = 24
stg_image_size = 5G
stg_image_boot = no
# other variants.
# stg_image_format = qcow2
# stg_drive_format = virtio
# stg_assign_index = yes
Linux:
image_size_image1 = 20G
Windows:
image_size_image1 = 30G
- with_virtio_scsi_TMF:
only Linux
only virtio_blk
stg_image_num = 300
stg_image_size = 50M
stg_params = "drive_format:scsi-hd "
dd_test = "dd if=/dev/zero of=/dev/%s bs=1M count=40 oflag=direct; dd if=/dev/%s of=/dev/null bs=1M count=40 iflag=direct"
need_reboot = yes
- all_drive_format_types:
# virtio-scsi driver support from RHEL6.3
no RHEL.3 RHEL.4 RHEL.5 RHEL.6.0 RHEL.6.1 RHEL.6.2
......@@ -58,29 +73,35 @@
stg_params = "drive_format:ahci,virtio,scsi-hd,usb2"
pseries:
stg_image_num = 3
stg_params = "drive_format:virtio,scsi-hd,usb2"
usbs += " default-ehci"
usb_type_default-ehci = usb-ehci
stg_params = "drive_format:virtio,scsi-hd,usb3"
usbs += " extra_usb"
usb_type_extra_usb = usb-ehci
ppc64le, ppc64:
usb_type_extra_usb = nec-usb-xhci
Host_RHEL.m6:
usbs = "default-ehci"
usb_type_default-ehci = ich9-usb-ehci1
usbs = "extra_usb"
usb_type_extra_usb = ich9-usb-ehci1
ppc64le, ppc64:
usb_type_extra_usb = nec-usb-xhci
- virtio_scsi_variants:
only virtio_scsi
# virtio-scsi driver support from RHEL6.3
no RHEL.3 RHEL.4 RHEL.5 RHEL.6.0 RHEL.6.1 RHEL.6.2
# Decrease length of the command
stg_image_size = 40M
stg_image_size = 50M
drive_letters = 26
stg_params = "drive_format:scsi-disk "
variants:
- @passthrough:
# We need to unload scsi_debug modules used by VM
stg_params = "drive_format:scsi-block "
kill_vm = yes
force_create_image = no
pre_command = "modprobe -r scsi_debug; modprobe sg; modprobe scsi_debug add_host=9 dev_size_mb=40"
pre_command = "modprobe -r scsi_debug; modprobe sg; modprobe scsi_debug add_host=9 dev_size_mb=50"
post_command = "rmmod scsi_debug"
stg_params += "image_raw_device:yes "
stg_params += "image_format:raw "
stg_params += "indirect_image_select:range(-9,0) "
Linux:
need_reboot = yes
variants:
- block:
stg_params += "image_name:/dev/sd* "
......@@ -90,20 +111,32 @@
stg_params += "drive_format:scsi-generic "
stg_params += "image_name:/dev/sg* "
- multi_lun:
only Linux
stg_params += "drive_port:range(0,16383,63) "
Linux:
stg_params += "drive_port:range(0,16383,63) "
Windows:
stg_params += "drive_port:range(0,255,1) "
need_reboot = yes
need_shutdown = yes
- multi_scsiid_lun:
only Linux
stg_params += "drive_unit:range(0,255,1,3) "
stg_params += "drive_port:range(0,16383,8191) "
Linux:
stg_params += "drive_port:range(0,16383,8191) "
Windows:
stg_params += "drive_port:range(0,255,127) "
need_reboot = yes
need_shutdown = yes
- multi_bus_scsiid_lun:
only Linux
ide, virtio_blk:
stg_params += "drive_bus:range(0,15,1,9) "
virtio_scsi:
stg_params += "drive_bus:range(1,15,1,9) "
stg_params += "drive_unit:range(0,255,127,3) "
stg_params += "drive_port:range(0,16383,8191) "
Linux:
stg_params += "drive_port:range(0,16383,8191) "
Windows:
stg_params += "drive_port:range(0,255,127) "
need_reboot = yes
need_shutdown = yes
- debug_params:
# Remove this to execute this test-params-devel test
no multi_disk
......
......@@ -13,6 +13,7 @@ from virttest import env_process
from virttest import error_context
from virttest import qemu_qtree
from virttest import utils_misc
from virttest import utils_disk
_RE_RANGE1 = re.compile(r'range\([ ]*([-]?\d+|n).*\)')
_RE_RANGE2 = re.compile(r',[ ]*([-]?\d+|n)')
......@@ -105,27 +106,6 @@ def run(test, params, env):
session.cmd_status_output(cmd)
session.close()
def _get_disk_index(session, image_size, disk_indexs):
list_disk_cmd = "echo list disk > disk && "
list_disk_cmd += "echo exit >> disk && diskpart /s disk"
disks = session.cmd_output(list_disk_cmd)
size_type = image_size[-1] + "B"
disk_size = ""
if size_type == "MB":
disk_size = image_size[:-1] + " MB"
elif size_type == "GB" and int(image_size[:-1]) < 8:
disk_size = str(int(image_size[:-1])*1024) + " MB"
else:
disk_size = image_size[:-1] + " GB"
regex_str = r'Disk (\d+).*?%s.*?%s' % (disk_size, disk_size)
for disk in disks.splitlines():
if disk.startswith(" Disk"):
o = re.findall(regex_str, disk, re.I | re.M)
if o:
disk_indexs.append(o[0])
error_context.context("Parsing test configuration", logging.info)
stg_image_num = 0
stg_params = params.get("stg_params", "")
......@@ -221,15 +201,17 @@ def run(test, params, env):
error_context.context("Start the guest with those disks", logging.info)
vm = env.get_vm(params["main_vm"])
vm.create(timeout=max(10, stg_image_num), params=params)
session = vm.wait_for_login(timeout=int(params.get("login_timeout", 360)))
login_timeout = int(params.get("login_timeout", 360))
session = vm.wait_for_login(timeout=login_timeout)
n_repeat = int(params.get("n_repeat", "1"))
file_system = [_.strip() for _ in params.get("file_system").split()]
file_system = [_.strip() for _ in params["file_system"].split()]
cmd_timeout = float(params.get("cmd_timeout", 360))
re_str = params["re_str"]
black_list = params["black_list"].split()
stg_image_size = params.get("stg_image_size")
disk_indexs = []
drive_letters = int(params.get("drive_letters", "26"))
stg_image_size = params["stg_image_size"]
dd_test = params.get("dd_test", "no")
labeltype = params.get("labeltype", "gpt")
have_qtree = True
out = vm.monitor.human_monitor_cmd("info qtree", debug=False)
......@@ -251,124 +233,93 @@ def run(test, params, env):
err += tmp1 + tmp2
if err:
test.fail("%s errors occurred while verifying"
" qtree vs. params" % err)
test.fail("%s errors occurred while verifying qtree vs."
" params" % err)
if params.get('multi_disk_only_qtree') == 'yes':
return
try:
cmd = params.get("clean_cmd")
if cmd:
session.cmd_status_output(cmd)
if params.get("os_type") == "windows":
error_context.context("Create partition on those disks", logging.info)
# Get the disk index
_get_disk_index(session, stg_image_size, disk_indexs)
if len(disk_indexs) < stg_image_num:
err_msg = "Set disks num: %d" % stg_image_num
err_msg += ", Get disks num in guest: %d" % len(disk_indexs)
test.fail("Fail to list all the volumes, %s" % err_msg)
# Random select one file system from file_system
index = random.randint(0, (len(file_system) - 1))
fs_type = file_system[index].strip()
for i in range(stg_image_num):
utils_misc.format_windows_disk(session, disk_indexs[i], None,
None, fs_type)
error_context.context("Get disks dev filenames in guest", logging.info)
cmd = params["list_volume_command"]
s, output = session.cmd_status_output(cmd, timeout=cmd_timeout)
if s != 0:
test.fail("List volume command failed with cmd '%s'.\n"
"Output is: %s\n" % (cmd, output))
output = session.cmd_output(cmd, timeout=cmd_timeout)
disks = re.findall(re_str, output)
disks = [item.strip() for item in disks]
disks.sort()
logging.debug("Volume list that meet regular expressions: %s",
" ".join(disks))
images = params.get("images").split()
if len(disks) < len(images):
logging.debug("disks: %s , images: %s", len(disks), len(images))
test.fail("Fail to list all the volumes!")
if params.get("os_type") == "linux":
output = session.cmd_output("mount")
li = re.findall(r"^/dev/(%s)\d*" % re_str, output, re.M)
if li:
black_list.extend(li)
err_msg = "Set disks num: %d" % stg_image_num
err_msg += ", Get disks num in guest: %d"
ostype = params["os_type"]
if ostype == "windows":
error_context.context("Get windows disk index that to "
"be formatted", logging.info)
disks = utils_disk.get_windows_disks_index(session, stg_image_size)
if len(disks) < stg_image_num:
test.fail("Fail to list all the volumes"
", %s" % err_msg % len(disks))
if len(disks) > drive_letters:
black_list.extend(utils_misc.get_winutils_vol(session))
disks = random.sample(disks, drive_letters - len(black_list))
error_context.context("Clear readonly for all disks and online "
"them in windows guest.", logging.info)
if not utils_disk.update_windows_disk_attributes(session, disks):
test.fail("Failed to update windows disk attributes.")
dd_test = "no"
else:
black_list.extend(utils_misc.get_winutils_vol(session))
disks = set(disks)
black_list = set(black_list)
logging.info("No need to check volume '%s'", (disks & black_list))
disks = disks - black_list
error_context.context("Get linux disk that to be "
"formatted", logging.info)
disks = sorted(utils_disk.get_linux_disks(session).keys())
if len(disks) < stg_image_num:
test.fail("Fail to list all the volumes"
", %s" % err_msg % len(disks))
except Exception:
_do_post_cmd(session)
raise
try:
for i in range(n_repeat):
logging.info("iterations: %s", (i + 1))
error_context.context("Format those disks in guest", logging.info)
for disk in disks:
disk = disk.strip()
error_context.context("Preparing disk: %s..." % disk)
error_context.context("Format disk in guest: '%s'" % disk,
logging.info)
# Random select one file system from file_system
index = random.randint(0, (len(file_system) - 1))
fs = file_system[index].strip()
cmd = params["format_command"] % (fs, disk)
error_context.context("formatting test disk")
session.cmd(cmd, timeout=cmd_timeout)
cmd = params.get("mount_command")
if cmd:
cmd = cmd % (disk, disk, disk)
session.cmd(cmd)
error_context.context("Cope file into / out of those disks", logging.info)
fstype = file_system[index].strip()
partitions = utils_disk.configure_empty_disk(
session, disk, stg_image_size, ostype,
fstype=fstype, labeltype=labeltype)
if not partitions:
test.fail("Fail to format disks.")
cmd_list = params["cmd_list"]
for partition in partitions:
if "/" not in partition:
partition += ":"
else:
partition = partition.split("/")[-1]
error_context.context("Copy file into / out of partition:"
" %s..." % partition, logging.info)
for cmd_l in cmd_list.split():
cmd = params.get(cmd_l)
if cmd:
session.cmd(cmd % partition, timeout=cmd_timeout)
cmd = params["compare_command"]
key_word = params["check_result_key_word"]
output = session.cmd_output(cmd)
if key_word not in output:
test.fail("Files on guest os root fs and disk differ")
if dd_test != "no":
error_context.context("dd test on partition: %s..."
% partition, logging.info)
status, output = session.cmd_status_output(
dd_test % (partition, partition), timeout=cmd_timeout)
if status != 0:
test.fail("dd test fail: %s" % output)
need_reboot = params.get("need_reboot", "no")
need_shutdown = params.get("need_shutdown", "no")
if need_reboot == "yes":
error_context.context("Rebooting guest ...", logging.info)
session = vm.reboot(session=session, timeout=login_timeout)
if need_shutdown == "yes":
error_context.context("Shutting down guest ...", logging.info)
vm.graceful_shutdown(timeout=login_timeout)
if vm.is_alive():
test.fail("Fail to shut down guest.")
error_context.context("Start the guest again.", logging.info)
vm = env.get_vm(params["main_vm"])
vm.create(params=params)
session = vm.wait_for_login(timeout=login_timeout)
error_context.context("Delete partitions in guest.", logging.info)
for disk in disks:
disk = disk.strip()
error_context.context("Performing I/O on disk: %s..." % disk)
cmd_list = params["cmd_list"].split()
for cmd_l in cmd_list:
cmd = params.get(cmd_l)
if cmd:
session.cmd(cmd % disk, timeout=cmd_timeout)
cmd = params["compare_command"]
key_word = params["check_result_key_word"]
output = session.cmd_output(cmd)
if key_word not in output:
test.fail("Files on guest os root fs and disk differ")
if params.get("umount_command"):
cmd = params.get("show_mount_cmd")
output = session.cmd_output(cmd)
disks = re.findall(re_str, output)
disks.sort()
for disk in disks:
disk = disk.strip()
error_context.context("Unmounting disk: %s..." % disk)
cmd = params.get("umount_command") % (disk, disk)
session.cmd(cmd)
utils_disk.clean_partition(session, disk, ostype)
finally:
cmd = params.get("show_mount_cmd")
if cmd:
try:
output = session.cmd_output(cmd)
disks = re.findall(re_str, output)
disks.sort()
for disk in disks:
error_context.context("Unmounting disk: %s..." % disk)
cmd = params["umount_command"] % (disk, disk)
session.cmd(cmd)
except Exception as err:
logging.warn("Get error when cleanup, '%s'", err)
_do_post_cmd(session)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册