Merge lp:~qzhang/lava-dispatcher/fix-861115 into lp:lava-dispatcher
- fix-861115
- Merge into trunk
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Yongqin Liu | Approve | ||
Spring Zhang (community) | Needs Resubmitting | ||
Review via email: mp+77290@code.launchpad.net |
Commit message
Description of the change
fix Bug 861115
Spring Zhang (qzhang) wrote : | # |
Yongqin Liu (liuyq0307) wrote : | # |
116 + self.android_
117 + os.chmod(
LavaClient doesn't have property lava_result_dir, it should be self.context.
btw, about the mode, default is as below, why need to change?
The directory is readable, writable, and searchable only by the creating user.
- 128. By Spring Zhang
-
fix by comments
Spring Zhang (qzhang) wrote : | # |
> 116 + self.android_
> mkdtemp(
> 117 + os.chmod(
>
> LavaClient doesn't have property lava_result_dir, it should be
> self.context.
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.
Spring Zhang (qzhang) wrote : | # |
fix some errors
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.
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-
For this problem, how about doing combinationg and submit for each lava-android-
Normally, the lava-result-
If there are lava-android-
If its lava-dispatcher is still running, then this lava-android-
but the logic will become a little complicate.
For it need to add a flag for each lava-android-
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.
Yongqin Liu (liuyq0307) wrote : | # |
when execute lava-dispatcher, it reports errors as below:
$ ./lava-dispatch doc/lava-
Traceback (most recent call last):
File "./lava-dispatch", line 59, in <module>
job = LavaTestJob(
File "/tmp/fix-
self.job_data)
File "/tmp/fix-
self._client = LavaAndroidClie
File "/tmp/fix-
self.
File "/tmp/fix-
if self.client.
File "/tmp/fix-
return self._client
AttributeError: 'LavaContext' object has no attribute '_client'
18:13:45 liuyq:fix-861115$
Spring Zhang (qzhang) wrote : | # |
Thanks, the object creating is a recursive call, so it failed.
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
- 132. By Spring Zhang
-
merge with mainline
Spring Zhang (qzhang) wrote : | # |
Thanks Yongqin on test.
Preview Diff
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 | 146 | 146 | ||
6 | 147 | @property | 147 | @property |
7 | 148 | def lava_result_dir(self): | 148 | def lava_result_dir(self): |
8 | 149 | if self.client.android_result_dir: | ||
9 | 150 | return self.client.android_result_dir | ||
10 | 149 | return self.config.get("LAVA_RESULT_DIR") | 151 | return self.config.get("LAVA_RESULT_DIR") |
11 | 150 | 152 | ||
12 | 151 | @property | 153 | @property |
13 | 152 | 154 | ||
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 | 70 | logging.warning("Fault string: %s" % err.faultString) | 70 | logging.warning("Fault string: %s" % err.faultString) |
19 | 71 | 71 | ||
20 | 72 | class cmd_submit_results_on_host(SubmitResultAction): | 72 | class cmd_submit_results_on_host(SubmitResultAction): |
21 | 73 | |||
22 | 74 | def run(self, server, stream): | 73 | def run(self, server, stream): |
23 | 75 | |||
24 | 76 | #Upload bundle files to dashboard | 74 | #Upload bundle files to dashboard |
25 | 77 | logging.info("Executing submit_results_on_host command") | 75 | logging.info("Executing submit_results_on_host command") |
26 | 78 | bundlename_list = [] | 76 | bundlename_list = [] |
27 | 79 | status = 'pass' | 77 | status = 'pass' |
28 | 80 | err_msg = '' | 78 | err_msg = '' |
29 | 81 | try: | 79 | try: |
31 | 82 | bundle_list = os.listdir("/tmp/%s" % self.context.lava_result_dir) | 80 | bundle_list = os.listdir(self.context.lava_result_dir) |
32 | 83 | for bundle_name in bundle_list: | 81 | for bundle_name in bundle_list: |
34 | 84 | bundle = "/tmp/%s/%s" % (self.context.lava_result_dir, bundle_name) | 82 | bundle = "%s/%s" % (self.context.lava_result_dir, bundle_name) |
35 | 85 | bundlename_list.append(bundle) | 83 | bundlename_list.append(bundle) |
36 | 86 | f = open(bundle) | 84 | f = open(bundle) |
37 | 87 | content = f.read() | 85 | content = f.read() |
38 | @@ -92,17 +90,15 @@ | |||
39 | 92 | status = 'fail' | 90 | status = 'fail' |
40 | 93 | err_msg = err_msg + " Some test case result appending failed." | 91 | err_msg = err_msg + " Some test case result appending failed." |
41 | 94 | 92 | ||
42 | 95 | |||
43 | 96 | self.submit_combine_bundles(status, err_msg, server, stream) | 93 | self.submit_combine_bundles(status, err_msg, server, stream) |
44 | 97 | 94 | ||
45 | 98 | if status == 'fail': | ||
46 | 99 | raise OperationFailed(err_msg) | ||
47 | 100 | |||
48 | 101 | for bundle in bundlename_list: | 95 | for bundle in bundlename_list: |
49 | 102 | os.remove(bundle) | 96 | os.remove(bundle) |
50 | 97 | shutil.rmtree(self.context.lava_result_dir) | ||
51 | 98 | if status == 'fail': | ||
52 | 99 | raise OperationFailed(err_msg) | ||
53 | 103 | 100 | ||
54 | 104 | class cmd_submit_results(SubmitResultAction): | 101 | class cmd_submit_results(SubmitResultAction): |
55 | 105 | |||
56 | 106 | def run(self, server, stream, result_disk="testrootfs"): | 102 | def run(self, server, stream, result_disk="testrootfs"): |
57 | 107 | """Submit test results to a lava-dashboard server | 103 | """Submit test results to a lava-dashboard server |
58 | 108 | :param server: URL of the lava-dashboard server RPC endpoint | 104 | :param server: URL of the lava-dashboard server RPC endpoint |
59 | @@ -133,7 +129,7 @@ | |||
60 | 133 | status = 'pass' | 129 | status = 'pass' |
61 | 134 | err_msg = '' | 130 | err_msg = '' |
62 | 135 | master_ip = client.get_master_ip() | 131 | master_ip = client.get_master_ip() |
64 | 136 | if master_ip != None: | 132 | if master_ip: |
65 | 137 | # Set 80 as server port | 133 | # Set 80 as server port |
66 | 138 | client.run_cmd_master('python -m SimpleHTTPServer 80 &> /dev/null &') | 134 | client.run_cmd_master('python -m SimpleHTTPServer 80 &> /dev/null &') |
67 | 139 | time.sleep(3) | 135 | time.sleep(3) |
68 | @@ -144,7 +140,6 @@ | |||
69 | 144 | 140 | ||
70 | 145 | # download test result with a retry mechanism | 141 | # download test result with a retry mechanism |
71 | 146 | # set retry timeout to 2mins | 142 | # set retry timeout to 2mins |
72 | 147 | |||
73 | 148 | logging.info("About to download the result tarball to host") | 143 | logging.info("About to download the result tarball to host") |
74 | 149 | now = time.time() | 144 | now = time.time() |
75 | 150 | timeout = 120 | 145 | timeout = 120 |
76 | @@ -195,6 +190,7 @@ | |||
77 | 195 | def _get_dashboard(server): | 190 | def _get_dashboard(server): |
78 | 196 | if not server.endswith("/"): | 191 | if not server.endswith("/"): |
79 | 197 | server = ''.join([server, "/"]) | 192 | server = ''.join([server, "/"]) |
80 | 193 | |||
81 | 198 | #add backward compatible for 'dashboard/'-end URL | 194 | #add backward compatible for 'dashboard/'-end URL |
82 | 199 | #Fix it: it's going to be deleted after transition | 195 | #Fix it: it's going to be deleted after transition |
83 | 200 | if server.endswith("dashboard/"): | 196 | if server.endswith("dashboard/"): |
84 | @@ -211,6 +207,7 @@ | |||
85 | 211 | else: | 207 | else: |
86 | 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!!!") |
87 | 213 | dashboard = srv.dashboard | 209 | dashboard = srv.dashboard |
88 | 210 | |||
89 | 214 | logging.info("server RPC endpoint URL: %s" % server) | 211 | logging.info("server RPC endpoint URL: %s" % server) |
90 | 215 | return dashboard | 212 | return dashboard |
91 | 216 | 213 | ||
92 | 217 | 214 | ||
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 | 18 | # | 18 | # |
98 | 19 | # You should have received a copy of the GNU General Public License | 19 | # You should have received a copy of the GNU General Public License |
99 | 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>. |
100 | 21 | |||
101 | 21 | import sys | 22 | import sys |
102 | 22 | import pexpect | 23 | import pexpect |
103 | 23 | import time | 24 | import time |
104 | @@ -61,11 +62,11 @@ | |||
105 | 61 | return dev_name | 62 | return dev_name |
106 | 62 | 63 | ||
107 | 63 | class cmd_lava_android_test_run(AndroidTestAction): | 64 | class cmd_lava_android_test_run(AndroidTestAction): |
109 | 64 | def run(self, test_name, timeout= -1): | 65 | def run(self, test_name, timeout=-1): |
110 | 65 | #Make sure in test image now | 66 | #Make sure in test image now |
111 | 66 | dev_name = self.is_ready_for_test() | 67 | dev_name = self.is_ready_for_test() |
112 | 67 | bundle_name = test_name + "-" + datetime.now().strftime("%H%M%S") | 68 | bundle_name = test_name + "-" + datetime.now().strftime("%H%M%S") |
114 | 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' % ( |
115 | 69 | test_name, dev_name, self.context.lava_result_dir, bundle_name) | 70 | test_name, dev_name, self.context.lava_result_dir, bundle_name) |
116 | 70 | 71 | ||
117 | 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] |
118 | 72 | 73 | ||
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 | 19 | 19 | ||
124 | 20 | import pexpect | 20 | import pexpect |
125 | 21 | import sys | 21 | import sys |
126 | 22 | import os | ||
127 | 22 | import time | 23 | import time |
128 | 23 | from lava_dispatcher.client import LavaClient, OperationFailed, NetworkError, GeneralError | 24 | from lava_dispatcher.client import LavaClient, OperationFailed, NetworkError, GeneralError |
129 | 24 | import logging | 25 | import logging |
130 | 25 | 26 | ||
131 | 26 | from utils import string_to_list | 27 | from utils import string_to_list |
132 | 28 | from tempfile import mkdtemp | ||
133 | 27 | 29 | ||
134 | 28 | class LavaAndroidClient(LavaClient): | 30 | class LavaAndroidClient(LavaClient): |
135 | 31 | def __init__(self, context, config): | ||
136 | 32 | LavaClient.__init__(self, context, config) | ||
137 | 33 | # use a random result directory on android for they are using same host | ||
138 | 34 | self.android_result_dir = mkdtemp( | ||
139 | 35 | dir='/tmp/%s' % context.config.get("LAVA_RESULT_DIR")) | ||
140 | 36 | os.chmod(self.android_result_dir, 0755) | ||
141 | 29 | 37 | ||
143 | 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): |
144 | 31 | adb_cmd = "adb -s %s shell %s" % (dev_id, cmd) | 39 | adb_cmd = "adb -s %s shell %s" % (dev_id, cmd) |
145 | 32 | try: | 40 | try: |
146 | 33 | adb_proc = pexpect.spawn(adb_cmd, logfile=sys.stdout) | 41 | adb_proc = pexpect.spawn(adb_cmd, logfile=sys.stdout) |
Please have a test, I didn't have available Android image.