From patchwork Thu Apr 21 06:21:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amos Kong X-Patchwork-Id: 723961 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p3L6LXi1026947 for ; Thu, 21 Apr 2011 06:21:33 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750935Ab1DUGVa (ORCPT ); Thu, 21 Apr 2011 02:21:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:30953 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750784Ab1DUGV3 (ORCPT ); Thu, 21 Apr 2011 02:21:29 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p3L6LRPx031361 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 21 Apr 2011 02:21:27 -0400 Received: from [127.0.0.1] (dhcp-8-167.nay.redhat.com [10.66.8.167]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p3L6LP85003978; Thu, 21 Apr 2011 02:21:26 -0400 Subject: [Autotest PATCH] KVM-test: Simple stop/continue test To: autotest@test.kernel.org From: Amos Kong Cc: lmr@redhat.com, kvm@vger.kernel.org Date: Thu, 21 Apr 2011 14:21:13 +0800 Message-ID: <20110421062112.9564.51395.stgit@t> User-Agent: StGit/0.15 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 21 Apr 2011 06:21:33 +0000 (UTC) Change guest state by monitor cmd, verify guest status, and try to login guest by network. Signed-off-by: Jason Wang Signed-off-by: Amos Kong --- client/tests/kvm/tests/stop_continue.py | 52 +++++++++++++++++++++++++++++++ client/tests/kvm/tests_base.cfg.sample | 4 ++ 2 files changed, 56 insertions(+), 0 deletions(-) create mode 100644 client/tests/kvm/tests/stop_continue.py -- 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 diff --git a/client/tests/kvm/tests/stop_continue.py b/client/tests/kvm/tests/stop_continue.py new file mode 100644 index 0000000..c7d8025 --- /dev/null +++ b/client/tests/kvm/tests/stop_continue.py @@ -0,0 +1,52 @@ +import logging +from autotest_lib.client.common_lib import error + + +def run_stop_continue(test, params, env): + """ + Suspend a running Virtual Machine and verify its state. + + 1) Boot the vm + 2) Suspend the vm through stop command + 3) Verify the state through info status command + 4) Check is the ssh session to guest is still responsive, + if succeed, fail the test. + + @param test: Kvm test object + @param params: Dictionary with the test parameters + @param env: Dictionary with test environment. + """ + vm = env.get_vm(params["main_vm"]) + vm.verify_alive() + timeout = float(params.get("login_timeout", 240)) + session = vm.wait_for_login(timeout=timeout) + + try: + logging.info("Suspend the virtual machine") + vm.monitor.cmd("stop") + + logging.info("Verifying the status of virtual machine through monitor") + o = vm.monitor.info("status") + if 'paused' not in o and ( "u'running': False" not in str(o)): + logging.error(o) + raise error.TestFail("Fail to suspend through monitor command line") + + logging.info("Check the session responsiveness") + if session.is_responsive(): + raise error.TestFail("Session is still responsive after stop") + + logging.info("Try to resume the guest") + vm.monitor.cmd("cont") + + o = vm.monitor.info("status") + m_type = params.get("monitor_type", "human") + if ('human' in m_type and 'running' not in o) or\ + ('qmp' in m_type and "u'running': True" not in str(o)): + logging.error(o) + raise error.TestFail("Could not continue the execution") + + logging.info("Try to re-log into guest") + session = vm.wait_for_login(timeout=timeout) + + finally: + session.close() diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/tests_base.cfg.sample index 5d274f8..7333ed0 100644 --- a/client/tests/kvm/tests_base.cfg.sample +++ b/client/tests/kvm/tests_base.cfg.sample @@ -260,6 +260,10 @@ variants: - systemtap: test_control_file = systemtap.control + - stop_continue: + type = stop_continue + kill_vm_on_error = yes + - linux_s3: install setup unattended_install.cdrom only Linux type = linux_s3