From patchwork Thu Sep 1 15:55:12 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Spring Zhang X-Patchwork-Id: 3846 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 BBE9623F36 for ; Thu, 1 Sep 2011 15:55:17 +0000 (UTC) Received: from mail-ew0-f52.google.com (mail-ew0-f52.google.com [209.85.215.52]) by fiordland.canonical.com (Postfix) with ESMTP id ABBB7A1841C for ; Thu, 1 Sep 2011 15:55:17 +0000 (UTC) Received: by mail-ew0-f52.google.com with SMTP id 28so1586084ewy.11 for ; Thu, 01 Sep 2011 08:55:17 -0700 (PDT) Received: by 10.223.76.201 with SMTP id d9mr122659fak.119.1314892513946; Thu, 01 Sep 2011 08:55:13 -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.152.11.8 with SMTP id m8cs57031lab; Thu, 1 Sep 2011 08:55:13 -0700 (PDT) Received: by 10.227.201.83 with SMTP id ez19mr8439wbb.26.1314892513196; Thu, 01 Sep 2011 08:55:13 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com [91.189.90.7]) by mx.google.com with ESMTPS id fk15si447295wbb.137.2011.09.01.08.55.12 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 01 Sep 2011 08:55:13 -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 1Qz9bk-0007jd-Gq for ; Thu, 01 Sep 2011 15:55:12 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 72B74E0030 for ; Thu, 1 Sep 2011 15:55:12 +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: 97 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-validation/lava-dispatcher/trunk] Rev 97: add retry mechanism to make sure test result download successfully Message-Id: <20110901155512.902.93476.launchpad@ackee.canonical.com> Date: Thu, 01 Sep 2011 15:55:12 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="13830"; Instance="initZopeless config overlay" X-Launchpad-Hash: bc4ccb95811363b59123475845d510b589783860 Merge authors: Spring Zhang (qzhang) Related merge proposals: https://code.launchpad.net/~qzhang/lava-dispatcher/fix-387397-831784/+merge/73489 proposed by: Spring Zhang (qzhang) review: Approve - Spring Zhang (qzhang) ------------------------------------------------------------ revno: 97 [merge] committer: Spring Zhang branch nick: temp-merge timestamp: Thu 2011-09-01 23:52:58 +0800 message: add retry mechanism to make sure test result download successfully modified: lava_dispatcher/actions/launch_control.py lava_dispatcher/client.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/launch_control.py' --- lava_dispatcher/actions/launch_control.py 2011-08-29 13:57:19 +0000 +++ lava_dispatcher/actions/launch_control.py 2011-09-01 15:52:58 +0000 @@ -105,10 +105,18 @@ result_tarball = "http://%s/lava_results.tgz" % master_ip tarball_dir = mkdtemp(dir=LAVA_IMAGE_TMPDIR) os.chmod(tarball_dir, 0755) - #FIXME: need to consider exception? - result_path = download(result_tarball, tarball_dir) - id = client.proc.expect([MASTER_STR, pexpect.TIMEOUT, pexpect.EOF], - timeout=3) + + # download test result with a retry mechanism + # set retry timeout to 2mins + now = time.time() + timeout = 120 + while time.time() < now+timeout: + try: + result_path = download(result_tarball, tarball_dir) + except: + if time.time() >= now+timeout: + raise + client.run_shell_command('kill %1', response=MASTER_STR) tar = tarfile.open(result_path) === modified file 'lava_dispatcher/client.py' --- lava_dispatcher/client.py 2011-08-29 13:57:19 +0000 +++ lava_dispatcher/client.py 2011-08-31 07:49:52 +0000 @@ -131,17 +131,18 @@ self.wait_network_up() #tty device uses minimal match, see pexpect wiki #pattern1 = ".*\n(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})" - pattern1 = "(\d?\d?\d?\.\d?\d?\d?\.\d?\d?\d?\.\d?\d?\d?)" + pattern1 = "(\d+\d?\d?\.\d+\d?\d?\.\d+\d?\d?\.\d+\d?\d?)" cmd = ("ifconfig %s | grep 'inet addr' | awk -F: '{print $2}' |" "awk '{print $1}'" % self.board.default_network_interface) self.proc.sendline(cmd) - #if running from ipython, it needs another Enter, don't know why + #if running from ipython, it needs another Enter, don't know why: #self.proc.sendline("") id = self.proc.expect([pattern1, pexpect.EOF, pexpect.TIMEOUT], timeout=5) - print "\nid=%s" %id + print "\nmatching pattern is %s" % id if id == 0: ip = self.proc.match.groups()[0] + print "Master IP is %s" % ip return ip else: return None