[Branch,~linaro-validation/lava-dispatcher/trunk] Rev 89: Merge out-of-tree support changes from ChiThu

Message ID 20110819013514.14550.75544.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Paul Larson Aug. 19, 2011, 1:35 a.m.
Merge authors:
  Le Chi Thu le.chi.thu@linaro.org <le.chi.thu@linaro.org>
Related merge proposals:
  https://code.launchpad.net/~le-chi-thu/lava-dispatcher/out-of-tree-tests/+merge/72034
  proposed by: Le Chi Thu (le-chi-thu)
------------------------------------------------------------
revno: 89 [merge]
committer: Paul Larson <paul.larson@linaro.org>
branch nick: lava-dispatcher
timestamp: Thu 2011-08-18 21:38:38 +0100
message:
  Merge out-of-tree support changes from ChiThu
added:
  doc/lava-out-of-tree-test-1.json
  doc/lava-out-of-tree-test-2.json
modified:
  lava_dispatcher/actions/lava-test.py
  lava_dispatcher/utils.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

Patch

=== added file 'doc/lava-out-of-tree-test-1.json'
--- doc/lava-out-of-tree-test-1.json	1970-01-01 00:00:00 +0000
+++ doc/lava-out-of-tree-test-1.json	2011-08-18 20:38:38 +0000
@@ -0,0 +1,48 @@ 
+{
+  "job_name": "foo",
+  "target": "panda01",
+  "timeout": 18000,
+  "actions": [
+    {
+      "command": "deploy_linaro_image",
+      "parameters":
+        {
+          "rootfs": "http://snapshots.linaro.org/11.05-daily/linaro-ubuntu-desktop/20110814/0/images/tar/linaro-n-ubuntu-desktop-tar-20110814-0.tar.gz",
+          "hwpack": "http://snapshots.linaro.org/11.05-daily/linaro-hwpacks/panda/20110814/0/images/hwpack/hwpack_linaro-panda_20110814-0_armel_supported.tar.gz"
+        }
+    },
+    {
+      "command": "add_apt_repository",
+      "parameters":
+        {
+            "arg": ["ppa:linaro-graphics-wg/ppa"]
+        }
+    },
+    {
+      "command": "lava_test_install",
+      "parameters":
+        {
+            "tests": ["glcompbench"],
+            "install_python": ["bzr+http//:bazaar.launchpad.net/~linaro-graphics-wg/+junk/linaro-graphics-wg-tests/#egg=linaro-graphics-wg-tests"]
+        }
+    },
+    {
+      "command": "boot_linaro_image"
+    },
+    {
+      "command": "lava_test_run",
+      "parameters":
+        {
+          "test_name": "glcompbench"
+        }
+    },
+    {
+      "command": "submit_results",
+      "parameters":
+        {
+          "server": "http://validation.linaro.org/launch-control",
+          "stream": "/anonymous/panda01-tesing/"
+        }
+    }
+  ]
+}

=== added file 'doc/lava-out-of-tree-test-2.json'
--- doc/lava-out-of-tree-test-2.json	1970-01-01 00:00:00 +0000
+++ doc/lava-out-of-tree-test-2.json	2011-08-18 20:38:38 +0000
@@ -0,0 +1,41 @@ 
+{
+  "job_name": "foo",
+  "target": "panda01",
+  "timeout": 18000,
+  "actions": [
+    {
+      "command": "deploy_linaro_image",
+      "parameters":
+        {
+          "rootfs": "http://snapshots.linaro.org/11.05-daily/linaro-ubuntu-desktop/20110814/0/images/tar/linaro-n-ubuntu-desktop-tar-20110814-0.tar.gz",
+          "hwpack": "http://snapshots.linaro.org/11.05-daily/linaro-hwpacks/panda/20110814/0/images/hwpack/hwpack_linaro-panda_20110814-0_armel_supported.tar.gz"
+        }
+    },
+    {
+      "command": "lava_test_install",
+      "parameters":
+        {
+            "tests": ["linaro.pmwg"],
+            "register": ["http://bazaar.launchpad.net/~linaro-validation/lava-test/trunk/download/head:/powermanagementtests-20110628125042-dnw8hkhbce7pqi0y-2/power-management-tests.json"]
+        }
+    },
+    {
+      "command": "boot_linaro_image"
+    },
+    {
+      "command": "lava_test_run",
+      "parameters":
+        {
+          "test_name": "linaro.pmwg"
+        }
+    },
+    {
+      "command": "submit_results",
+      "parameters":
+        {
+          "server": "http://validation.linaro.org/launch-control",
+          "stream": "/anonymous/panda01-testing/"
+        }
+    }
+  ]
+}

=== modified file 'lava_dispatcher/actions/lava-test.py'
--- lava_dispatcher/actions/lava-test.py	2011-08-04 07:19:53 +0000
+++ lava_dispatcher/actions/lava-test.py	2011-08-18 20:38:38 +0000
@@ -27,6 +27,73 @@ 
 from lava_dispatcher.client import OperationFailed
 from lava_dispatcher.config import LAVA_RESULT_DIR, MASTER_STR, TESTER_STR
 
+def _setup_testrootfs(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()
+
+    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)
+
+def _teardown_testrootfs(client):
+    client.run_shell_command(
+        'cp -f /mnt/root/etc/resolv.conf.bak /mnt/root/etc/resolv.conf',
+        response=MASTER_STR)
+    cmd = ('cat /proc/mounts | awk \'{print $2}\' | grep "^/mnt/root/dev"'
+        '| sort -r | xargs umount')
+    client.run_shell_command(
+        cmd,
+        response=MASTER_STR)
+    client.run_shell_command(
+        'umount /mnt/root',
+        response=MASTER_STR)
+
+def _install_lava_test(client):
+    #install bazaar in tester image
+    client.run_shell_command(
+        'chroot /mnt/root apt-get update',
+        response=MASTER_STR)
+    #Install necessary packages for build lava-test
+    cmd = ('chroot /mnt/root apt-get -y install bzr usbutils python-apt '
+        'python-setuptools python-simplejson lsb-release')
+    client.run_shell_command(
+        cmd,
+        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-test", timeout=10)
+    except:
+        tb = traceback.format_exc()
+        client.sio.write(tb)
+        _teardown_testrootfs(client)
+        raise OperationFailed("lava-test deployment failed")
 
 class cmd_lava_test_run(BaseAction):
     def run(self, test_name, timeout=-1):
@@ -47,75 +114,46 @@ 
     """
     lava-test deployment to test image rootfs by chroot
     """
-    def run(self, tests, timeout=2400):
+    def run(self, tests, install_python = None, register = None, 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
-        cmd = ('chroot /mnt/root apt-get -y install bzr usbutils python-apt '
-            'python-setuptools python-simplejson lsb-release')
-        client.run_shell_command(
-            cmd,
-            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", timeout=10)
-        except:
-            tb = traceback.format_exc()
-            client.sio.write(tb)
-            raise OperationFailed("lava-test deployment failed")
+
+        _setup_testrootfs(client)
+        _install_lava_test(client)
+
+        if install_python:
+            for module in install_python:
+                client.run_shell_command("chroot /mnt/root apt-get -y install python-pip", response=MASTER_STR)
+                client.run_shell_command("chroot /mnt/root pip -e " + module, response=MASTER_STR)
+
+        if register:
+            for test_def_url in register:
+                client.run_shell_command('chroot /mnt/root lava-test register-test  ' + test_def_url, response=MASTER_STR)
 
         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)
-        cmd = ('cat /proc/mounts | awk \'{print $2}\' | grep "^/mnt/root/dev"'
-            '| sort -r | xargs umount')
-        client.run_shell_command(
-            cmd,
-            response=MASTER_STR)
-        client.run_shell_command(
-            'umount /mnt/root',
-            response=MASTER_STR)
+
+        client.run_shell_command('rm -rf /mnt/root/lava-test', response=MASTER_STR)
+
+        _teardown_testrootfs(client)
+
+class cmd_add_apt_repository(BaseAction):
+    """
+    add apt repository to test image rootfs by chroot
+    arg could be 'deb uri distribution [component1] [component2][...]' or ppm:<ppa_name>
+    """
+    def run(self, arg):
+        client = self.client
+        _setup_testrootfs(client)
+        
+        #install add-apt-repository
+        client.run_shell_command('chroot /mnt/root apt-get -y install python-software-properties',response=MASTER_STR)
+
+        #add ppa
+        client.run_shell_command('chroot /mnt/root add-apt-repository ' + arg[0], response=MASTER_STR)
+        client.run_shell_command('chroot /mnt/root apt-get update', response=MASTER_STR)
+
+        _teardown_testrootfs(client)
+
+

=== modified file 'lava_dispatcher/utils.py'
--- lava_dispatcher/utils.py	2011-08-15 10:44:10 +0000
+++ lava_dispatcher/utils.py	2011-08-18 20:38:38 +0000
@@ -32,7 +32,7 @@ 
         filename = os.path.join(path,filename)
     fd = open(filename, "w")
     try:
-        response = urllib2.urlopen(urllib2.quote(url, safe=":/"), timeout=5)
+        response = urllib2.urlopen(urllib2.quote(url, safe=":/"), timeout=30)
         fd = open(filename, 'wb')
         shutil.copyfileobj(response,fd,0x10000)
         fd.close()