diff mbox

[Branch,~linaro-validation/lava-dispatcher/trunk] Rev 124: merge to trunk:

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

Commit Message

Yongqin Liu Sept. 27, 2011, 10:16 a.m. UTC
Merge authors:
  Yongqin Liu (liuyq0307)
Related merge proposals:
  https://code.launchpad.net/~liuyq0307/lava-dispatcher/combine/+merge/76966
  proposed by: Yongqin Liu (liuyq0307)
  review: Approve - Spring Zhang (qzhang)
------------------------------------------------------------
revno: 124 [merge]
committer: Yongqin Liu <yongqin.liu@linaro.org>
branch nick: lava-dispatcher
timestamp: Tue 2011-09-27 18:12:50 +0800
message:
  merge to trunk: 
      add combine process for submit_results_on_host action
      make 0xbench execute first befor monkey in job file
      add busybox test to job file
modified:
  doc/lava-android-test-leb-panda.json
  lava_dispatcher/actions/launch_control.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 'doc/lava-android-test-leb-panda.json'
--- doc/lava-android-test-leb-panda.json	2011-09-20 06:14:43 +0000
+++ doc/lava-android-test-leb-panda.json	2011-09-27 10:12:50 +0000
@@ -25,7 +25,21 @@ 
       "command": "lava_android_test_install",
       "parameters":
         {
-            "tests": ["monkey", "0xbench"]
+            "tests": ["monkey", "0xbench", "busybox"]
+        }
+    },
+    {
+      "command": "lava_android_test_run",
+      "parameters":
+        {
+          "test_name": "busybox"
+        }
+    },
+    {
+      "command": "lava_android_test_run",
+      "parameters":
+        {
+          "test_name": "0xbench"
         }
     },
     {
@@ -36,13 +50,6 @@ 
         }
     },
     {
-      "command": "lava_android_test_run",
-      "parameters":
-        {
-          "test_name": "0xbench"
-        }
-    },
-    {
       "command": "submit_results_on_host",
       "parameters":
         {

=== modified file 'lava_dispatcher/actions/launch_control.py'
--- lava_dispatcher/actions/launch_control.py	2011-09-23 02:53:30 +0000
+++ lava_dispatcher/actions/launch_control.py	2011-09-26 11:37:32 +0000
@@ -33,42 +33,81 @@ 
 import xmlrpclib
 import traceback
 
-class cmd_submit_results_on_host(BaseAction):
+class SubmitResultAction(BaseAction):
+    all_bundles = []
+    def combine_bundles(self):
+        if not self.all_bundles:
+            return {
+                     "test_runs": [],
+                     "format": "Dashboard Bundle Format 1.2"
+                   }
+        main_bundle = self.all_bundles.pop(0)
+        test_runs = main_bundle['test_runs']
+        for bundle in self.all_bundles:
+            test_runs += bundle['test_runs']
+        return main_bundle
+
+    def submit_combine_bundles(self, status='pass', err_msg='', server=None, stream=None):
+        dashboard = _get_dashboard(server)
+        main_bundle = self.combine_bundles()
+        self.context.test_data.add_seriallog(
+            self.context.client.get_seriallog())
+        # 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', {})
+            attributes.update(self.context.test_data.get_metadata())
+            test_run['attributes'] = attributes
+        json_bundle = json.dumps(main_bundle)
+
+        try:
+            print >> self.context.oob_file, 'dashboard-put-result:', \
+                  dashboard.put_ex(json_bundle, 'lava-dispatcher.bundle', stream)
+        except xmlrpclib.Fault, err:
+            logging.warning("xmlrpclib.Fault occurred")
+            logging.warning("Fault code: %d" % err.faultCode)
+            logging.warning("Fault string: %s" % err.faultString)
+
+class cmd_submit_results_on_host(SubmitResultAction):
+
     def run(self, server, stream):
-        dashboard = _get_dashboard(server)
 
         #Upload bundle files to dashboard
         logging.info("Executing submit_results_on_host command")
-        bundle_list = os.listdir("/tmp/%s" % self.context.lava_result_dir)
-        for bundle_name in bundle_list:
-            bundle = "/tmp/%s/%s" % (self.context.lava_result_dir, bundle_name)
-            f = open(bundle)
-            content = f.read()
-            f.close()
-            job_name = self.context.job_data.get('job_name', "LAVA Results")
-            try:
-                print >> self.context.oob_file, 'dashboard-put-result:', \
-                      dashboard.put_ex(content, job_name, stream)
-            except xmlrpclib.Fault, err:
-                logging.warning("xmlrpclib.Fault occurred")
-                logging.warning("Fault code: %d" % err.faultCode)
-                logging.warning("Fault string: %s" % err.faultString)
-
-            # After uploading, remove the bundle file at the host side
+        bundlename_list = []
+        status = 'pass'
+        err_msg = ''
+        try:
+            bundle_list = os.listdir("/tmp/%s" % self.context.lava_result_dir)
+            for bundle_name in bundle_list:
+                bundle = "/tmp/%s/%s" % (self.context.lava_result_dir, bundle_name)
+                bundlename_list.append(bundle)
+                f = open(bundle)
+                content = f.read()
+                f.close()
+                self.all_bundles.append(json.loads(content))
+        except:
+            print traceback.format_exc()
+            status = 'fail'
+            err_msg = err_msg + " Some test case result appending failed."
+
+
+        self.submit_combine_bundles(status, err_msg, server, stream)
+
+        if status == 'fail':
+            raise OperationFailed(err_msg)
+
+        for bundle in bundlename_list:
             os.remove(bundle)
 
-
-class cmd_submit_results(BaseAction):
-    all_bundles = []
+class cmd_submit_results(SubmitResultAction):
 
     def run(self, server, stream, result_disk="testrootfs"):
         """Submit test results to a lava-dashboard server
         :param server: URL of the lava-dashboard server RPC endpoint
         :param stream: Stream on the lava-dashboard server to save the result to
         """
-        #Create l-d server connection
-        dashboard = _get_dashboard(server)
-
         client = self.client
         try:
             self.in_master_shell()
@@ -110,11 +149,11 @@ 
             now = time.time()
             timeout = 120
             try:
-                while time.time() < now+timeout:
+                while time.time() < now + timeout:
                     try:
                         result_path = download(result_tarball, tarball_dir)
                     except:
-                        if time.time() >= now+timeout:
+                        if time.time() >= now + timeout:
                             raise
             except:
                 logging.warning(traceback.format_exc())
@@ -148,37 +187,10 @@ 
 
         #flush the serial log
         client.run_shell_command("")
-
-        main_bundle = self.combine_bundles()
-        self.context.test_data.add_seriallog(
-            self.context.client.get_seriallog())
-        # 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',{})
-            attributes.update(self.context.test_data.get_metadata())
-            test_run['attributes'] = attributes
-        json_bundle = json.dumps(main_bundle)
-        job_name = self.context.job_data.get('job_name', "LAVA Results")
-        print >> self.context.oob_file, 'dashboard-put-result:', \
-              dashboard.put_ex(json_bundle, job_name, stream)
-
+        self.submit_combine_bundles(status, err_msg, server, stream)
         if status == 'fail':
             raise OperationFailed(err_msg)
 
-    def combine_bundles(self):
-        if not self.all_bundles:
-            return {
-                     "test_runs": [],
-                     "format": "Dashboard Bundle Format 1.2"
-                   }
-        main_bundle = self.all_bundles.pop(0)
-        test_runs = main_bundle['test_runs']
-        for bundle in self.all_bundles:
-            test_runs += bundle['test_runs']
-        return main_bundle
-
 #util function, see if it needs to be part of utils.py
 def _get_dashboard(server):
     if not server.endswith("/"):