From: Michael Goldish Subject: Re: [Autotest] [PATCH 12/19] KVM test: Add new module kvm_test_utils.py Date: Mon, 14 Sep 2009 04:46:27 -0400 (EDT) Message-ID: <283897882.38121252917987083.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com> References: <857145908.38101252917938768.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, Yolkfull Chow To: Uri Lublin Return-path: Received: from mx1.redhat.com ([209.132.183.28]:27074 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750915AbZINIqX (ORCPT ); Mon, 14 Sep 2009 04:46:23 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n8E8kRif012423 for ; Mon, 14 Sep 2009 04:46:27 -0400 In-Reply-To: <857145908.38101252917938768.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: ----- "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). > > 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.