From patchwork Fri Jun 18 00:14:19 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 106771 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 o5I0F2mb015806 for ; Fri, 18 Jun 2010 00:15:04 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757670Ab0FRAOz (ORCPT ); Thu, 17 Jun 2010 20:14:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:19908 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757330Ab0FRAOy (ORCPT ); Thu, 17 Jun 2010 20:14:54 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o5I0EqHb009078 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 17 Jun 2010 20:14:52 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o5I0Ep9G012157; Thu, 17 Jun 2010 20:14:51 -0400 Received: from localhost.localdomain (dhcp-1-188.tlv.redhat.com [10.35.1.188]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o5I0EljI005733; Thu, 17 Jun 2010 20:14:50 -0400 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: Michael Goldish Subject: [KVM-AUTOTEST PATCH 02/18] KVM test: kvm.py: suppress exceptions during postprocessing if the test fails Date: Fri, 18 Jun 2010 03:14:19 +0300 Message-Id: <1276820075-31310-2-git-send-email-mgoldish@redhat.com> In-Reply-To: <1276820075-31310-1-git-send-email-mgoldish@redhat.com> References: <1276820075-31310-1-git-send-email-mgoldish@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 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]); Fri, 18 Jun 2010 00:15:04 +0000 (UTC) diff --git a/client/tests/kvm/kvm.py b/client/tests/kvm/kvm.py index c6e146d..bab1e6f 100644 --- a/client/tests/kvm/kvm.py +++ b/client/tests/kvm/kvm.py @@ -32,49 +32,79 @@ class kvm(test.test): self.write_test_keyval({key: params[key]}) # Open the environment file + logging.info("Unpickling env. You may see some harmless error " + "messages.") env_filename = os.path.join(self.bindir, params.get("env", "env")) env = kvm_utils.load_env(env_filename, {}) - logging.debug("Contents of environment: %s", str(env)) + logging.debug("Contents of environment: %s", env) + + test_passed = False try: try: - # Get the test routine corresponding to the specified test type - t_type = params.get("type") - # Verify if we have the correspondent source file for it - subtest_dir = os.path.join(self.bindir, "tests") - module_path = os.path.join(subtest_dir, "%s.py" % t_type) - if not os.path.isfile(module_path): - raise error.TestError("No %s.py test file found" % t_type) - # Load the test module - f, p, d = imp.find_module(t_type, [subtest_dir]) - test_module = imp.load_module(t_type, f, p, d) - f.close() - - # Preprocess try: - kvm_preprocessing.preprocess(self, params, env) - finally: - kvm_utils.dump_env(env, env_filename) - # Run the test function - run_func = getattr(test_module, "run_%s" % t_type) - try: - run_func(self, params, env) - finally: - kvm_utils.dump_env(env, env_filename) + # Get the test routine corresponding to the specified + # test type + t_type = params.get("type") + # Verify if we have the correspondent source file for it + subtest_dir = os.path.join(self.bindir, "tests") + module_path = os.path.join(subtest_dir, "%s.py" % t_type) + if not os.path.isfile(module_path): + raise error.TestError("No %s.py test file found" % + t_type) + # Load the test module + f, p, d = imp.find_module(t_type, [subtest_dir]) + test_module = imp.load_module(t_type, f, p, d) + f.close() - except Exception, e: - logging.error("Test failed: %s", e) - logging.debug("Postprocessing on error...") + # Preprocess + try: + kvm_preprocessing.preprocess(self, params, env) + finally: + kvm_utils.dump_env(env, env_filename) + # Run the test function + run_func = getattr(test_module, "run_%s" % t_type) + try: + run_func(self, params, env) + finally: + kvm_utils.dump_env(env, env_filename) + test_passed = True + + except Exception, e: + logging.error("Test failed: %s", e) + try: + kvm_preprocessing.postprocess_on_error( + self, params, env) + finally: + kvm_utils.dump_env(env, env_filename) + raise + + finally: + # Postprocess try: - kvm_preprocessing.postprocess_on_error(self, params, env) + try: + kvm_preprocessing.postprocess(self, params, env) + except Exception, e: + if test_passed: + raise + logging.error("Exception raised during " + "postprocessing: %s", e) finally: kvm_utils.dump_env(env, env_filename) - raise + logging.debug("Contents of environment: %s", env) - finally: - # Postprocess - try: - kvm_preprocessing.postprocess(self, params, env) - finally: - kvm_utils.dump_env(env, env_filename) - logging.debug("Contents of environment: %s", str(env)) + except Exception, e: + if params.get("abort_on_error") != "yes": + raise + # Abort on error + logging.info("Aborting job (%s)", e) + for vm in kvm_utils.env_get_all_vms(env): + if vm.is_dead(): + continue + logging.info("VM '%s' is alive.", vm.name) + for m in vm.monitors: + logging.info("'%s' has a %s monitor unix socket at: %s", + vm.name, m.protocol, m.filename) + logging.info("The command line used to start '%s' was:\n%s", + vm.name, vm.make_qemu_command()) + raise error.JobError("Abort requested (%s)" % e) diff --git a/client/tests/kvm/kvm_preprocessing.py b/client/tests/kvm/kvm_preprocessing.py index 17f3a29..84ad7c5 100644 --- a/client/tests/kvm/kvm_preprocessing.py +++ b/client/tests/kvm/kvm_preprocessing.py @@ -362,20 +362,6 @@ def postprocess(test, params, env): int(params.get("post_command_timeout", "600")), params.get("post_command_noncritical") == "yes") - # Abort on error? - if params.get("abort") == "yes": - exc_string = str(sys.exc_info()[1]) - logging.info("Aborting job (%s)", exc_string) - for vm in kvm_utils.env_get_all_vms(env): - if not vm.is_dead(): - logging.info("VM '%s' is alive.", vm.name) - for m in vm.monitors: - logging.info("'%s' has a %s monitor unix socket at: %s", - vm.name, m.protocol, m.filename) - logging.info("The command line used to start '%s' was:\n%s", - vm.name, vm.make_qemu_command()) - raise error.JobError("Abort requested (%s)" % exc_string) - def postprocess_on_error(test, params, env): """