From mboxrd@z Thu Jan 1 00:00:00 1970 From: jason wang Subject: Re: [KVM-AUTOTEST PATCH 1/2] KVM test: add shutdown test Date: Wed, 17 Jun 2009 11:10:34 +0800 Message-ID: <4A385EAA.1040203@redhat.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: autotest@test.kernel.org, kvm@vger.kernel.org To: Michael Goldish Return-path: Received: from mx2.redhat.com ([66.187.237.31]:49240 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759279AbZFQDKU (ORCPT ); Tue, 16 Jun 2009 23:10:20 -0400 In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: Hello Michael: The shutdown case is useful but the patch does really similar work to vm.destroy(). Maybe we could simple let the preprocess progress to shutdown all the vms just like: - shutdown: install setup vms =3D '' Michael Goldish =D0=B4=B5=C0: > The shutdown test logs into a VM and sends a shutdown command. > It serves two purposes: > - Test KVM's ability to shut down. > - Clean up after the other tests: > Currently VMs of the last test remain alive when Autotest finishes ru= nning. > When one guest finishes testing and another begins, the VM is automat= ically > shut down by the preprocessor because the QEMU command required for t= he next > guest differs from that of the guest that just finished. In the case= of the > final guest this doesn't happen because no guest follows it, so the p= reprocessor > must be explicitly instructed to kill the VM. > However, we have no easy way of knowing which test runs last because = the user > usually selects a subset of the tests/guests. > The addition of a shutdown test can be a decent solution to this smal= l problem: > by convention the shutdown test will always be the last to run, and i= f users > wish to clean up after the tests, they must select the shutdown test. > > Note: it is beneficial to allow users to leave the VMs of the last te= st running > because it saves time when developing and testing tests. A test write= r can run > the test once on a VM, and when the test exits, make some modificatio= ns to its > code and re-run it on the same living VM, and repeat this procedure w= ithout > having to shutdown/boot the VM every time. > > Signed-off-by: Michael Goldish > --- > client/tests/kvm/kvm.py | 1 + > client/tests/kvm/kvm_tests.py | 37 +++++++++++++++++++++++++++++++= ++++++ > 2 files changed, 38 insertions(+), 0 deletions(-) > > diff --git a/client/tests/kvm/kvm.py b/client/tests/kvm/kvm.py > index 9428162..aa727da 100644 > --- a/client/tests/kvm/kvm.py > +++ b/client/tests/kvm/kvm.py > @@ -48,6 +48,7 @@ class kvm(test.test): > "steps": test_routine("kvm_guest_wizard", "ru= n_steps"), > "stepmaker": test_routine("stepmaker", "run_stepm= aker"), > "boot": test_routine("kvm_tests", "run_boot"= ), > + "shutdown": test_routine("kvm_tests", "run_shutd= own"), > "migration": test_routine("kvm_tests", "run_migra= tion"), > "yum_update": test_routine("kvm_tests", "run_yum_u= pdate"), > "autotest": test_routine("kvm_tests", "run_autot= est"), > diff --git a/client/tests/kvm/kvm_tests.py b/client/tests/kvm/kvm_tes= ts.py > index ffe9116..4c9653f 100644 > --- a/client/tests/kvm/kvm_tests.py > +++ b/client/tests/kvm/kvm_tests.py > @@ -57,6 +57,43 @@ def run_boot(test, params, env): > session.close() > =20 > =20 > +def run_shutdown(test, params, env): > + """ > + KVM shutdown test: > + 1) Log into a guest > + 2) Send a shutdown command to the guest > + 3) Wait until it's down > + > + @param test: kvm test object > + @param params: Dictionary with the test parameters > + @param env: Dictionary with test environment > + """ > + vm =3D kvm_utils.env_get_vm(env, params.get("main_vm")) > + if not vm: > + raise error.TestError("VM object not found in environment") > + if not vm.is_alive(): > + raise error.TestError("VM seems to be dead; Test requires a = living VM") > + > + logging.info("Waiting for guest to be up...") > + > + session =3D kvm_utils.wait_for(vm.ssh_login, 240, 0, 2) > + if not session: > + raise error.TestFail("Could not log into guest") > + > + logging.info("Logged in") > + > + # Send the VM's shutdown command > + session.sendline(vm.get_params().get("cmd_shutdown")) > + session.close() > + > + logging.info("Shutdown command sent; waiting for guest to go dow= n...") > + > + if not kvm_utils.wait_for(vm.is_dead, 120, 0, 1): > + raise error.TestFail("Guest refuses to go down") > + > + logging.info("Guest is down") > + > + > def run_migration(test, params, env): > """ > KVM migration test: > =20