From: Lucas Meneghel Rodrigues <lmr@redhat.com>
To: autotest@test.kernel.org
Cc: kvm@vger.kernel.org, mst@redhat.com
Subject: Re: [PATCH 1/3] KVM Test: Introduce a helper class to run a test in the background
Date: Fri, 26 Nov 2010 21:16:32 -0200 [thread overview]
Message-ID: <1290813392.2578.60.camel@freedom> (raw)
In-Reply-To: <1290812474-21377-1-git-send-email-lmr@redhat.com>
On Fri, 2010-11-26 at 21:01 -0200, Lucas Meneghel Rodrigues wrote:
> Sometimes, we need to run a test when doing operations on a running VM
> (such as migrate the vm during its rebooting ). So this patch introduces
> a simple warpper BackgroundTest to run a specified test in the background
> through a dedicated thread, it also records the exception raised in the
> thead and raise it when master call join().
Since we've spent some time looking into this and noone came up with a
better solution, I'm applying Jason's series. In order to run the tests
in parallel, on your test set you can put either:
only migrate.with_file_transfer
or
only migrate.with_reboot
Provided, of course, that you already had a vm installed with autotest.
If you don't you probably want to include the unattended_install.cdrom
test before.
Cheers!
Lucas
> Changes from v1:
> - Rebase against latest upstream
>
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---
> client/tests/kvm/kvm_test_utils.py | 49 +++++++++++++++++++++++++++++++++++-
> 1 files changed, 48 insertions(+), 1 deletions(-)
>
> diff --git a/client/tests/kvm/kvm_test_utils.py b/client/tests/kvm/kvm_test_utils.py
> index e7c8d33..218bf31 100644
> --- a/client/tests/kvm/kvm_test_utils.py
> +++ b/client/tests/kvm/kvm_test_utils.py
> @@ -21,7 +21,7 @@ More specifically:
> @copyright: 2008-2009 Red Hat Inc.
> """
>
> -import time, os, logging, re, commands, signal
> +import time, os, logging, re, commands, signal, threading
> from autotest_lib.client.common_lib import error
> from autotest_lib.client.bin import utils
> import kvm_utils, kvm_vm, kvm_subprocess, scan_results
> @@ -564,6 +564,53 @@ def run_autotest(vm, session, control_path, timeout, outputdir):
> raise error.TestFail(e_msg)
>
>
> +class BackgroundTest(object):
> + """
> + This class would run a test in background through a dedicated thread.
> + """
> +
> + def __init__(self, func, params):
> + """
> + Initialize the object and set a few attributes.
> + """
> + self.thread = threading.Thread(target=self.launch,
> + args=(func, params))
> + self.exception = None
> +
> +
> + def launch(self, func, params):
> + """
> + Catch and record the exception.
> + """
> + try:
> + func(*params)
> + except Exception, e:
> + self.exception = e
> +
> +
> + def start(self):
> + """
> + Run func(params) in a dedicated thread
> + """
> + self.thread.start()
> +
> +
> + def join(self):
> + """
> + Wait for the join of thread and raise its exception if any.
> + """
> + self.thread.join()
> + if self.exception:
> + raise self.exception
> +
> +
> + def is_alive(self):
> + """
> + Check whether the test is still alive.
> + """
> + return self.thread.is_alive()
> +
> +
> def get_loss_ratio(output):
> """
> Get the packet loss ratio from the output of ping
next prev parent reply other threads:[~2010-11-26 23:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-26 23:01 [PATCH 1/3] KVM Test: Introduce a helper class to run a test in the background Lucas Meneghel Rodrigues
2010-11-26 23:01 ` [PATCH 2/3] KVM test: Test reboot during migration Lucas Meneghel Rodrigues
2010-11-26 23:01 ` [PATCH 3/3] KVM test: Test the file transfer during migartion Lucas Meneghel Rodrigues
2010-11-26 23:16 ` Lucas Meneghel Rodrigues [this message]
2010-12-01 8:06 ` [PATCH 1/3] KVM Test: Introduce a helper class to run a test in the background Michael Goldish
-- strict thread matches above, loose matches on Subject: below --
2010-09-25 9:36 [PATCH 0/3] Launch other test during migration Jason Wang
2010-09-25 9:36 ` [PATCH 1/3] KVM Test: Introduce a helper class to run a test in the background Jason Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1290813392.2578.60.camel@freedom \
--to=lmr@redhat.com \
--cc=autotest@test.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=mst@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox