From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jiri Zupka Subject: Re: [Autotest] [AUTOTEST][PATCH 2/2] Add ability to call autotest client tests from kvm tests like a subtest. Date: Wed, 4 May 2011 09:57:19 -0400 (EDT) Message-ID: <951967588.349478.1304517439490.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: kvm-autotest@redhat.com, kvm@vger.kernel.org, autotest@test.kernel.org, ldoktor@redhat.com, akong@redhat.com To: Lucas Meneghel Rodrigues Return-path: Received: from mx3-phx2.redhat.com ([209.132.183.24]:57192 "EHLO mx3-phx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752809Ab1EDN5W convert rfc822-to-8bit (ORCPT ); Wed, 4 May 2011 09:57:22 -0400 In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: ----- Original Message ----- > Hi Jiri, after reviewing the code I have comments, similar to > Cleber's: >=20 > On Fri, Apr 29, 2011 at 10:59 AM, Ji=C5=99=C3=AD =C5=BDupka > wrote: > > Example run autotest/client/netperf2 like a server. >=20 > ... snip >=20 > > diff --git a/client/tests/kvm/tests/subtest.py > > b/client/tests/kvm/tests/subtest.py > > new file mode 100644 > > index 0000000..3b546dc > > --- /dev/null > > +++ b/client/tests/kvm/tests/subtest.py > > @@ -0,0 +1,43 @@ > > +import os, logging > > +from autotest_lib.client.virt import virt_utils, virt_test_utils, > > kvm_monitor > > +from autotest_lib.client.bin import job > > +from autotest_lib.client.bin.net import net_utils > > + > > + > > +def run_subtest(test, params, env): > > + """ > > + Run an autotest test inside a guest and subtest on host side. > > + This test should be substitution netperf test in kvm. > > + > > + @param test: kvm test object. > > + @param params: Dictionary with test parameters. > > + @param env: Dictionary with the test environment. > > + """ > > + vm =3D env.get_vm(params["main_vm"]) > > + vm.verify_alive() > > + timeout =3D int(params.get("login_timeout", 360)) > > + session =3D vm.wait_for_login(timeout=3Dtimeout) > > + > > + # Collect test parameters > > + timeout =3D int(params.get("test_timeout", 300)) > > + control_path =3D os.path.join(test.bindir, "autotest_control", > > + params.get("test_control_file")) > > + control_args =3D params.get("test_control_args") > > + outputdir =3D test.outputdir > > + > > + guest_ip =3D vm.get_address() > > + host_ip =3D net_utils.network().get_corespond_local_ip(guest_ip) > > + if not host_ip is None: > > + control_args =3D host_ip + " " + guest_ip > > + > > + guest =3D virt_utils.Thread(virt_test_utils.run_autotest, > > + (vm, session, control_path, control_args, > > + timeout, outputdir, params)) > > + guest.start() > > + > > + test.runsubtest("netperf2", tag=3D"server", server_ip=3Dhost_ip, > > + client_ip=3Dguest_ip, role=3D'server') >=20 > ^ This really should be made generic, since as Cleber mentioned, > calling this test run_subtest wouldn't cut for cases where we run > something other than netperf2. So things that started coming to my > mind: ^ Yes you are right. I wanted to show how use and configure parameter=20 in control file. This shouldn't be a test this test should be only a sa= mple=20 of technology. But I made wrong implanting to tests_base.conf. I try th= ink=20 about tests_base.conf and make this implantation in better way.=20 I repair subtest and send patch again. >=20 > * We could extend the utility function to run autotest tests on a > guest in a way that it can accept a string with the control file > contents, rather than just an existing control file. This way we'd be > more free to run arbitrary control code in guests, while of course > keeping the ability to use existing control files; > * We could actually create an Autotest() class abstraction, very much > like what we have in server control files, such as >=20 > auto_vm1 =3D virt_utils.Autotest(vm1) # This would install autotest i= n a > VM and wait for further commands >=20 > control =3D "job.run_test('sleeptest')" ^ This should be standard t= est in client/tests/ not file from client/te= sts/kvm/autotest_control. >=20 > auto_vm1.run_control(control) # This would run sleeptest and bring > back the results to the host >=20 > It's a matter to see how this is modeled for server side control > files... I believe this could be cleaner and help us a lot... And yes I agree with this. This sounds good.=20 >=20 > In other comments, please use the idiom: >=20 > if foo is not None: >=20 > Across all places where we compare a variable with None, because it's > easier to understand the intent right away and it's on the > CODING_STYLE document. ^^ I try this. >=20 > -- > Lucas