From patchwork Tue Apr 2 10:38:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yongqin Liu X-Patchwork-Id: 15811 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 6CAEE23DEE for ; Tue, 2 Apr 2013 10:38:16 +0000 (UTC) Received: from mail-vc0-f177.google.com (mail-vc0-f177.google.com [209.85.220.177]) by fiordland.canonical.com (Postfix) with ESMTP id D5B6FA18731 for ; Tue, 2 Apr 2013 10:38:15 +0000 (UTC) Received: by mail-vc0-f177.google.com with SMTP id ia10so243594vcb.22 for ; Tue, 02 Apr 2013 03:38:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :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=ziG/vGpmFEHVzDU3UGXviJF3BVzhAUunt8mPXya/yiI=; b=Y1FxR++ni832wiqMLyi6Sm8clZjfAaJ0G9ksZDNlw1YBbe+UoqXeOc91Qfyuc98ofV bGfNCi65hEZBzgY4HQ8GP3ztQ4XvjhatucaSZNo++W/epmCoh+ZdbLkAeefHmxEJPhH9 PZkFB6FrNd0ReQFWGtAbAhBa0Qg7bA0VWAgvEdL8kQUuMZW/99ZyLD6ObIb/tqgAZrzl e8FKqNqx5W7vqc8ecg9rlk3xsDHd7JI4jfHlPESzgg2pZ9YlNe8vJTKI3wn4CAv7o0a7 6aVIA647zd64uMud3BSi5bsHhYqog4MElmnapMN+wvjpxvTx5e1rTaYArbpm1Cj/IZ2s VLkw== X-Received: by 10.58.210.200 with SMTP id mw8mr12123826vec.32.1364899095383; Tue, 02 Apr 2013 03:38:15 -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.59.4.204 with SMTP id cg12csp119304ved; Tue, 2 Apr 2013 03:38:14 -0700 (PDT) X-Received: by 10.180.77.66 with SMTP id q2mr14711564wiw.13.1364899094242; Tue, 02 Apr 2013 03:38:14 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id mc9si352338wjb.5.2013.04.02.03.38.13 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 02 Apr 2013 03:38: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 1UMybV-0001kd-NT for ; Tue, 02 Apr 2013 10:38:13 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id A0044E027E for ; Tue, 2 Apr 2013 10:38:13 +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: 573 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-validation/lava-dispatcher/trunk] Rev 573: merge with the branch that try a reboot when the adb connection can not be created after boot Message-Id: <20130402103813.12857.45915.launchpad@ackee.canonical.com> Date: Tue, 02 Apr 2013 10:38:13 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="16546"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 3350ceb53c8140f655c531071a6cf324fb7b0e12 X-Gm-Message-State: ALoCoQm71ioG9r/+jNyZ8y5jMrzZIvyIecCEJwYDP6BAfGLOb8tr1GExfnIU8BcQDqHVOZg7q7am Merge authors: Yongqin Liu (liuyq0307) Related merge proposals: https://code.launchpad.net/~liuyq0307/lava-dispatcher/check-adb-at-boot/+merge/155881 proposed by: Yongqin Liu (liuyq0307) ------------------------------------------------------------ revno: 573 [merge] committer: Yongqin Liu branch nick: lava-dispatcher timestamp: Tue 2013-04-02 18:36:49 +0800 message: merge with the branch that try a reboot when the adb connection can not be created after boot modified: lava_dispatcher/actions/boot_control.py lava_dispatcher/client/base.py lava_dispatcher/errors.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/boot_control.py' --- lava_dispatcher/actions/boot_control.py 2012-11-20 21:22:17 +0000 +++ lava_dispatcher/actions/boot_control.py 2013-03-27 11:22:07 +0000 @@ -23,7 +23,10 @@ import logging from lava_dispatcher.actions import BaseAction, null_or_empty_schema -from lava_dispatcher.errors import CriticalError +from lava_dispatcher.errors import ( + CriticalError, + ADBConnectError, +) _boot_schema = { 'type': 'object', @@ -40,12 +43,20 @@ """ parameters_schema = _boot_schema + parameters_schema['properties']['adb_check'] = { + 'default': False, 'optional': True + } - def run(self, options=[]): + def run(self, options=[], adb_check=False): client = self.client client.target_device.boot_options = options try: - client.boot_linaro_android_image() + client.boot_linaro_android_image( + adb_check=adb_check) + except ADBConnectError as err: + logging.exception(('boot_linaro_android_image failed to create' + ' the adb connection: %s') % err) + raise err except Exception as e: logging.exception("boot_linaro_android_image failed: %s" % e) raise CriticalError("Failed to boot test image.") === modified file 'lava_dispatcher/client/base.py' --- lava_dispatcher/client/base.py 2013-02-18 06:00:28 +0000 +++ lava_dispatcher/client/base.py 2013-03-27 11:22:07 +0000 @@ -34,6 +34,7 @@ NetworkError, OperationFailed, CriticalError, + ADBConnectError, ) @@ -246,6 +247,9 @@ match_id = adb_proc.expect([pattern1, pattern2, pattern3, pexpect.EOF]) if match_id in [0, 1]: self.dev_name = adb_proc.match.groups()[0] + else: + raise ADBConnectError(('Failed to connected to device with' + ' command:%s') % cmd) def android_adb_over_tcp_disconnect(self): dev_ip = self.dev_ip @@ -289,7 +293,7 @@ return time.sleep(3) - raise NetworkError( + raise ADBConnectError( "The android device(%s) isn't attached" % self._client.hostname) def wait_home_screen(self): @@ -441,7 +445,7 @@ def get_android_adb_interface(self): return self.config.default_network_interface - def boot_linaro_android_image(self): + def boot_linaro_android_image(self, adb_check=False): """Reboot the system to the test android image.""" self._boot_linaro_android_image() TESTER_PS1_PATTERN = self.target_device.deployment_data['TESTER_PS1_PATTERN'] @@ -465,6 +469,14 @@ if self.config.android_adb_over_tcp: self._enable_adb_over_tcp() + #check if the adb connection can be created. + #by adb connect dev_ip command + if adb_check: + try: + session = AndroidTesterCommandRunner(self) + session.connect() + finally: + session.disconnect() def _disable_suspend(self): """ disable the suspend of images. === modified file 'lava_dispatcher/errors.py' --- lava_dispatcher/errors.py 2012-11-20 21:22:17 +0000 +++ lava_dispatcher/errors.py 2013-03-27 03:50:25 +0000 @@ -51,6 +51,12 @@ """ +class ADBConnectError(NetworkError): + """ + This is used when adb connection failed to created + """ + + class OperationFailed(GeneralError): """ The exception throws when a file system or system operation fails. === modified file 'lava_dispatcher/job.py' --- lava_dispatcher/job.py 2013-01-23 22:37:53 +0000 +++ lava_dispatcher/job.py 2013-03-27 13:49:44 +0000 @@ -33,6 +33,7 @@ CriticalError, TimeoutError, GeneralError, + ADBConnectError, ) @@ -175,6 +176,24 @@ try: status = 'fail' action.run(**params) + except ADBConnectError: + if cmd.get('command') == 'boot_linaro_android_image': + logging.warning(('[ACTION-E] %s failed to create the' + ' adb connection') % (cmd['command'])) + ## 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 will reboot the image to try again') + self.context.client.proc.sendcontrol("c") + self.context.client.proc.sendline("") + time.sleep(5) + self.context.client.boot_linaro_android_image( + adb_check=True) + ## mark it as pass if the second boot works + status = 'pass' except TimeoutError as err: if cmd.get('command').startswith('lava_android_test'): logging.warning("[ACTION-E] %s times out." % (