diff mbox

[Branch,~linaro-validation/lava-dispatcher/trunk] Rev 286: runs all the commands run by the lava_test_install action with a helper that catches errors and r...

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

Commit Message

Michael-Doyle Hudson May 10, 2012, 9:29 p.m. UTC
Merge authors:
  Michael Hudson-Doyle (mwhudson)
Related merge proposals:
  https://code.launchpad.net/~mwhudson/lava-dispatcher/lava-test-install-resilience/+merge/105278
  proposed by: Michael Hudson-Doyle (mwhudson)
  review: Approve - Le Chi Thu (le-chi-thu)
------------------------------------------------------------
revno: 286 [merge]
committer: Michael Hudson-Doyle <michael.hudson@linaro.org>
branch nick: trunk
timestamp: Fri 2012-05-11 09:27:49 +1200
message:
  runs all the commands run by the lava_test_install action with a helper that catches errors and reports results into the lava testrun
modified:
  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

=== modified file 'lava_dispatcher/actions/lava-test.py'
--- lava_dispatcher/actions/lava-test.py	2012-05-07 05:27:30 +0000
+++ lava_dispatcher/actions/lava-test.py	2012-05-09 22:24:31 +0000
@@ -20,11 +20,10 @@ 
 # along
 # with this program; if not, see <http://www.gnu.org/licenses>.
 
-from datetime import datetime
 import logging
 
 from lava_dispatcher.actions import BaseAction
-from lava_dispatcher.client.base import OperationFailed, CriticalError
+from lava_dispatcher.client.base import OperationFailed
 from lava_dispatcher.utils import generate_bundle_file_name
 
 
@@ -116,6 +115,15 @@ 
         'additionalProperties': False,
         }
 
+    def run_command_with_test_result(self, session, command, test_result_name, timeout):
+        try:
+            session.run(command, timeout=timeout)
+        except OperationFailed as e:
+            logging.error("running %r failed" % command)
+            self.context.test_data.add_result(test_result_name, 'fail', str(e))
+        else:
+            self.context.test_data.add_result(test_result_name, 'pass')
+
     def run(self, tests, install_python=None, register=None, timeout=2400):
         logging.info(
             "Executing lava_test_install (%s) command" % ",".join(tests))
@@ -133,15 +141,20 @@ 
 
             if install_python:
                 for module in install_python:
-                    session.run("pip install -e " + module)
+                    self.run_command_with_test_result(
+                        session, "pip install -e " + module,
+                        'lava_test_install python (%s)' % module, timeout=60)
 
             if register:
                 for test_def_url in register:
-                    session.run('lava-test register-test  ' + test_def_url,
-                        timeout=60)
+                    self.run_command_with_test_result(
+                        session, 'lava-test register-test  ' + test_def_url,
+                        'lava_test_install register (%s)' % test_def_url, timeout=60)
 
             for test in tests:
-                session.run('lava-test install %s' % test, timeout=timeout)
+                self.run_command_with_test_result(
+                    session, 'lava-test install %s' % test,
+                    'lava_test_install (%s)' % test, timeout=timeout)
 
             session.run('rm -rf lava-test', timeout=60)