From patchwork Wed Apr 7 08:49:16 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Feng Yang X-Patchwork-Id: 90978 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o378nSjp032393 for ; Wed, 7 Apr 2010 08:49:29 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752181Ab0DGIt2 (ORCPT ); Wed, 7 Apr 2010 04:49:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:29750 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751830Ab0DGItZ (ORCPT ); Wed, 7 Apr 2010 04:49:25 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o378nOYc016465 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 7 Apr 2010 04:49:24 -0400 Received: from localhost.localdomain ([10.66.91.72]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o378nGdx009801; Wed, 7 Apr 2010 04:49:22 -0400 From: Feng Yang To: autotest@test.kernel.org Cc: kvm@vger.kernel.org, Feng Yang Subject: [PATCH 3/3] KVM Test: Add ioquit test case Date: Wed, 7 Apr 2010 16:49:16 +0800 Message-Id: <1270630156-9904-3-git-send-email-fyang@redhat.com> In-Reply-To: <1270630156-9904-2-git-send-email-fyang@redhat.com> References: <1270630156-9904-1-git-send-email-fyang@redhat.com> <1270630156-9904-2-git-send-email-fyang@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 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.3 (demeter.kernel.org [140.211.167.41]); Wed, 07 Apr 2010 08:49:29 +0000 (UTC) diff --git a/client/tests/kvm/tests/ioquit.py b/client/tests/kvm/tests/ioquit.py new file mode 100644 index 0000000..c75a0e3 --- /dev/null +++ b/client/tests/kvm/tests/ioquit.py @@ -0,0 +1,54 @@ +import logging, time, random, signal, os +from autotest_lib.client.common_lib import error +import kvm_test_utils, kvm_utils + + +def run_ioquit(test, params, env): + """ + Emulate the poweroff under IO workload(dbench so far) using monitor + command 'quit'. + + @param test: Kvm test object + @param params: Dictionary with the test parameters. + @param env: Dictionary with test environment. + """ + vm = kvm_test_utils.get_living_vm(env, params.get("main_vm")) + session = kvm_test_utils.wait_for_login(vm, + timeout=int(params.get("login_timeout", 360))) + session2 = kvm_test_utils.wait_for_login(vm, + timeout=int(params.get("login_timeout", 360))) + def is_autotest_launched(): + if session.get_command_status("pgrep autotest") != 0: + logging.debug("Autotest process not found") + return False + return True + + test_name = params.get("background_test", "dbench") + control_file = params.get("control_file", "dbench.control") + timeout = int(params.get("test_timeout", 300)) + control_path = os.path.join(test.bindir, "autotest_control", + control_file) + outputdir = test.outputdir + + pid = kvm_test_utils.run_autotest_background(vm, session2, control_path, + timeout, test_name, + outputdir) + if pid < 0: + raise error.TestError("Could not create child process to execute " + "autotest background") + + if kvm_utils.wait_for(is_autotest_launched, 240, 0, 2): + logging.debug("Background autotest successfully") + else: + logging.debug("Background autotest failed, start the test anyway") + + time.sleep(100 + random.randrange(0,100)) + logging.info("Kill the virtual machine") + vm.process.close() + + logging.info("Kill the tracking process") + kvm_utils.safe_kill(pid, signal.SIGKILL) + kvm_test_utils.wait_autotest_background(pid) + session.close() + session2.close() + diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/tests_base.cfg.sample index 9b12fc2..d8530f6 100644 --- a/client/tests/kvm/tests_base.cfg.sample +++ b/client/tests/kvm/tests_base.cfg.sample @@ -305,6 +305,10 @@ variants: - ksm_parallel: ksm_mode = "parallel" + - ioquit: + type = ioquit + control_file = dbench.control.200 + background_test = dbench # system_powerdown, system_reset and shutdown *must* be the last ones # defined (in this order), since the effect of such tests can leave # the VM on a bad state.