From: Yolkfull Chow Subject: Re: [Autotest] [PATCH 12/19] KVM test: Add new module kvm_test_utils.py Date: Mon, 14 Sep 2009 16:40:10 +0800 Message-ID: <20090914084010.GB2476@aFu.nay.redhat.com> References: <1252519932-30733-5-git-send-email-mgoldish@redhat.com> <1252519932-30733-6-git-send-email-mgoldish@redhat.com> <1252519932-30733-7-git-send-email-mgoldish@redhat.com> <1252519932-30733-8-git-send-email-mgoldish@redhat.com> <1252519932-30733-9-git-send-email-mgoldish@redhat.com> <1252519932-30733-10-git-send-email-mgoldish@redhat.com> <1252519932-30733-11-git-send-email-mgoldish@redhat.com> <1252519932-30733-12-git-send-email-mgoldish@redhat.com> <20090914052644.GA2476@aFu.nay.redhat.com> <4AADF789.9050603@redhat.com> Reply-To: Yolkfull Chow Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Michael Goldish , kvm@vger.kernel.org To: Uri Lublin Return-path: Received: from mx1.redhat.com ([209.132.183.28]:41196 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750815AbZINIjf (ORCPT ); Mon, 14 Sep 2009 04:39:35 -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 n8E8ddsr020699 for ; Mon, 14 Sep 2009 04:39:39 -0400 Content-Disposition: inline In-Reply-To: <4AADF789.9050603@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: 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