Merge lp:~qzhang/lava-dispatcher/fix-861115 into lp:lava-dispatcher

Proposed by Spring Zhang
Status: Merged
Merged at revision: 129
Proposed branch: lp:~qzhang/lava-dispatcher/fix-861115
Merge into: lp:lava-dispatcher
Diff against target: 146 lines (+22/-14)
4 files modified
lava_dispatcher/__init__.py (+2/-0)
lava_dispatcher/actions/launch_control.py (+8/-11)
lava_dispatcher/actions/lava-android-test.py (+3/-2)
lava_dispatcher/android_client.py (+9/-1)
To merge this branch: bzr merge lp:~qzhang/lava-dispatcher/fix-861115
Reviewer Review Type Date Requested Status
Yongqin Liu Approve
Spring Zhang (community) Needs Resubmitting
Review via email: mp+77290@code.launchpad.net

Description of the change

To post a comment you must log in.
Revision history for this message
Spring Zhang (qzhang) wrote :

Please have a test, I didn't have available Android image.

Revision history for this message
Yongqin Liu (liuyq0307) wrote :

116 + self.android_result_dir = mkdtemp(dir=LavaClient.lava_result_dir)
117 + os.chmod(self.android_result_dir, 0755)

LavaClient doesn't have property lava_result_dir, it should be self.context.lava_result_dir I think.

btw, about the mode, default is as below, why need to change?

The directory is readable, writable, and searchable only by the creating user.

review: Needs Fixing
128. By Spring Zhang

fix by comments

Revision history for this message
Spring Zhang (qzhang) wrote :

> 116 + self.android_result_dir =
> mkdtemp(dir=LavaClient.lava_result_dir)
> 117 + os.chmod(self.android_result_dir, 0755)
>
> LavaClient doesn't have property lava_result_dir, it should be
> self.context.lava_result_dir I think.
right
>
> btw, about the mode, default is as below, why need to change?
It's 0700 by default, I changed it to follow the routine in lava code

>
> The directory is readable, writable, and searchable only by the creating user.

Revision history for this message
Spring Zhang (qzhang) wrote :

fix some errors

review: Needs Resubmitting
Revision history for this message
Yongqin Liu (liuyq0307) wrote :

last night i dreamed a problem.
if we use a uniqe name for each job in the result directory, then if the job failed to submit the results to lava-server,
when the failed results will be resubmitted?

another problem I think about is that whether it is good to put the result in /tmp directory?
For my ubuntu os, if I reboot, the /tmp directory will be cleared.
For our lava-dispatcher case, there is chance that the failed results will be cleared I think.

Revision history for this message
Yongqin Liu (liuyq0307) wrote :

> last night i dreamed a problem.
> if we use a uniqe name for each job in the result directory, then if the job
> failed to submit the results to lava-server,
> when the failed results will be resubmitted?
Here use lava-result-directory for the result directory specified by user, lava-android-test-result-directory for the directory created by lava-dispatcher temporarily.
For this problem, how about doing combinationg and submit for each lava-android-test-result-directory failed to submitted last time in the lava-result-directory?
Normally, the lava-result-directory will only contain lava-android-test-result-directory that its lava-dispatcher still running. So each lava-dispatcher will only combine and submit its result.
If there are lava-android-test-result-directory that the lava-dispatcher create it is not running, then combine it and submit its results, otherwise the results will not be submitted again.
If its lava-dispatcher is still running, then this lava-android-test-result-directory will be ignored, it will be submitted by its lava-dispatcher.

but the logic will become a little complicate.
For it need to add a flag for each lava-android-test-result-directory to specify whether its lava-dispatcher is still running.

review: Needs Fixing
Revision history for this message
Spring Zhang (qzhang) wrote :

If the result submitting failed, we leave it now. We can draft a work item about result cache submitting in Internet environment, when the dashboard is in a public website and validation farm is not placed with dashboard server.

Revision history for this message
Yongqin Liu (liuyq0307) wrote :

when execute lava-dispatcher, it reports errors as below:

$ ./lava-dispatch doc/lava-android-test-leb-panda.json
Traceback (most recent call last):
  File "./lava-dispatch", line 59, in <module>
    job = LavaTestJob(jobdata, oob_file)
  File "/tmp/fix-861115/lava_dispatcher/__init__.py", line 42, in __init__
    self.job_data)
  File "/tmp/fix-861115/lava_dispatcher/__init__.py", line 125, in __init__
    self._client = LavaAndroidClient(self, device_config)
  File "/tmp/fix-861115/lava_dispatcher/android_client.py", line 33, in __init__
    self.android_result_dir = mkdtemp(dir=self.context.lava_result_dir)
  File "/tmp/fix-861115/lava_dispatcher/__init__.py", line 149, in lava_result_dir
    if self.client.android_result_dir:
  File "/tmp/fix-861115/lava_dispatcher/__init__.py", line 133, in client
    return self._client
AttributeError: 'LavaContext' object has no attribute '_client'
18:13:45 liuyq:fix-861115$

review: Needs Fixing
Revision history for this message
Spring Zhang (qzhang) wrote :

Thanks, the object creating is a recursive call, so it failed.

Revision history for this message
Paul Larson (pwlars) wrote :

Please merge this when liuyq has tested it and it looks good.

129. By Spring Zhang

break recursive call between Client and LavaContext

130. By Spring Zhang

merge with mainline

131. By Spring Zhang

Fix bugs caused by creating result directory in advance

Revision history for this message
Yongqin Liu (liuyq0307) wrote :

tested.

review: Approve
132. By Spring Zhang

merge with mainline

Revision history for this message
Spring Zhang (qzhang) wrote :

Thanks Yongqin on test.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lava_dispatcher/__init__.py'
--- lava_dispatcher/__init__.py 2011-09-28 03:41:31 +0000
+++ lava_dispatcher/__init__.py 2011-10-10 16:12:17 +0000
@@ -146,6 +146,8 @@
146146
147 @property147 @property
148 def lava_result_dir(self):148 def lava_result_dir(self):
149 if self.client.android_result_dir:
150 return self.client.android_result_dir
149 return self.config.get("LAVA_RESULT_DIR")151 return self.config.get("LAVA_RESULT_DIR")
150152
151 @property153 @property
152154
=== 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 16:12:17 +0000
@@ -70,18 +70,16 @@
70 logging.warning("Fault string: %s" % err.faultString)70 logging.warning("Fault string: %s" % err.faultString)
7171
72class cmd_submit_results_on_host(SubmitResultAction):72class cmd_submit_results_on_host(SubmitResultAction):
73
74 def run(self, server, stream):73 def run(self, server, stream):
75
76 #Upload bundle files to dashboard74 #Upload bundle files to dashboard
77 logging.info("Executing submit_results_on_host command")75 logging.info("Executing submit_results_on_host command")
78 bundlename_list = []76 bundlename_list = []
79 status = 'pass'77 status = 'pass'
80 err_msg = ''78 err_msg = ''
81 try:79 try:
82 bundle_list = os.listdir("/tmp/%s" % self.context.lava_result_dir)80 bundle_list = os.listdir(self.context.lava_result_dir)
83 for bundle_name in bundle_list:81 for bundle_name in bundle_list:
84 bundle = "/tmp/%s/%s" % (self.context.lava_result_dir, bundle_name)82 bundle = "%s/%s" % (self.context.lava_result_dir, bundle_name)
85 bundlename_list.append(bundle)83 bundlename_list.append(bundle)
86 f = open(bundle)84 f = open(bundle)
87 content = f.read()85 content = f.read()
@@ -92,17 +90,15 @@
92 status = 'fail'90 status = 'fail'
93 err_msg = err_msg + " Some test case result appending failed."91 err_msg = err_msg + " Some test case result appending failed."
9492
95
96 self.submit_combine_bundles(status, err_msg, server, stream)93 self.submit_combine_bundles(status, err_msg, server, stream)
9794
98 if status == 'fail':
99 raise OperationFailed(err_msg)
100
101 for bundle in bundlename_list:95 for bundle in bundlename_list:
102 os.remove(bundle)96 os.remove(bundle)
97 shutil.rmtree(self.context.lava_result_dir)
98 if status == 'fail':
99 raise OperationFailed(err_msg)
103100
104class cmd_submit_results(SubmitResultAction):101class cmd_submit_results(SubmitResultAction):
105
106 def run(self, server, stream, result_disk="testrootfs"):102 def run(self, server, stream, result_disk="testrootfs"):
107 """Submit test results to a lava-dashboard server103 """Submit test results to a lava-dashboard server
108 :param server: URL of the lava-dashboard server RPC endpoint104 :param server: URL of the lava-dashboard server RPC endpoint
@@ -133,7 +129,7 @@
133 status = 'pass'129 status = 'pass'
134 err_msg = ''130 err_msg = ''
135 master_ip = client.get_master_ip()131 master_ip = client.get_master_ip()
136 if master_ip != None:132 if master_ip:
137 # Set 80 as server port133 # Set 80 as server port
138 client.run_cmd_master('python -m SimpleHTTPServer 80 &> /dev/null &')134 client.run_cmd_master('python -m SimpleHTTPServer 80 &> /dev/null &')
139 time.sleep(3)135 time.sleep(3)
@@ -144,7 +140,6 @@
144140
145 # download test result with a retry mechanism141 # download test result with a retry mechanism
146 # set retry timeout to 2mins142 # set retry timeout to 2mins
147
148 logging.info("About to download the result tarball to host")143 logging.info("About to download the result tarball to host")
149 now = time.time()144 now = time.time()
150 timeout = 120145 timeout = 120
@@ -195,6 +190,7 @@
195def _get_dashboard(server):190def _get_dashboard(server):
196 if not server.endswith("/"):191 if not server.endswith("/"):
197 server = ''.join([server, "/"])192 server = ''.join([server, "/"])
193
198 #add backward compatible for 'dashboard/'-end URL194 #add backward compatible for 'dashboard/'-end URL
199 #Fix it: it's going to be deleted after transition195 #Fix it: it's going to be deleted after transition
200 if server.endswith("dashboard/"):196 if server.endswith("dashboard/"):
@@ -211,6 +207,7 @@
211 else:207 else:
212 logging.warn("The url seems not RPC2 or xml-rpc endpoints, please make sure it's a valid one!!!")208 logging.warn("The url seems not RPC2 or xml-rpc endpoints, please make sure it's a valid one!!!")
213 dashboard = srv.dashboard209 dashboard = srv.dashboard
210
214 logging.info("server RPC endpoint URL: %s" % server)211 logging.info("server RPC endpoint URL: %s" % server)
215 return dashboard212 return dashboard
216213
217214
=== 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 16:12:17 +0000
@@ -18,6 +18,7 @@
18#18#
19# You should have received a copy of the GNU General Public License19# You should have received a copy of the GNU General Public License
20# along with this program; if not, see <http://www.gnu.org/licenses>.20# along with this program; if not, see <http://www.gnu.org/licenses>.
21
21import sys22import sys
22import pexpect23import pexpect
23import time24import time
@@ -61,11 +62,11 @@
61 return dev_name62 return dev_name
6263
63class cmd_lava_android_test_run(AndroidTestAction):64class cmd_lava_android_test_run(AndroidTestAction):
64 def run(self, test_name, timeout= -1):65 def run(self, test_name, timeout=-1):
65 #Make sure in test image now66 #Make sure in test image now
66 dev_name = self.is_ready_for_test()67 dev_name = self.is_ready_for_test()
67 bundle_name = test_name + "-" + datetime.now().strftime("%H%M%S")68 bundle_name = test_name + "-" + datetime.now().strftime("%H%M%S")
68 cmd = 'lava-android-test run %s -s %s -o /tmp/%s/%s.bundle' % (69 cmd = 'lava-android-test run %s -s %s -o %s/%s.bundle' % (
69 test_name, dev_name, self.context.lava_result_dir, bundle_name)70 test_name, dev_name, self.context.lava_result_dir, bundle_name)
7071
71 rc = pexpect.run(cmd, timeout=None, logfile=sys.stdout, withexitstatus=True)[1]72 rc = pexpect.run(cmd, timeout=None, logfile=sys.stdout, withexitstatus=True)[1]
7273
=== 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 16:12:17 +0000
@@ -19,15 +19,23 @@
1919
20import pexpect20import pexpect
21import sys21import sys
22import os
22import time23import time
23from lava_dispatcher.client import LavaClient, OperationFailed, NetworkError, GeneralError24from lava_dispatcher.client import LavaClient, OperationFailed, NetworkError, GeneralError
24import logging25import logging
2526
26from utils import string_to_list27from utils import string_to_list
28from tempfile import mkdtemp
2729
28class LavaAndroidClient(LavaClient):30class LavaAndroidClient(LavaClient):
31 def __init__(self, context, config):
32 LavaClient.__init__(self, context, config)
33 # use a random result directory on android for they are using same host
34 self.android_result_dir = mkdtemp(
35 dir='/tmp/%s' % context.config.get("LAVA_RESULT_DIR"))
36 os.chmod(self.android_result_dir, 0755)
2937
30 def run_adb_shell_command(self, dev_id, cmd, response, timeout= -1):38 def run_adb_shell_command(self, dev_id, cmd, response, timeout=-1):
31 adb_cmd = "adb -s %s shell %s" % (dev_id, cmd)39 adb_cmd = "adb -s %s shell %s" % (dev_id, cmd)
32 try:40 try:
33 adb_proc = pexpect.spawn(adb_cmd, logfile=sys.stdout)41 adb_proc = pexpect.spawn(adb_cmd, logfile=sys.stdout)

Subscribers

People subscribed via source and target branches