From patchwork Wed May 25 09:19:31 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Feng Yang X-Patchwork-Id: 815392 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p4P9Jl4R011488 for ; Wed, 25 May 2011 09:19:47 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754275Ab1EYJTo (ORCPT ); Wed, 25 May 2011 05:19:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:5612 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753315Ab1EYJTo (ORCPT ); Wed, 25 May 2011 05:19:44 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p4P9Jgm6022324 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 25 May 2011 05:19:42 -0400 Received: from fyang.redhat.com (dhcp-65-138.nay.redhat.com [10.66.65.138]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p4P9Jdm4011340; Wed, 25 May 2011 05:19:40 -0400 From: fyang@redhat.com To: autotest@test.kernel.org Cc: kvm@vger.kernel.org, Feng Yang Subject: [PATCH 1/2] KVM Test: Add a new kvm subtest multi_disk. Date: Wed, 25 May 2011 17:19:31 +0800 Message-Id: <1306315171-26747-1-git-send-email-fyang@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 25 May 2011 09:19:47 +0000 (UTC) From: Feng Yang This case test multi disk suport in kvm guest os. It can work on Linux and Windows guest. Signed-off-by: Feng Yang --- client/tests/kvm/tests/multi_disk.py | 127 ++++++++++++++++++++++++++++++++++ 1 files changed, 127 insertions(+), 0 deletions(-) create mode 100644 client/tests/kvm/tests/multi_disk.py diff --git a/client/tests/kvm/tests/multi_disk.py b/client/tests/kvm/tests/multi_disk.py new file mode 100644 index 0000000..262a65d --- /dev/null +++ b/client/tests/kvm/tests/multi_disk.py @@ -0,0 +1,127 @@ +import logging, re, random +from autotest_lib.client.common_lib import error + +def run_multi_disk(test, params, env): + """ + Test multi disk suport of guest, this case will: + 1)create disks image in configuration file + 2)start the guest with those disks. + 3)format those disks. + 4)cope file into / out of those disks. + 5)compare the original file and the copyed file by md5 or fc comand. + 6) Repeat step 3-5 if need + + @param test: kvm test object + @param params: Dictionary with the test parameters + @param env: Dictionary with test environment. + """ + vm = env.get_vm(params["main_vm"]) + vm.verify_alive() + session = vm.wait_for_login(timeout=int(params.get("login_timeout", 360))) + + images = params.get("images").split() + n_repeat = int(params.get("n_repeat", "1")) + image_num = len(images) + disk_num = 0 + file_system = params.get("file_system").split() + fs_num = len(file_system) + cmd_timeout = float(params.get("cmd_timeout", 360)) + re_str = params.get("re_str") + block_list = params.get("block_list").split() + try: + if params.get("clean_cmd"): + cmd = params.get("clean_cmd") + session.cmd_status_output(cmd) + if params.get("pre_cmd"): + cmd = params.get("pre_cmd") + (s,output) = session.cmd_status_output(cmd, timeout=cmd_timeout) + if s != 0: + raise error.TestFail("Create partition on disk failed.\n" + "Output is:%s \n" % output) + cmd = params.get("list_volume_command") + (s,output) = session.cmd_status_output(cmd, timeout=cmd_timeout) + if s != 0: + raise error.TestFail("List volume command failed.\n" + "Output is:%s\n" % output) + disks = re.findall(re_str, output) + disks.sort() + logging.debug("Volume list that meet regular expressions: %s" % disks) + if len(disks) < image_num: + raise error.TestFail("Fail to list all the volume!") + + tmp_list = [] + for disk in disks: + if disk.strip() in block_list: + tmp_list.append(disk) + for disk in tmp_list: + logging.info("No need check volume %s" % disk) + disks.remove(disk) + + for i in range(n_repeat): + logging.info("iterations: %s" %(i + 1)) + for disk in disks: + disk = disk.strip() + + logging.info("Format disk: %s..." % disk) + index = random.randint(0,fs_num -1) + + # Random select one file system from file_system + fs = file_system[index].strip() + cmd = params.get("format_command") % (fs, disk) + (s, output) = session.cmd_status_output(cmd, + timeout=cmd_timeout) + if s != 0: + raise error.TestFail("Format disk failed with output: %s" % + output) + if params.get("mount_command"): + cmd = params.get("mount_command") % (disk, disk, disk) + (s, output) = session.cmd_status_output(cmd) + if s != 0: + raise error.TestFail("Mount disk failed. Output: %s" % + output) + + for disk in disks: + disk = disk.strip() + + logging.info("Performing I/O on disk: %s..." % disk) + cmd_list = params.get("cmd_list").split() + for cmd_l in cmd_list: + if params.get(cmd_l): + cmd = params.get(cmd_l) % disk + (s, output) = session.cmd_status_output(cmd, + timeout=cmd_timeout) + if s != 0: + raise error.TestFail("Failed command: %. Output:%s" % + (cmd,output)) + cmd = params.get("compare_command") + (s, output) = session.cmd_status_output(cmd) + if s != 0: + raise error.TestFail("Fail to compare two files. Output:%s" % + output) + key_word = params.get("check_result_key_word") + if key_word and key_word in output: + logging.debug("Guest's virtual disk %s works fine" % disk) + elif key_word: + raise error.TestFail("Two files are not the same!") + else: + raise error.TestError("check_result_key_word is not specified!") + + if params.get("umount_command"): + cmd = params.get("show_mount_cmd") + (s,output) = session.cmd_status_output(cmd) + disks = re.findall(re_str, output) + disks.sort() + for disk in disks: + disk = disk.strip() + + cmd = params.get("umount_command") % (disk, disk) + (s,output) = session.cmd_status_output(cmd) + if s != 0: + raise error.TestFail("Fail to unmount disk. Output is:%s" % + output) + finally: + if params.get("post_cmd"): + cmd = params.get("post_cmd") + session.cmd_status_output(cmd) + session.close() +