diff mbox

[Branch,~linaro-validation/lava-dispatcher/trunk] Rev 62: renamed lava-test got dropped in the rename it seems

Message ID 20110610145535.23875.38883.launchpad@loganberry.canonical.com
State Accepted
Headers show

Commit Message

Paul Larson June 10, 2011, 2:55 p.m. UTC
------------------------------------------------------------
revno: 62
committer: Paul Larson <paul.larson@canonical.com>
branch nick: lava-dispatcher
timestamp: Fri 2011-06-10 09:52:59 -0500
message:
  renamed lava-test got dropped in the rename it seems
added:
  lava/dispatcher/actions/lava-test.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
diff mbox

Patch

=== added file 'lava/dispatcher/actions/lava-test.py'
--- lava/dispatcher/actions/lava-test.py	1970-01-01 00:00:00 +0000
+++ lava/dispatcher/actions/lava-test.py	2011-06-10 14:52:59 +0000
@@ -0,0 +1,88 @@ 
+#!/usr/bin/python
+from lava.dispatcher.actions import BaseAction
+from lava.dispatcher.client import OperationFailed
+from lava.dispatcher.config import LAVA_RESULT_DIR, MASTER_STR, TESTER_STR
+
+class cmd_lava_test_run(BaseAction):
+    def run(self, test_name, timeout=-1):
+        #Make sure in test image now
+        client = self.client
+        client.in_test_shell()
+        client.run_shell_command('mkdir -p %s' % LAVA_RESULT_DIR,
+            response = TESTER_STR)
+        client.export_display()
+        client.run_shell_command(
+            'lava-test run %s -o %s/%s.bundle' % (
+                test_name, LAVA_RESULT_DIR, test_name),
+            response = TESTER_STR, timeout = timeout)
+
+class cmd_lava_test_install(BaseAction):
+    """
+    lava-test deployment to test image rootfs by chroot
+    """
+    def run(self, tests, timeout=2400):
+        client = self.client
+        #Make sure in master image
+        #, or exception can be caught and do boot_master_image()
+        try:
+            client.in_master_shell()
+        except:
+            client.boot_master_image()
+
+        #install bazaar in tester image
+        client.run_shell_command(
+            'mkdir -p /mnt/root',
+            response = MASTER_STR)
+        client.run_shell_command(
+            'mount /dev/disk/by-label/testrootfs /mnt/root',
+            response = MASTER_STR)
+        client.run_shell_command(
+            'cp -f /mnt/root/etc/resolv.conf /mnt/root/etc/resolv.conf.bak',
+            response = MASTER_STR)
+        client.run_shell_command(
+            'cp -L /etc/resolv.conf /mnt/root/etc',
+            response = MASTER_STR)
+        #eliminate warning: Can not write log, openpty() failed
+        #                   (/dev/pts not mounted?), does not work
+        client.run_shell_command(
+            'mount --rbind /dev /mnt/root/dev',
+            response = MASTER_STR)
+        client.run_shell_command(
+            'chroot /mnt/root apt-get update',
+            response = MASTER_STR)
+        #Install necessary packages for build lava-test
+        client.run_shell_command(
+            'chroot /mnt/root apt-get -y install bzr python-apt python-distutils-extra',
+            response = MASTER_STR, timeout=2400)
+        client.run_shell_command(
+            'chroot /mnt/root bzr branch lp:lava-test',
+            response = MASTER_STR)
+        client.run_shell_command(
+            'chroot /mnt/root sh -c "cd lava-test && python setup.py install"',
+            response = MASTER_STR)
+
+        #Test if lava-test installed
+        try:
+            client.run_shell_command(
+                'chroot /mnt/root lava-test help',
+                response = "list-tests")
+        except:
+            raise OperationFailed("lava-test deployment failed")
+
+        for test in tests:
+            client.run_shell_command(
+                'chroot /mnt/root lava-test install %s' % test,
+                response = MASTER_STR)
+        #clean up
+        client.run_shell_command(
+            'cp -f /mnt/root/etc/resolv.conf.bak /mnt/root/etc/resolv.conf',
+            response = MASTER_STR)
+        client.run_shell_command(
+            'rm -rf /mnt/root/lava-test',
+            response = MASTER_STR)
+        client.run_shell_command(
+            'cat /proc/mounts | awk \'{print $2}\' | grep "^/mnt/root/dev" | sort -r | xargs umount',
+            response = MASTER_STR)
+        client.run_shell_command(
+            'umount /mnt/root',
+            response = MASTER_STR)