From patchwork Wed Jun 13 07:37:14 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yongqin Liu X-Patchwork-Id: 9257 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id C93AA23E55 for ; Wed, 13 Jun 2012 07:37:20 +0000 (UTC) Received: from mail-gh0-f180.google.com (mail-gh0-f180.google.com [209.85.160.180]) by fiordland.canonical.com (Postfix) with ESMTP id 7A5A4A18AF0 for ; Wed, 13 Jun 2012 07:37:20 +0000 (UTC) Received: by ghbz12 with SMTP id z12so153020ghb.11 for ; Wed, 13 Jun 2012 00:37:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf :content-type:mime-version:x-launchpad-project:x-launchpad-branch :x-launchpad-message-rationale:x-launchpad-branch-revision-number :x-launchpad-notification-type:to:from:subject:message-id:date :reply-to:sender:errors-to:precedence:x-generated-by :x-launchpad-hash:x-gm-message-state; bh=JWIe4DbbyvRG5YgEBZlYXQINiGNF51FrfChXzfpv2Hg=; b=pvHR31q0N3CwPh3j19tIahdM+5hj7stCeSt145/lZv6ovW0WGHs1bBzo3krgu8h22Z jOf9CPGR2r2o3G3yfX/A1iNY8tJPMav34ZrwkHAvp/EhvnCMOHbn9vQ3FqlIByyc61Gq CoMeIyGL/mq6c9mbarbwqFAt1VHLQZKl4bW9aXF0DpYtMFV0lbAaorSpCezefqTTb02Y R40GKEPuQ7zEAV/HiYtQDpv43aMj+gbZn6EP9xLdhyRoAGhBd824ziNdMB14311wF/dY j9V2Rq5LIgyTqy9m0C6y3/wVVveG/Np6uCcCr/OqzHOY9wep5rzmtSRRWpFK/JrKZGBw Ghgw== Received: by 10.50.163.99 with SMTP id yh3mr9834877igb.53.1339573039750; Wed, 13 Jun 2012 00:37:19 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.24.148 with SMTP id v20csp7552ibb; Wed, 13 Jun 2012 00:37:15 -0700 (PDT) Received: by 10.180.96.106 with SMTP id dr10mr35150064wib.3.1339573034759; Wed, 13 Jun 2012 00:37:14 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id dz2si8951673wib.14.2012.06.13.00.37.14 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 13 Jun 2012 00:37:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) client-ip=91.189.90.7; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) smtp.mail=bounces@canonical.com Received: from ackee.canonical.com ([91.189.89.26]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1Sei8g-0001WE-6v for ; Wed, 13 Jun 2012 07:37:14 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 2877EE000F for ; Wed, 13 Jun 2012 07:37:14 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: lava-dispatcher X-Launchpad-Branch: ~linaro-validation/lava-dispatcher/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 322 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-validation/lava-dispatcher/trunk] Rev 322: merge with the branch that adding support for android test actions Message-Id: <20120613073714.25825.17491.launchpad@ackee.canonical.com> Date: Wed, 13 Jun 2012 07:37:14 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="15389"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: a6830284fadbf64c46a24d512fe99990e8977e0f X-Gm-Message-State: ALoCoQmsFTMB7p0vG28PoMRzUFxbYDZrEg7eliDvfBGktOHzQjmSUsdeS9KywOpCdNJrMLKt3szr Merge authors: Yongqin Liu (liuyq0307) Related merge proposals: https://code.launchpad.net/~liuyq0307/lava-dispatcher/support-timeout-of-android-test-actions/+merge/109609 proposed by: Yongqin Liu (liuyq0307) review: Approve - Michael Hudson-Doyle (mwhudson) ------------------------------------------------------------ revno: 322 [merge] committer: Yongqin Liu branch nick: lava-dispatcher timestamp: Wed 2012-06-13 15:35:23 +0800 message: merge with the branch that adding support for android test actions modified: lava_dispatcher/actions/lava-android-test.py lava_dispatcher/client/base.py lava_dispatcher/client/master.py lava_dispatcher/job.py --- lp:lava-dispatcher https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk You are subscribed to branch lp:lava-dispatcher. To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk/+edit-subscription === modified file 'lava_dispatcher/actions/lava-android-test.py' --- lava_dispatcher/actions/lava-android-test.py 2012-04-26 07:44:18 +0000 +++ lava_dispatcher/actions/lava-android-test.py 2012-06-07 10:49:44 +0000 @@ -23,7 +23,7 @@ import subprocess import logging from lava_dispatcher.actions import BaseAction -from lava_dispatcher.client.base import OperationFailed +from lava_dispatcher.client.base import OperationFailed, TimeoutError from lava_dispatcher.utils import generate_bundle_file_name @@ -62,9 +62,17 @@ bundle_name)] if option is not None: cmds.extend(['-O', option]) + if timeout != -1: + cmds.insert(0, 'timeout') + cmds.insert(1, '%ss' % timeout) + logging.info("Execute command on host: %s" % (' '.join(cmds))) rc = subprocess.call(cmds) - if rc != 0: + if rc == 124: + raise TimeoutError( + "The test case(%s) on device(%s) times out" % ( + test_name, session.dev_name)) + elif rc != 0: raise OperationFailed( "Failed to run test case(%s) on device(%s) with return " "value: %s" % (test_name, session.dev_name, rc)) @@ -116,9 +124,17 @@ bundle_name)]) if parser is not None: cmds.extend(['-p', parser]) + + if timeout != -1: + cmds.insert(0, 'timeout') + cmds.insert(1, '%ss' % timeout) logging.info("Execute command on host: %s" % (' '.join(cmds))) rc = subprocess.call(cmds) - if rc != 0: + if rc == 124: + raise TimeoutError( + "The test (%s) on device(%s) times out." % ( + ' '.join(cmds), session.dev_name)) + elif rc != 0: raise OperationFailed( "Failed to run test custom case[%s] on device(%s)" " with return value: %s" % (' '.join(cmds), @@ -156,9 +172,17 @@ cmds.extend(['-s', session.dev_name, '-o', '%s/%s.bundle' % (self.context.host_result_dir, bundle_name)]) + if timeout != -1: + cmds.insert(0, 'timeout') + cmds.insert(1, '%ss' % timeout) + logging.info("Execute command on host: %s" % (' '.join(cmds))) rc = subprocess.call(cmds) - if rc != 0: + if rc == 124: + raise TimeoutError( + "Failed to run monkeyrunner test url[%s] " + "on device(%s)" % (url, session.dev_name)) + elif rc != 0: raise OperationFailed( "Failed to run monkeyrunner test url[%s] on device(%s)" " with return value: %s" % (url, session.dev_name, rc)) @@ -188,9 +212,17 @@ '-s', session.dev_name] if option is not None: cmds.extend(['-o', option]) + if timeout != -1: + cmds.insert(0, 'timeout') + cmds.insert(1, '%ss' % timeout) logging.info("Execute command on host: %s" % (' '.join(cmds))) rc = subprocess.call(cmds) - if rc != 0: + if rc == 124: + raise OperationFailed( + "The installation of test case(%s)" + " on device(%s) times out" % (test, + session.dev_name)) + elif rc != 0: raise OperationFailed( "Failed to install test case(%s) on device(%s) with " "return value: %s" % (test, session.dev_name, rc)) === modified file 'lava_dispatcher/client/base.py' --- lava_dispatcher/client/base.py 2012-05-31 10:43:31 +0000 +++ lava_dispatcher/client/base.py 2012-06-13 07:35:23 +0000 @@ -513,6 +513,12 @@ """ +class TimeoutError(DispatcherError): + """ + The timeout error + """ + + class CriticalError(DispatcherError): """ The critical error === modified file 'lava_dispatcher/client/master.py' --- lava_dispatcher/client/master.py 2012-06-11 19:54:52 +0000 +++ lava_dispatcher/client/master.py 2012-06-13 07:35:23 +0000 @@ -813,10 +813,10 @@ self.proc.sendline("reboot") # Looking for reboot messages or if they are missing, the U-Boot message will also indicate the # reboot is done. - id = self.proc.expect( + match_id = self.proc.expect( ['Restarting system.', 'The system is going down for reboot NOW', 'Will now restart', 'U-Boot', pexpect.TIMEOUT], timeout=120) - if id not in [0, 1, 2, 3]: + if match_id not in [0, 1, 2, 3]: raise Exception("Soft reboot failed") def hard_reboot(self): @@ -839,7 +839,8 @@ def _enter_uboot(self): interrupt_boot_prompt = self.device_option('interrupt_boot_prompt') - self.proc.expect(interrupt_boot_prompt) + if self.proc.expect(interrupt_boot_prompt) != 0: + raise Exception("Faile to enter uboot") interrupt_boot_command = self.device_option('interrupt_boot_command') self.proc.sendline(interrupt_boot_command) === modified file 'lava_dispatcher/job.py' --- lava_dispatcher/job.py 2012-05-29 02:10:58 +0000 +++ lava_dispatcher/job.py 2012-06-13 07:35:23 +0000 @@ -1,4 +1,4 @@ -# Copyright (C) 2011 Linaro Limited +# Copyright (C) 2011-2012 Linaro Limited # # Author: Paul Larson # @@ -21,14 +21,17 @@ import json import logging import pexpect +import time import traceback from json_schema_validator.schema import Schema from json_schema_validator.validator import Validator from lava_dispatcher.actions import get_all_cmds -from lava_dispatcher.client.base import CriticalError, GeneralError from lava_dispatcher.context import LavaContext +from lava_dispatcher.client.base import CriticalError, \ + TimeoutError, \ + GeneralError job_schema = { @@ -123,7 +126,7 @@ def logging_level(self): try: return self.job_data['logging_level'] - except : + except: return None def run(self): @@ -131,7 +134,8 @@ self._set_logging_level() lava_commands = get_all_cmds() - if self.job_data['actions'][-1]['command'].startswith("submit_results"): + if self.job_data['actions'][-1]['command'].startswith( + "submit_results"): submit_results = self.job_data['actions'].pop(-1) else: submit_results = None @@ -147,15 +151,43 @@ self.context.test_data.add_tags(self.tags) try: + job_length = len(self.job_data['actions']) + job_num = 0 for cmd in self.job_data['actions']: + job_num = job_num + 1 params = cmd.get('parameters', {}) - logging.info("[ACTION-B] %s is started with %s" % (cmd['command'], params)) + if cmd.get('command').startswith('lava_android_test'): + if not params.get('timeout') and \ + self.job_data.get('timeout'): + params['timeout'] = self.job_data['timeout'] + logging.info("[ACTION-B] %s is started with %s" % ( + cmd['command'], params)) metadata = cmd.get('metadata', {}) self.context.test_data.add_metadata(metadata) action = lava_commands[cmd['command']](self.context) try: status = 'fail' action.run(**params) + except TimeoutError as err: + if cmd.get('command').startswith('lava_android_test'): + logging.warning("[ACTION-E] %s times out." % ( + cmd['command'])) + if job_num == job_length: + ## not reboot the android image for + ## the last test action + pass + else: + ## clear the session on the serial and wait a while + ## and not put the following 3 sentences into the + ## boot_linaro_android_image method just for + ## avoiding effects when the method being called + ## in other places + logging.warning( + "Now the android image will be rebooted") + self.context.client.proc.sendcontrol("c") + self.context.client.proc.sendline("") + time.sleep(5) + self.context.client.boot_linaro_android_image() except CriticalError as err: raise except (pexpect.TIMEOUT, GeneralError) as err: @@ -167,23 +199,29 @@ finally: err_msg = "" if status == 'fail': - logging.warning("[ACTION-E] %s is finished with error (%s)." %(cmd['command'], err)) - err_msg = "Lava failed at action %s with error: %s\n" %\ - (cmd['command'], unicode(str(err), 'ascii', 'replace')) + logging.warning( + "[ACTION-E] %s is finished with error (%s)." % ( + cmd['command'], err)) + err_msg = ("Lava failed at action %s with error:" + "%s\n") % (cmd['command'], + unicode(str(err), + 'ascii', 'replace')) if cmd['command'] == 'lava_test_run': - err_msg += "Lava failed on test: %s" %\ + err_msg += "Lava failed on test: %s" % \ params.get('test_name', "Unknown") err_msg = err_msg + traceback.format_exc() # output to both serial log and logfile self.context.client.sio.write(err_msg) else: - logging.info("[ACTION-E] %s is finished successfully." %cmd['command']) + logging.info( + "[ACTION-E] %s is finished successfully." % ( + cmd['command'])) err_msg = "" self.context.test_data.add_result( action.test_name(**params), status, err_msg) except: #Capture all user-defined and non-user-defined critical errors - self.context.test_data.job_status='fail' + self.context.test_data.job_status = 'fail' raise finally: if submit_results: @@ -213,4 +251,6 @@ elif level == 'CRITICAL': logging.root.setLevel(logging.CRITICAL) else: - logging.warning("Unknown logging level in the job '%s'. Allow level are : CRITICAL, ERROR, WARNING, INFO or DEBUG" %level) + logging.warning("Unknown logging level in the job '%s'. " + "Allow level are : CRITICAL, ERROR, " + "WARNING, INFO or DEBUG" % level)