From patchwork Wed Aug 3 23:33:57 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Meneghel Rodrigues X-Patchwork-Id: 1033132 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p73NYQXS024743 for ; Wed, 3 Aug 2011 23:34:27 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932306Ab1HCXeJ (ORCPT ); Wed, 3 Aug 2011 19:34:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:30761 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932297Ab1HCXeC (ORCPT ); Wed, 3 Aug 2011 19:34:02 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p73NY10Y027440 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 3 Aug 2011 19:34:01 -0400 Received: from freedom.redhat.com (vpn-8-156.rdu.redhat.com [10.11.8.156]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p73NXxwL012058; Wed, 3 Aug 2011 19:34:00 -0400 From: Lucas Meneghel Rodrigues To: autotest@test.kernel.org Cc: kvm@vger.kernel.org, Amos Kong , Feng Yang Subject: [PATCH] KVM test: Add hdparm subtest v2 Date: Wed, 3 Aug 2011 20:33:57 -0300 Message-Id: <1312414437-8783-1-git-send-email-lmr@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 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, 03 Aug 2011 23:34:35 +0000 (UTC) From: Amos Kong This test uses 'hdparm' to set disk device to low/high performance status, and compare the reading speed. The emulated device should pass all the tests. Changes from v1: * Little changes in message wording * Better logging of hdparm messages (better looking logs) * Proper printing of average speeds (.2f rather than s) Signed-off-by: Feng Yang Signed-off-by: Amos Kong --- client/tests/kvm/tests/hdparm.py | 89 ++++++++++++++++++++++++++++++++ client/tests/kvm/tests_base.cfg.sample | 13 +++++ 2 files changed, 102 insertions(+), 0 deletions(-) create mode 100644 client/tests/kvm/tests/hdparm.py diff --git a/client/tests/kvm/tests/hdparm.py b/client/tests/kvm/tests/hdparm.py new file mode 100644 index 0000000..9092fc7 --- /dev/null +++ b/client/tests/kvm/tests/hdparm.py @@ -0,0 +1,89 @@ +import re, logging +from autotest_lib.client.common_lib import error + + +@error.context_aware +def run_hdparm(test, params, env): + """ + Test hdparm setting on linux guest os. This case will: + 1) Set/record parameters value of hard disk to low performance status. + 2) Perform device/cache read timings then record the results. + 3) Set/record parameters value of hard disk to high performance status. + 4) Perform device/cache read timings then compare two results. + + @param test: KVM test object. + @param params: Dictionary with the test parameters. + @param env: Dictionary with test environment. + """ + def check_setting_result(set_cmd, timeout): + params = re.findall("(-[a-zA-Z])([0-9]*)", set_cmd) + disk = re.findall("(\/+[a-z]*\/[a-z]*$)", set_cmd)[0] + for (param, value) in params: + cmd = "hdparm %s %s" % (param, disk) + (s, output) = session.cmd_status_output(cmd, timeout) + if s != 0: + raise error.TestError("Fail to get %s parameter value. " + "Output is:\n%s" % (param, output.strip())) + if value not in output: + raise error.TestFail("Fail to set %s parameter to value: %s" + % (param, value)) + + + def perform_read_timing(disk, timeout, num=5): + results = 0 + for i in range(num): + cmd = params.get("device_cache_read_cmd") % disk + (s, output) = session.cmd_status_output(cmd, timeout) + if s != 0: + raise error.TestFail("Fail to perform device/cache read" + " timings \nOutput is: %s\n" % output) + logging.info("Output of device/cache read timing check (%s of %s):" + % (i + 1, num)) + for line in output.strip().splitlines(): + logging.info(line) + (result, unit) = re.findall("= *([0-9]*.+[0-9]*) ([a-zA-Z]*)", + output)[1] + if unit == "kB": + result = float(result)/1024.0 + results += float(result) + return results/num + + + vm = env.get_vm(params["main_vm"]) + vm.create() + session = vm.wait_for_login(timeout=int(params.get("login_timeout", 360))) + try: + timeout = float(params.get("cmd_timeout", 60)) + cmd = params.get("get_disk_cmd") + output = session.cmd(cmd) + disk = output.strip() + + error.context("Setting hard disk to lower performance") + cmd = params.get("low_status_cmd") % disk + session.cmd(cmd, timeout) + + error.context("Checking hard disk keyval under lower performance " + "settings") + check_setting_result(cmd, timeout) + low_result = perform_read_timing(disk, timeout) + logging.info("Average buffered disk read speed under low performance " + "settings: %.2f MB/sec" % low_result) + + error.context("Setting hard disk to higher performance") + cmd = params.get("high_status_cmd") % disk + session.cmd(cmd, timeout) + + error.context("Checking hard disk keyval under higher performance " + "settings") + check_setting_result(cmd, timeout) + high_result = perform_read_timing(disk, timeout) + logging.info("Average buffered disk read speed under high performance " + "settings: %.2f MB/sec" % high_result) + + if not float(high_result) > float(low_result): + raise error.TestFail("High performance setting does not " + "increase read speed\n") + + finally: + if session: + session.close() diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/tests_base.cfg.sample index 5012a46..acd9883 100644 --- a/client/tests/kvm/tests_base.cfg.sample +++ b/client/tests/kvm/tests_base.cfg.sample @@ -1137,6 +1137,19 @@ variants: fdisk_string = "10 MB, 10485760 bytes" only Linux + - hdparm: + type = hdparm + get_disk_cmd = \ls /dev/[vhs]da + low_status_cmd = hdparm -a64 -d0 -u0 %s + device_cache_read_cmd = hdparm -tT %s + high_status_cmd = hdparm -a256 -d1 -u1 %s + cmd_timeout = 540 + only Linux + virtio_blk: + get_disk_cmd = \ls /dev/vda + low_status_cmd = hdparm -a32 -r0 %s + high_status_cmd = hdparm -a256 -r1 %s + # NICs variants: