From patchwork Mon Feb 20 20:06:10 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael-Doyle Hudson X-Patchwork-Id: 6837 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 2CEE323E48 for ; Mon, 20 Feb 2012 20:06:16 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id C90DAA184D4 for ; Mon, 20 Feb 2012 20:06:15 +0000 (UTC) Received: by iabz7 with SMTP id z7so11111000iab.11 for ; Mon, 20 Feb 2012 12:06:14 -0800 (PST) Received: from mr.google.com ([10.50.155.231]) by 10.50.155.231 with SMTP id vz7mr15110627igb.26.1329768374959 (num_hops = 1); Mon, 20 Feb 2012 12:06:14 -0800 (PST) Received: by 10.50.155.231 with SMTP id vz7mr12221191igb.26.1329768372976; Mon, 20 Feb 2012 12:06:12 -0800 (PST) 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.11.10 with SMTP id r10csp57108ibr; Mon, 20 Feb 2012 12:06:12 -0800 (PST) Received: by 10.180.95.1 with SMTP id dg1mr16503862wib.21.1329768371485; Mon, 20 Feb 2012 12:06:11 -0800 (PST) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id x6si6319706wif.40.2012.02.20.12.06.11 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 20 Feb 2012 12:06:11 -0800 (PST) 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 1RzZUw-0004t9-Tx for ; Mon, 20 Feb 2012 20:06:10 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id D6BE4E1438 for ; Mon, 20 Feb 2012 20:06:10 +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: 233 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-validation/lava-dispatcher/trunk] Rev 233: change the default behaviour of CommandRunner.run() to raise Message-Id: <20120220200610.13705.20411.launchpad@ackee.canonical.com> Date: Mon, 20 Feb 2012 20:06:10 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="14833"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: f0d7120a986147ed695aad8402fc5af11b55c90b X-Gm-Message-State: ALoCoQmJ8ThcTzZ8fHzNzYjGFZC1ks2vUTATiQGVr+BHc2X/LzciuGDg/pkPwzoGEYZbyW1Td+5W Merge authors: Michael Hudson-Doyle (mwhudson) Related merge proposals: https://code.launchpad.net/~mwhudson/lava-dispatcher/fail-should-fail/+merge/93755 proposed by: Michael Hudson-Doyle (mwhudson) review: Approve - Zygmunt Krynicki (zkrynicki) ------------------------------------------------------------ revno: 233 [merge] committer: Michael Hudson-Doyle branch nick: trunk timestamp: Tue 2012-02-21 09:04:16 +1300 message: change the default behaviour of CommandRunner.run() to raise and exception if the shell command it runs fails. modified: lava_dispatcher/client/base.py lava_dispatcher/client/master.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/client/base.py' --- lava_dispatcher/client/base.py 2012-02-07 20:30:14 +0000 +++ lava_dispatcher/client/base.py 2012-02-20 00:41:31 +0000 @@ -61,7 +61,7 @@ index = self._connection.expect( ['.+', pexpect.EOF, pexpect.TIMEOUT], timeout=1, lava_no_logging=1) - def run(self, cmd, response=None, timeout=-1): + def run(self, cmd, response=None, timeout=-1, failok=False): """Run `cmd` and wait for a shell response. :param cmd: The command to execute. @@ -96,6 +96,9 @@ ['rc=(\d+\d?\d?)', pexpect.EOF, pexpect.TIMEOUT], timeout=2, lava_no_logging=1) if match_id == 0: rc = int(self._connection.match.groups()[0]) + if rc != 0 and not failok: + raise OperationFailed( + "executing %r failed with code %s" % (cmd, rc)) else: rc = None else: @@ -117,7 +120,8 @@ lava_server_ip = self._client.context.lava_server_ip self.run( "LC_ALL=C ping -W4 -c1 %s" % lava_server_ip, - ["1 received", "0 received", "Network is unreachable"], timeout=5) + ["1 received", "0 received", "Network is unreachable"], + timeout=5, failok=True) if self.match_id == 0: return True else: @@ -143,7 +147,7 @@ self, client.proc, client.tester_str, wait_for_rc) def export_display(self): - self.run("su - linaro -c 'DISPLAY=:0 xhost local:'") + self.run("su - linaro -c 'DISPLAY=:0 xhost local:'", failok=True) self.run("export DISPLAY=:0") === modified file 'lava_dispatcher/client/master.py' --- lava_dispatcher/client/master.py 2012-02-08 16:42:05 +0000 +++ lava_dispatcher/client/master.py 2012-02-20 00:42:52 +0000 @@ -69,14 +69,10 @@ decompression_char = 'z' elif tarball_url.endswith('.bz2'): decompression_char = 'j' - rc = session.run( + session.run( 'wget -qO- %s |tar --numeric-owner -C %s -x%sf -' % ( tarball_url, dest, decompression_char), timeout=timeout) - if rc != 0: - msg = "Deploy: failed to deploy to %s" % dest - raise OperationFailed(msg) - def _deploy_linaro_rootfs(session, rootfs): logging.info("Deploying linaro image") @@ -153,6 +149,7 @@ % (data_part_org, data_part_lava)) session.run('sed -i "s/mmcblk1p%s/mmcblk1p%s/g" init.rc' % (sys_part_org, sys_part_lava)) + # failok true for this?: session.run( 'sed -i "/export PATH/a \ \ \ \ export PS1 root@linaro: " init.rc') @@ -174,7 +171,7 @@ logging.info("Deploying the test root filesystem") # sdcard_part_lava = session._client.device_option("sdcard_part_android") - session.run('umount /dev/disk/by-label/testrootfs') + session.run('umount /dev/disk/by-label/testrootfs', failok=True) session.run( 'mkfs -t %s -q /dev/disk/by-label/testrootfs -L testrootfs' % rootfstype) session.run('udevadm trigger') @@ -187,7 +184,9 @@ # "/devices/platform/omap/omap_hsmmc.0/mmc_host/mmc0" % sdcard_part_lava # session.run( # 'sed -i "%s" /mnt/lava/system/etc/vold.fstab' % sed_cmd) - session.run('sed -i "s/^PS1=.*$/PS1=\'root@linaro: \'/" /mnt/lava/system/etc/mkshrc') + session.run( + 'sed -i "s/^PS1=.*$/PS1=\'root@linaro: \'/" /mnt/lava/system/etc/mkshrc', + failok=True) session.run('umount /mnt/lava/system') def _purge_linaro_android_sdcard(session): @@ -218,8 +217,9 @@ prefix += ' ' self._prefix = prefix - def run(self, cmd, response=None, timeout=-1): - return super(PrefixCommandRunner, self).run(self._prefix + cmd, response, timeout) + def run(self, cmd, response=None, timeout=-1, failok=False): + return super(PrefixCommandRunner, self).run( + self._prefix + cmd, response, timeout, failok) class MasterCommandRunner(NetworkCommandRunner): @@ -440,11 +440,11 @@ def _format_testpartition(self, session, fstype): logging.info("Format testboot and testrootfs partitions") - session.run('umount /dev/disk/by-label/testrootfs') + session.run('umount /dev/disk/by-label/testrootfs', failok=True) session.run( 'mkfs -t %s -q /dev/disk/by-label/testrootfs -L testrootfs' % fstype) - session.run('umount /dev/disk/by-label/testboot') + session.run('umount /dev/disk/by-label/testboot', failok=True) session.run('mkfs.vfat /dev/disk/by-label/testboot -n testboot') def _generate_tarballs(self, image_file):