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
1=== modified file 'lava_dispatcher/__init__.py'
2--- lava_dispatcher/__init__.py 2011-09-28 03:41:31 +0000
3+++ lava_dispatcher/__init__.py 2011-10-10 16:12:17 +0000
4@@ -146,6 +146,8 @@
5
6 @property
7 def lava_result_dir(self):
8+ if self.client.android_result_dir:
9+ return self.client.android_result_dir
10 return self.config.get("LAVA_RESULT_DIR")
11
12 @property
13
14=== modified file 'lava_dispatcher/actions/launch_control.py'
15--- lava_dispatcher/actions/launch_control.py 2011-09-27 10:36:53 +0000
16+++ lava_dispatcher/actions/launch_control.py 2011-10-10 16:12:17 +0000
17@@ -70,18 +70,16 @@
18 logging.warning("Fault string: %s" % err.faultString)
19
20 class cmd_submit_results_on_host(SubmitResultAction):
21-
22 def run(self, server, stream):
23-
24 #Upload bundle files to dashboard
25 logging.info("Executing submit_results_on_host command")
26 bundlename_list = []
27 status = 'pass'
28 err_msg = ''
29 try:
30- bundle_list = os.listdir("/tmp/%s" % self.context.lava_result_dir)
31+ bundle_list = os.listdir(self.context.lava_result_dir)
32 for bundle_name in bundle_list:
33- bundle = "/tmp/%s/%s" % (self.context.lava_result_dir, bundle_name)
34+ bundle = "%s/%s" % (self.context.lava_result_dir, bundle_name)
35 bundlename_list.append(bundle)
36 f = open(bundle)
37 content = f.read()
38@@ -92,17 +90,15 @@
39 status = 'fail'
40 err_msg = err_msg + " Some test case result appending failed."
41
42-
43 self.submit_combine_bundles(status, err_msg, server, stream)
44
45- if status == 'fail':
46- raise OperationFailed(err_msg)
47-
48 for bundle in bundlename_list:
49 os.remove(bundle)
50+ shutil.rmtree(self.context.lava_result_dir)
51+ if status == 'fail':
52+ raise OperationFailed(err_msg)
53
54 class cmd_submit_results(SubmitResultAction):
55-
56 def run(self, server, stream, result_disk="testrootfs"):
57 """Submit test results to a lava-dashboard server
58 :param server: URL of the lava-dashboard server RPC endpoint
59@@ -133,7 +129,7 @@
60 status = 'pass'
61 err_msg = ''
62 master_ip = client.get_master_ip()
63- if master_ip != None:
64+ if master_ip:
65 # Set 80 as server port
66 client.run_cmd_master('python -m SimpleHTTPServer 80 &> /dev/null &')
67 time.sleep(3)
68@@ -144,7 +140,6 @@
69
70 # download test result with a retry mechanism
71 # set retry timeout to 2mins
72-
73 logging.info("About to download the result tarball to host")
74 now = time.time()
75 timeout = 120
76@@ -195,6 +190,7 @@
77 def _get_dashboard(server):
78 if not server.endswith("/"):
79 server = ''.join([server, "/"])
80+
81 #add backward compatible for 'dashboard/'-end URL
82 #Fix it: it's going to be deleted after transition
83 if server.endswith("dashboard/"):
84@@ -211,6 +207,7 @@
85 else:
86 logging.warn("The url seems not RPC2 or xml-rpc endpoints, please make sure it's a valid one!!!")
87 dashboard = srv.dashboard
88+
89 logging.info("server RPC endpoint URL: %s" % server)
90 return dashboard
91
92
93=== modified file 'lava_dispatcher/actions/lava-android-test.py'
94--- lava_dispatcher/actions/lava-android-test.py 2011-09-20 06:14:43 +0000
95+++ lava_dispatcher/actions/lava-android-test.py 2011-10-10 16:12:17 +0000
96@@ -18,6 +18,7 @@
97 #
98 # You should have received a copy of the GNU General Public License
99 # along with this program; if not, see <http://www.gnu.org/licenses>.
100+
101 import sys
102 import pexpect
103 import time
104@@ -61,11 +62,11 @@
105 return dev_name
106
107 class cmd_lava_android_test_run(AndroidTestAction):
108- def run(self, test_name, timeout= -1):
109+ def run(self, test_name, timeout=-1):
110 #Make sure in test image now
111 dev_name = self.is_ready_for_test()
112 bundle_name = test_name + "-" + datetime.now().strftime("%H%M%S")
113- cmd = 'lava-android-test run %s -s %s -o /tmp/%s/%s.bundle' % (
114+ cmd = 'lava-android-test run %s -s %s -o %s/%s.bundle' % (
115 test_name, dev_name, self.context.lava_result_dir, bundle_name)
116
117 rc = pexpect.run(cmd, timeout=None, logfile=sys.stdout, withexitstatus=True)[1]
118
119=== modified file 'lava_dispatcher/android_client.py'
120--- lava_dispatcher/android_client.py 2011-09-23 02:53:30 +0000
121+++ lava_dispatcher/android_client.py 2011-10-10 16:12:17 +0000
122@@ -19,15 +19,23 @@
123
124 import pexpect
125 import sys
126+import os
127 import time
128 from lava_dispatcher.client import LavaClient, OperationFailed, NetworkError, GeneralError
129 import logging
130
131 from utils import string_to_list
132+from tempfile import mkdtemp
133
134 class LavaAndroidClient(LavaClient):
135+ def __init__(self, context, config):
136+ LavaClient.__init__(self, context, config)
137+ # use a random result directory on android for they are using same host
138+ self.android_result_dir = mkdtemp(
139+ dir='/tmp/%s' % context.config.get("LAVA_RESULT_DIR"))
140+ os.chmod(self.android_result_dir, 0755)
141
142- def run_adb_shell_command(self, dev_id, cmd, response, timeout= -1):
143+ def run_adb_shell_command(self, dev_id, cmd, response, timeout=-1):
144 adb_cmd = "adb -s %s shell %s" % (dev_id, cmd)
145 try:
146 adb_proc = pexpect.spawn(adb_cmd, logfile=sys.stdout)

Subscribers

People subscribed via source and target branches