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