Re: [Autotest] [AUTOTEST][KVM] [PATCH 2/2] Add ability to call autotest client tests from kvm tests like a subtest.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Jiri, after reviewing the code I have comments, similar to Cleber's:

On Fri, Apr 29, 2011 at 10:59 AM, JiÅÃ Åupka <jzupka@xxxxxxxxxx> wrote:
> Example run autotest/client/netperf2 like a server.

... snip

> 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 = env.get_vm(params["main_vm"])
> + Â Âvm.verify_alive()
> + Â Âtimeout = int(params.get("login_timeout", 360))
> + Â Âsession = vm.wait_for_login(timeout=timeout)
> +
> + Â Â# Collect test parameters
> + Â Âtimeout = int(params.get("test_timeout", 300))
> + Â Âcontrol_path = os.path.join(test.bindir, "autotest_control",
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âparams.get("test_control_file"))
> + Â Âcontrol_args = params.get("test_control_args")
> + Â Âoutputdir = test.outputdir
> +
> + Â Âguest_ip = vm.get_address()
> + Â Âhost_ip = net_utils.network().get_corespond_local_ip(guest_ip)
> + Â Âif not host_ip is None:
> + Â Â Â Âcontrol_args = host_ip + " " + guest_ip
> +
> + Â Â Â Âguest = virt_utils.Thread(virt_test_utils.run_autotest,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (vm, session, control_path, control_args,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âtimeout, outputdir, params))
> + Â Â Â Âguest.start()
> +
> + Â Â Â Âtest.runsubtest("netperf2", tag="server", server_ip=host_ip,
> + Â Â Â Â Â Â client_ip=guest_ip, role='server')

^ 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:

* 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

auto_vm1 = virt_utils.Autotest(vm1) # This would install autotest in a
VM and wait for further commands

control = "job.run_test('sleeptest')"

auto_vm1.run_control(control) # This would run sleeptest and bring
back the results to the host

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...

In other comments, please use the idiom:

if foo is not None:

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.

-- 
Lucas
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux