diff mbox

[Branch,~linaro-validation/lava-dispatcher/trunk] Rev 129: create random result directory on Android test to fix bug 861115

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

Commit Message

Spring Zhang Oct. 10, 2011, 4:17 p.m. UTC
Merge authors:
  Spring Zhang (qzhang)
Related merge proposals:
  https://code.launchpad.net/~qzhang/lava-dispatcher/fix-861115/+merge/77290
  proposed by: Spring Zhang (qzhang)
  review: Approve - Yongqin Liu (liuyq0307)
  review: Resubmit - Spring Zhang (qzhang)
------------------------------------------------------------
revno: 129 [merge]
committer: Spring Zhang <spring.zhang@linaro.org>
branch nick: fix-861115
timestamp: Tue 2011-10-11 00:15:01 +0800
message:
  create random result directory on Android test to fix bug 861115
modified:
  lava_dispatcher/__init__.py
  lava_dispatcher/actions/launch_control.py
  lava_dispatcher/actions/lava-android-test.py
  lava_dispatcher/android_client.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/__init__.py'
--- lava_dispatcher/__init__.py	2011-09-28 03:41:31 +0000
+++ lava_dispatcher/__init__.py	2011-09-28 07:12:06 +0000
@@ -146,6 +146,8 @@ 
 
     @property
     def lava_result_dir(self):
+        if self.client.android_result_dir:
+            return self.client.android_result_dir
         return self.config.get("LAVA_RESULT_DIR")
 
     @property

=== modified file 'lava_dispatcher/actions/launch_control.py'
--- lava_dispatcher/actions/launch_control.py	2011-09-27 10:36:53 +0000
+++ lava_dispatcher/actions/launch_control.py	2011-10-10 10:19:45 +0000
@@ -70,18 +70,16 @@ 
             logging.warning("Fault string: %s" % err.faultString)
 
 class cmd_submit_results_on_host(SubmitResultAction):
-
     def run(self, server, stream):
-
         #Upload bundle files to dashboard
         logging.info("Executing submit_results_on_host command")
         bundlename_list = []
         status = 'pass'
         err_msg = ''
         try:
-            bundle_list = os.listdir("/tmp/%s" % self.context.lava_result_dir)
+            bundle_list = os.listdir(self.context.lava_result_dir)
             for bundle_name in bundle_list:
-                bundle = "/tmp/%s/%s" % (self.context.lava_result_dir, bundle_name)
+                bundle = "%s/%s" % (self.context.lava_result_dir, bundle_name)
                 bundlename_list.append(bundle)
                 f = open(bundle)
                 content = f.read()
@@ -92,17 +90,15 @@ 
             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)
+        shutil.rmtree(self.context.lava_result_dir)
+        if status == 'fail':
+            raise OperationFailed(err_msg)
 
 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
@@ -133,7 +129,7 @@ 
         status = 'pass'
         err_msg = ''
         master_ip = client.get_master_ip()
-        if master_ip != None:
+        if master_ip:
             # Set 80 as server port
             client.run_cmd_master('python -m SimpleHTTPServer 80 &> /dev/null &')
             time.sleep(3)
@@ -144,7 +140,6 @@ 
 
             # download test result with a retry mechanism
             # set retry timeout to 2mins
-
             logging.info("About to download the result tarball to host")
             now = time.time()
             timeout = 120
@@ -195,6 +190,7 @@ 
 def _get_dashboard(server):
     if not server.endswith("/"):
         server = ''.join([server, "/"])
+
     #add backward compatible for 'dashboard/'-end URL
     #Fix it: it's going to be deleted after transition
     if server.endswith("dashboard/"):
@@ -211,6 +207,7 @@ 
     else:
         logging.warn("The url seems not RPC2 or xml-rpc endpoints, please make sure it's a valid one!!!")
         dashboard = srv.dashboard
+
     logging.info("server RPC endpoint URL: %s" % server)
     return dashboard
 

=== modified file 'lava_dispatcher/actions/lava-android-test.py'
--- lava_dispatcher/actions/lava-android-test.py	2011-09-20 06:14:43 +0000
+++ lava_dispatcher/actions/lava-android-test.py	2011-10-10 10:19:45 +0000
@@ -18,6 +18,7 @@ 
 #
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses>.
+
 import sys
 import pexpect
 import time
@@ -61,11 +62,11 @@ 
         return dev_name
 
 class cmd_lava_android_test_run(AndroidTestAction):
-    def run(self, test_name, timeout= -1):
+    def run(self, test_name, timeout=-1):
         #Make sure in test image now
         dev_name = self.is_ready_for_test()
         bundle_name = test_name + "-" + datetime.now().strftime("%H%M%S")
-        cmd = 'lava-android-test run %s -s %s -o /tmp/%s/%s.bundle' % (
+        cmd = 'lava-android-test run %s -s %s -o %s/%s.bundle' % (
                 test_name, dev_name, self.context.lava_result_dir, bundle_name)
 
         rc = pexpect.run(cmd, timeout=None, logfile=sys.stdout, withexitstatus=True)[1]

=== modified file 'lava_dispatcher/android_client.py'
--- lava_dispatcher/android_client.py	2011-09-23 02:53:30 +0000
+++ lava_dispatcher/android_client.py	2011-10-10 10:19:45 +0000
@@ -19,15 +19,23 @@ 
 
 import pexpect
 import sys
+import os
 import time
 from lava_dispatcher.client import LavaClient, OperationFailed, NetworkError, GeneralError
 import logging
 
 from utils import string_to_list
+from tempfile import mkdtemp
 
 class LavaAndroidClient(LavaClient):
+    def __init__(self, context, config):
+        LavaClient.__init__(self, context, config)
+        # use a random result directory on android for they are using same host
+        self.android_result_dir = mkdtemp(
+            dir='/tmp/%s' % context.config.get("LAVA_RESULT_DIR"))
+        os.chmod(self.android_result_dir, 0755)
 
-    def run_adb_shell_command(self, dev_id, cmd, response, timeout= -1):
+    def run_adb_shell_command(self, dev_id, cmd, response, timeout=-1):
         adb_cmd = "adb -s %s shell %s" % (dev_id, cmd)
         try:
             adb_proc = pexpect.spawn(adb_cmd, logfile=sys.stdout)