From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yolkfull Chow Subject: [KVM-AUTOTEST PATCH] A test patch - Boot VMs until one of them becomes unresponsive Date: Tue, 09 Jun 2009 16:41:54 +0800 Message-ID: <4A2E2052.7050304@redhat.com> References: <1244433717-3391-1-git-send-email-lmr@redhat.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------060100090202070405040205" Cc: Uri Lublin To: kvm@vger.kernel.org Return-path: Received: from mx2.redhat.com ([66.187.237.31]:54647 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754839AbZFIImG (ORCPT ); Tue, 9 Jun 2009 04:42:06 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n598g808007175 for ; Tue, 9 Jun 2009 04:42:09 -0400 In-Reply-To: <1244433717-3391-1-git-send-email-lmr@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: This is a multi-part message in MIME format. --------------060100090202070405040205 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi, This test will boot VMs until one of them becomes unresponsive, and records the maximum number of VMs successfully started. -- Yolkfull Regards, --------------060100090202070405040205 Content-Type: text/plain; name="kvm_tests.py.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="kvm_tests.py.patch" diff --git a/client/tests/kvm/kvm_tests.py b/client/tests/kvm/kvm_tests.py index cccc48e..7d00277 100644 --- a/client/tests/kvm/kvm_tests.py +++ b/client/tests/kvm/kvm_tests.py @@ -466,3 +466,70 @@ def run_linux_s3(test, params, env): logging.info("VM resumed after S3") session.close() + +def run_boot_vms(tests, params, env): + """ + Boots VMs until one of them becomes unresponsive, and records the maximum + number of VMs successfully started: + 1) boot the first vm + 2) boot the second vm cloned from the first vm, check whether it boots up + and all booted vms can ssh-login + 3) go on until cannot create VM anymore or cannot allocate memory for VM + + @param test: kvm test object + @param params: Dictionary with the test parameters + @param env: Dictionary with test environment. + """ + # boot the first vm + vm1 = kvm_utils.env_get_vm(env, params.get("main_vm")) + + if not vm1: + raise error.TestError("VM object not found in environment") + if not vm1.is_alive(): + raise error.TestError("VM seems to be dead; Test requires a living VM") + + logging.info("Waiting for first guest to be up...") + + vm1_session = kvm_utils.wait_for(vm1.ssh_login, 240, 0, 2) + if not vm1_session: + raise error.TestFail("Could not log into first guest") + + num = 1 + vms = [vm1] + sessions = [vm1_session] + + # boot the VMs + while True: + try: + num += 1 + vm_name = "vm" + str(num) + + # clone vm according to the first one + curr_vm = vm1.clone(vm_name) + logging.info(" Booting the %dth guest" % num) + if not curr_vm.create(): + raise error.TestFail("Cannot boot vm anylonger") + + curr_vm_session = kvm_utils.wait_for(curr_vm.ssh_login, 240, 0, 2) + + if not curr_vm_session: + curr_vm.send_monitor_cmd("quit") + raise error.TestFail("Could not log into %dth guest" % num) + + logging.info(" %dth guest boots up successfully" % num) + sessions.append(curr_vm_session) + vms.append(curr_vm) + + # check whether all previous ssh sessions are responsive + for vm_session in sessions: + if not vm_session.is_responsive(): + logging.error("%dth guest's session is not responsive" \ + % (sessions.index(vm_session) + 1)) + + except (error.TestFail, OSError): + for vm in vms: + logging.info("Shut down the %dth guest" % (vms.index(vm) + 1)) + vm.destroy(gracefully = params.get("kill_vm_gracefully") \ + == "yes") + logging.info("Total number booted successfully: %d" % (num - 1)) + break --------------060100090202070405040205--