From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?windows-1252?Q?Luk=E1=9A_Doktor?= Subject: Re: [Autotest] [PATCH] KVM-test: Add hdparm subtest Date: Wed, 03 Aug 2011 16:19:07 +0200 Message-ID: <4E3958DB.1000102@redhat.com> References: <20110802033902.422.82801.stgit@t> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: autotest@test.kernel.org, lmr@redhat.com, kvm@vger.kernel.org To: Amos Kong Return-path: Received: from mx1.redhat.com ([209.132.183.28]:52505 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751392Ab1HCOTO (ORCPT ); Wed, 3 Aug 2011 10:19:14 -0400 In-Reply-To: <20110802033902.422.82801.stgit@t> Sender: kvm-owner@vger.kernel.org List-ID: Reviewed, looks sane. Luk=E1=9A Dne 2.8.2011 05:39, Amos Kong napsal(a): > 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. > > Signed-off-by: Feng Yang > Signed-off-by: Amos Kong > --- > client/tests/kvm/tests/hdparm.py | 84 +++++++++++++++++++++= +++++++++++ > client/tests/kvm/tests_base.cfg.sample | 13 +++++ > 2 files changed, 97 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/test= s/hdparm.py > new file mode 100644 > index 0000000..79ce5db > --- /dev/null > +++ b/client/tests/kvm/tests/hdparm.py > @@ -0,0 +1,84 @@ > +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 s= tatus. > + 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 environmen. > + """ > + > + def check_setting_result(set_cmd, timeout): > + params =3D re.findall("(-[a-zA-Z])([0-9]*)", set_cmd) > + disk =3D re.findall("(\/+[a-z]*\/[a-z]*$)", set_cmd)[0] > + for (param, value) in params: > + cmd =3D "hdparm %s %s" % (param, disk) > + (s, output) =3D session.cmd_status_output(cmd, timeout) > + if s !=3D 0: > + raise error.TestError("Fail to get %s parameter valu= e\n" > + "Output is: %s" % (param, outpu= t)) > + if value not in output: > + raise error.TestFail("Fail to set %s parameter to v= alue: %s" > + % (param, value)) > + > + > + def perform_read_timing(disk, timeout, num=3D5): > + results =3D 0 > + for i in range(num): > + cmd =3D params.get("device_cache_read_cmd") % disk > + (s, output) =3D session.cmd_status_output(cmd, timeout) > + if s !=3D 0: > + raise error.TestFail("Fail to perform device/cache r= ead" > + " timings \nOutput is: %s\n" % = output) > + logging.info("Output of device/cache read timing check(%= s of %s):" > + " %s" % (i + 1, num, output)) > + (result, post) =3D re.findall("=3D *([0-9]*.+[0-9]*) ([a= -zA-Z]*)", > + output)[1] > + if post =3D=3D "kB": > + result =3D float(result)/1024.0 > + results +=3D float(result) > + return results/num > + > + vm =3D env.get_vm(params["main_vm"]) > + vm.create() > + session =3D vm.wait_for_login(timeout=3Dint(params.get("login_ti= meout", 360))) > + try: > + timeout =3D float(params.get("cmd_timeout", 60)) > + cmd =3D params.get("get_disk_cmd") > + (s, output) =3D session.cmd_status_output(cmd) > + disk =3D output.strip() > + > + error.context("Setting hard disk to lower performance") > + cmd =3D params.get("low_status_cmd") % disk > + session.cmd(cmd, timeout) > + > + error.context("Checking hard disk keyval under lower perform= ance") > + check_setting_result(cmd, timeout) > + low_result =3D perform_read_timing(disk, timeout) > + logging.info("Buffered disk read speed under low performance= " > + " configuration: %s" % low_result) > + error.context("Setting hard disk to higher performance") > + cmd =3D params.get("high_status_cmd") % disk > + session.cmd(cmd, timeout) > + > + error.context("Checking hard disk keyval under higher perfor= mance") > + check_setting_result(cmd, timeout) > + high_result =3D perform_read_timing(disk, timeout) > + logging.info("Buffered disk read speed under high performanc= e" > + " configuration: %s" % high_result) > + if not float(high_result)> float(low_result): > + raise error.TestFail("High performance setting does not = " > + "increase read speed\n") > + logging.debug("High performance setting increased read speed= !") > + > + finally: > + if session: > + session.close() > diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kv= m/tests_base.cfg.sample > index d597b52..5491630 100644 > --- a/client/tests/kvm/tests_base.cfg.sample > +++ b/client/tests/kvm/tests_base.cfg.sample > @@ -1115,6 +1115,19 @@ variants: > image_snapshot =3D yes > only Linux > > + - hdparm: > + type =3D hdparm > + get_disk_cmd =3D \ls /dev/[vhs]da > + low_status_cmd =3D hdparm -a64 -d0 -u0 %s > + device_cache_read_cmd =3D hdparm -tT %s > + high_status_cmd =3D hdparm -a256 -d1 -u1 %s > + cmd_timeout =3D 540 > + only Linux > + virtio_blk: > + get_disk_cmd =3D \ls /dev/vda > + low_status_cmd =3D hdparm -a32 -r0 %s > + high_status_cmd =3D hdparm -a256 -r1 %s > + > > # NICs > variants: > > _______________________________________________ > Autotest mailing list > Autotest@test.kernel.org > http://test.kernel.org/cgi-bin/mailman/listinfo/autotest