From patchwork Sat Sep 10 03:12:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Spring Zhang X-Patchwork-Id: 4011 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 E858823EFD for ; Sat, 10 Sep 2011 03:12:15 +0000 (UTC) Received: from mail-fx0-f52.google.com (mail-fx0-f52.google.com [209.85.161.52]) by fiordland.canonical.com (Postfix) with ESMTP id C814BA18807 for ; Sat, 10 Sep 2011 03:12:15 +0000 (UTC) Received: by fxd18 with SMTP id 18so4541472fxd.11 for ; Fri, 09 Sep 2011 20:12:15 -0700 (PDT) Received: by 10.223.102.11 with SMTP id e11mr504741fao.8.1315624335580; Fri, 09 Sep 2011 20:12: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.152.11.8 with SMTP id m8cs32881lab; Fri, 9 Sep 2011 20:12:15 -0700 (PDT) Received: by 10.227.11.3 with SMTP id r3mr690701wbr.43.1315624334571; Fri, 09 Sep 2011 20:12:14 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com [91.189.90.7]) by mx.google.com with ESMTPS id fd19si7949665wbb.32.2011.09.09.20.12.13 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 09 Sep 2011 20:12: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 1R2DzJ-0000lu-I6 for ; Sat, 10 Sep 2011 03:12:13 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 7F380E1571 for ; Sat, 10 Sep 2011 03:12: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: 106 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-validation/lava-dispatcher/trunk] Rev 106: merge enhancement on gather_results Message-Id: <20110910031213.28527.2680.launchpad@ackee.canonical.com> Date: Sat, 10 Sep 2011 03:12: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="13900"; Instance="initZopeless config overlay" X-Launchpad-Hash: 90f14f3c177c2e823f3df49e102c7ca0a7fa5b6f Merge authors: Spring Zhang (qzhang) Related merge proposals: https://code.launchpad.net/~qzhang/lava-dispatcher/fix-833246-2/+merge/74481 proposed by: Spring Zhang (qzhang) review: Approve - Spring Zhang (qzhang) review: Approve - Paul Larson (pwlars) ------------------------------------------------------------ revno: 106 [merge] committer: Spring Zhang branch nick: fix-833246-2 timestamp: Sat 2011-09-10 11:09:51 +0800 message: merge enhancement on gather_results 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-09-08 04:28:39 +0000 +++ lava_dispatcher/actions/launch_control.py 2011-09-10 03:02:04 +0000 @@ -25,11 +25,12 @@ import shutil import tarfile from lava_dispatcher.actions import BaseAction -from lava_dispatcher.client import NetworkError +from lava_dispatcher.client import OperationFailed from lava_dispatcher.utils import download from tempfile import mkdtemp import time import xmlrpclib +import traceback class cmd_submit_results_on_host(BaseAction): def run(self, server, stream): @@ -89,39 +90,56 @@ client.run_cmd_master( 'tar czf /tmp/lava_results.tgz -C /tmp/%s .' % self.context.lava_result_dir) + # start gather_result job, status + status = 'pass' + err_msg = '' master_ip = client.get_master_ip() - if master_ip == None: - raise NetworkError("Getting master image IP address failed") - # Set 80 as server port - client.run_cmd_master('python -m SimpleHTTPServer 80 &> /dev/null &') - time.sleep(3) - - result_tarball = "http://%s/lava_results.tgz" % master_ip - tarball_dir = mkdtemp(dir=self.context.lava_image_tmpdir) - os.chmod(tarball_dir, 0755) - - # 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_cmd_master('kill %1') - - tar = tarfile.open(result_path) - for tarinfo in tar: - if os.path.splitext(tarinfo.name)[1] == ".bundle": - f = tar.extractfile(tarinfo) - content = f.read() - f.close() - self.all_bundles.append(json.loads(content)) - tar.close() - shutil.rmtree(tarball_dir) + if master_ip != None: + # Set 80 as server port + client.run_cmd_master('python -m SimpleHTTPServer 80 &> /dev/null &') + time.sleep(3) + + result_tarball = "http://%s/lava_results.tgz" % master_ip + tarball_dir = mkdtemp(dir=self.context.lava_image_tmpdir) + os.chmod(tarball_dir, 0755) + + # download test result with a retry mechanism + # set retry timeout to 2mins + now = time.time() + timeout = 120 + try: + while time.time() < now+timeout: + try: + result_path = download(result_tarball, tarball_dir) + except: + if time.time() >= now+timeout: + raise + except: + print traceback.format_exc() + status = 'fail' + err_msg = err_msg + " Can't retrieve test case results." + + client.run_cmd_master('kill %1') + + try: + tar = tarfile.open(result_path) + for tarinfo in tar: + if os.path.splitext(tarinfo.name)[1] == ".bundle": + f = tar.extractfile(tarinfo) + content = f.read() + f.close() + self.all_bundles.append(json.loads(content)) + tar.close() + except: + print traceback.format_exc() + status = 'fail' + err_msg = err_msg + " Some test case result appending failed." + finally: + shutil.rmtree(tarball_dir) + else: + status = 'fail' + err_msg = err_msg + "Getting master image IP address failed, \ +no test case result retrived." #flush the serial log client.run_shell_command("") @@ -129,12 +147,8 @@ main_bundle = self.combine_bundles() self.context.test_data.add_seriallog( self.context.client.get_seriallog()) - # add submit_results failure info if no available network to get test - # case result - if master_ip == None: - err_msg = "Getting master image IP address failed, \ -no test case result retrived." - self.context.test_data.add_result('submit_results', 'fail', err_msg) + # add gather_results result + self.context.test_data.add_result('gather_results', status, err_msg) main_bundle['test_runs'].append(self.context.test_data.get_test_run()) for test_run in main_bundle['test_runs']: attributes = test_run.get('attributes',{}) @@ -144,8 +158,8 @@ print >> self.context.oob_file, 'dashboard-put-result:', \ srv.put_ex(json_bundle, 'lava-dispatcher.bundle', stream) - if master_ip == None: - raise NetworkError(err_msg) + if status == 'fail': + raise OperationFailed(err_msg) def combine_bundles(self): if not self.all_bundles: === modified file 'lava_dispatcher/client.py' --- lava_dispatcher/client.py 2011-09-08 23:35:05 +0000 +++ lava_dispatcher/client.py 2011-09-10 03:02:04 +0000 @@ -22,6 +22,7 @@ import sys import time from cStringIO import StringIO +import traceback from utils import string_to_list class LavaClient(object): @@ -171,7 +172,11 @@ def get_master_ip(self): #get master image ip address - self.wait_network_up() + try: + self.wait_network_up() + except: + print traceback.format_exc() + return None #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?)"