All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [Autotest] [PATCH 12/19] KVM test: Add new module kvm_test_utils.py
       [not found] <857145908.38101252917938768.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com>
@ 2009-09-14  8:46 ` Michael Goldish
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Goldish @ 2009-09-14  8:46 UTC (permalink / raw)
  To: Uri Lublin; +Cc: kvm, Yolkfull Chow


----- "Uri Lublin" <uril@redhat.com> wrote:

> On 09/14/2009 08:26 AM, Yolkfull Chow wrote:
> > On Wed, Sep 09, 2009 at 09:12:05PM +0300, Michael Goldish wrote:
> >> This module is meant to reduce code size by performing common test
> procedures.
> >> Generally, code here should look like test code.
> 
> >> +def wait_for_login(vm, nic_index=0, timeout=240):
> >> +    """
> >> +    Try logging into a VM repeatedly.  Stop on success or when
> timeout expires.
> >> +
> >> +    @param vm: VM object.
> >> +    @param nic_index: Index of NIC to access in the VM.
> >> +    @param timeout: Time to wait before giving up.
> >> +    @return: A shell session object.
> >> +    """
> >> +    logging.info("Waiting for guest to be up...")
> >> +    session = kvm_utils.wait_for(lambda:
> vm.remote_login(nic_index=nic_index),
> >> +                                 timeout, 0, 2)
> >> +    if not session:
> >> +        raise error.TestFail("Could not log into guest")
> >
> > Hi Michael, I think we should also add a parameter 'vm_name' for
> > wait_for_login(). On the assumption that we boot more than one VMs,
> it's
> > hard to know which guest failed to login according to message
> above.
> > What do you think? :-)
> >
> 
> The VM object ("vm" parameter) "knows" its own name.
> It is a good idea to add that name to log/error messages, since we do
> want to 
> run different tests (VMs) in parallel (although the logs should be
> also saved in 
> different directories/files).
> 
> Regards,
>      Uri.

Currently it would be useful for tests that use multiple VMs, not for
multiple tests running in parallel, because all tests call their main VM
'vm1'.  That can be changed though.  In any case I agree that it's a
good idea.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Autotest] [PATCH 12/19] KVM test: Add new module kvm_test_utils.py
  2009-09-14  7:58                     ` Uri Lublin
@ 2009-09-14  8:40                       ` Yolkfull Chow
  0 siblings, 0 replies; 4+ messages in thread
From: Yolkfull Chow @ 2009-09-14  8:40 UTC (permalink / raw)
  To: Uri Lublin; +Cc: Michael Goldish, kvm

On Mon, Sep 14, 2009 at 10:58:01AM +0300, Uri Lublin wrote:
> On 09/14/2009 08:26 AM, Yolkfull Chow wrote:
>> On Wed, Sep 09, 2009 at 09:12:05PM +0300, Michael Goldish wrote:
>>> This module is meant to reduce code size by performing common test procedures.
>>> Generally, code here should look like test code.
>
>>> +def wait_for_login(vm, nic_index=0, timeout=240):
>>> +    """
>>> +    Try logging into a VM repeatedly.  Stop on success or when timeout expires.
>>> +
>>> +    @param vm: VM object.
>>> +    @param nic_index: Index of NIC to access in the VM.
>>> +    @param timeout: Time to wait before giving up.
>>> +    @return: A shell session object.
>>> +    """
>>> +    logging.info("Waiting for guest to be up...")
>>> +    session = kvm_utils.wait_for(lambda: vm.remote_login(nic_index=nic_index),
>>> +                                 timeout, 0, 2)
>>> +    if not session:
>>> +        raise error.TestFail("Could not log into guest")
>>
>> Hi Michael, I think we should also add a parameter 'vm_name' for
>> wait_for_login(). On the assumption that we boot more than one VMs, it's
>> hard to know which guest failed to login according to message above.
>> What do you think? :-)
>>
>
> The VM object ("vm" parameter) "knows" its own name.
> It is a good idea to add that name to log/error messages, since we do 
> want to run different tests (VMs) in parallel (although the logs should 
> be also saved in different directories/files).
>

Yes, I did ignore that we could use 'vm.name'
instead of adding a parameter for wait_for_login(). Therefore those
log/error messages could be added something like this:

if not session:
    raise error.TestFail("Could not log into guest %s" vm.name)

Thanks for pointing out that. :-)

> Regards,
>     Uri.

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Autotest] [PATCH 12/19] KVM test: Add new module kvm_test_utils.py
  2009-09-14  5:26                   ` [Autotest] " Yolkfull Chow
@ 2009-09-14  7:58                     ` Uri Lublin
  2009-09-14  8:40                       ` Yolkfull Chow
  0 siblings, 1 reply; 4+ messages in thread
From: Uri Lublin @ 2009-09-14  7:58 UTC (permalink / raw)
  To: Yolkfull Chow; +Cc: Michael Goldish, kvm

On 09/14/2009 08:26 AM, Yolkfull Chow wrote:
> On Wed, Sep 09, 2009 at 09:12:05PM +0300, Michael Goldish wrote:
>> This module is meant to reduce code size by performing common test procedures.
>> Generally, code here should look like test code.

>> +def wait_for_login(vm, nic_index=0, timeout=240):
>> +    """
>> +    Try logging into a VM repeatedly.  Stop on success or when timeout expires.
>> +
>> +    @param vm: VM object.
>> +    @param nic_index: Index of NIC to access in the VM.
>> +    @param timeout: Time to wait before giving up.
>> +    @return: A shell session object.
>> +    """
>> +    logging.info("Waiting for guest to be up...")
>> +    session = kvm_utils.wait_for(lambda: vm.remote_login(nic_index=nic_index),
>> +                                 timeout, 0, 2)
>> +    if not session:
>> +        raise error.TestFail("Could not log into guest")
>
> Hi Michael, I think we should also add a parameter 'vm_name' for
> wait_for_login(). On the assumption that we boot more than one VMs, it's
> hard to know which guest failed to login according to message above.
> What do you think? :-)
>

The VM object ("vm" parameter) "knows" its own name.
It is a good idea to add that name to log/error messages, since we do want to 
run different tests (VMs) in parallel (although the logs should be also saved in 
different directories/files).

Regards,
     Uri.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Autotest] [PATCH 12/19] KVM test: Add new module kvm_test_utils.py
  2009-09-09 18:12                 ` [PATCH 12/19] KVM test: Add new module kvm_test_utils.py Michael Goldish
@ 2009-09-14  5:26                   ` Yolkfull Chow
  2009-09-14  7:58                     ` Uri Lublin
  0 siblings, 1 reply; 4+ messages in thread
From: Yolkfull Chow @ 2009-09-14  5:26 UTC (permalink / raw)
  To: Michael Goldish; +Cc: autotest, kvm

On Wed, Sep 09, 2009 at 09:12:05PM +0300, Michael Goldish wrote:
> This module is meant to reduce code size by performing common test procedures.
> Generally, code here should look like test code.
> More specifically:
>     - Functions in this module should raise exceptions if things go wrong
>       (unlike functions in kvm_utils.py and kvm_vm.py which report failure via
>       their returned values).
>     - Functions in this module may use logging.info(), in addition to
>       logging.debug() and logging.error(), to log messages the user may be
>       interested in (unlike kvm_utils.py and kvm_vm.py which use
>       logging.debug() for everything that isn't an error).
>     - Functions in this module typically use functions and classes from
>       lower-level modules (e.g. kvm_utils.py, kvm_vm.py, kvm_subprocess.py).
>     - Functions in this module should not be used by lower-level modules.
>     - Functions in this module should be used in the right context.
>       For example, a function should not be used where it may display
>       misleading or inaccurate info or debug messages.
> 
> Signed-off-by: Michael Goldish <mgoldish@redhat.com>
> ---
>  client/tests/kvm/kvm_test_utils.py |   61 ++++++++++++++++++++++++++++++++++++
>  1 files changed, 61 insertions(+), 0 deletions(-)
>  create mode 100644 client/tests/kvm/kvm_test_utils.py
> 
> diff --git a/client/tests/kvm/kvm_test_utils.py b/client/tests/kvm/kvm_test_utils.py
> new file mode 100644
> index 0000000..39e92b9
> --- /dev/null
> +++ b/client/tests/kvm/kvm_test_utils.py
> @@ -0,0 +1,61 @@
> +import time, os, logging, re, commands
> +from autotest_lib.client.common_lib import utils, error
> +import kvm_utils, kvm_vm, kvm_subprocess
> +
> +"""
> +High-level KVM test utility functions.
> +
> +This module is meant to reduce code size by performing common test procedures.
> +Generally, code here should look like test code.
> +More specifically:
> +    - Functions in this module should raise exceptions if things go wrong
> +      (unlike functions in kvm_utils.py and kvm_vm.py which report failure via
> +      their returned values).
> +    - Functions in this module may use logging.info(), in addition to
> +      logging.debug() and logging.error(), to log messages the user may be
> +      interested in (unlike kvm_utils.py and kvm_vm.py which use
> +      logging.debug() for anything that isn't an error).
> +    - Functions in this module typically use functions and classes from
> +      lower-level modules (e.g. kvm_utils.py, kvm_vm.py, kvm_subprocess.py).
> +    - Functions in this module should not be used by lower-level modules.
> +    - Functions in this module should be used in the right context.
> +      For example, a function should not be used where it may display
> +      misleading or inaccurate info or debug messages.
> +
> +@copyright: 2008-2009 Red Hat Inc.
> +"""
> +
> +
> +def get_living_vm(env, vm_name):
> +    """
> +    Get a VM object from the environment and make sure it's alive.
> +
> +    @param env: Dictionary with test environment.
> +    @param vm_name: Name of the desired VM object.
> +    @return: A VM object.
> +    """
> +    vm = kvm_utils.env_get_vm(env, vm_name)
> +    if not vm:
> +        raise error.TestError("VM '%s' not found in environment" % vm_name)
> +    if not vm.is_alive():
> +        raise error.TestError("VM '%s' seems to be dead; test requires a "
> +                              "living VM" % vm_name)
> +    return vm
> +
> +
> +def wait_for_login(vm, nic_index=0, timeout=240):
> +    """
> +    Try logging into a VM repeatedly.  Stop on success or when timeout expires.
> +
> +    @param vm: VM object.
> +    @param nic_index: Index of NIC to access in the VM.
> +    @param timeout: Time to wait before giving up.
> +    @return: A shell session object.
> +    """
> +    logging.info("Waiting for guest to be up...")
> +    session = kvm_utils.wait_for(lambda: vm.remote_login(nic_index=nic_index),
> +                                 timeout, 0, 2)
> +    if not session:
> +        raise error.TestFail("Could not log into guest")

Hi Michael, I think we should also add a parameter 'vm_name' for
wait_for_login(). On the assumption that we boot more than one VMs, it's
hard to know which guest failed to login according to message above.
What do you think? :-)

> +    logging.info("Logged in")
> +    return session
> -- 
> 1.5.4.1
> 
> _______________________________________________
> Autotest mailing list
> Autotest@test.kernel.org
> http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-09-14  8:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <857145908.38101252917938768.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com>
2009-09-14  8:46 ` [Autotest] [PATCH 12/19] KVM test: Add new module kvm_test_utils.py Michael Goldish
2009-09-09 18:11 [PATCH 03/19] KVM test: scan_results.py: allow parsing and printing of multiple result files Michael Goldish
2009-09-09 18:11 ` [PATCH 04/19] KVM test: kvm_utils.py: add kill_process_tree() Michael Goldish
2009-09-09 18:11   ` [PATCH 05/19] KVM test: kvm_subprocess: use kill_process_tree() to close child processes Michael Goldish
2009-09-09 18:11     ` [PATCH 06/19] KVM test: timedrift test: set CPU affinity recursively for all children Michael Goldish
2009-09-09 18:12       ` [PATCH 07/19] KVM test: kvm_subprocess: get rid of get_pid() (replace it with get_shell_pid()) Michael Goldish
2009-09-09 18:12         ` [PATCH 08/19] KVM test: remove unused function is_sshd_running() Michael Goldish
2009-09-09 18:12           ` [PATCH 09/19] KVM test: kvm_config.py: remove unused function get_match_block_indices() Michael Goldish
2009-09-09 18:12             ` [PATCH 10/19] KVM test: boot test: add option to reboot using system_reset Michael Goldish
2009-09-09 18:12               ` [PATCH 11/19] KVM test: shutdown test: allow shutting down using system_powerdown Michael Goldish
2009-09-09 18:12                 ` [PATCH 12/19] KVM test: Add new module kvm_test_utils.py Michael Goldish
2009-09-14  5:26                   ` [Autotest] " Yolkfull Chow
2009-09-14  7:58                     ` Uri Lublin
2009-09-14  8:40                       ` Yolkfull Chow

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.