Merge lp:~le-chi-thu/lava-test/merging_w1121 into lp:lava-test/0.0

Proposed by Le Chi Thu
Status: Merged
Merged at revision: 70
Proposed branch: lp:~le-chi-thu/lava-test/merging_w1121
Merge into: lp:lava-test/0.0
Diff against target: 377 lines (+175/-49)
6 files modified
abrek/api.py (+44/-0)
abrek/bundle.py (+44/-0)
abrek/dashboard.py (+20/-13)
abrek/main.py (+6/-0)
abrek/testdef.py (+30/-27)
tests/test_dashboard.py (+31/-9)
To merge this branch: bzr merge lp:~le-chi-thu/lava-test/merging_w1121
Reviewer Review Type Date Requested Status
Paul Larson (community) Approve
Review via email: mp+63709@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Paul Larson (pwlars) wrote :

This seems to work, but somehow you seem to have picked up the changes from https://code.launchpad.net/~zkrynicki/abrek/save-tests-as-uuid/+merge/58356 which I asked that we *not* pick up for now.

It also might have been easier to spot this if you had done a commit for each merge. You only have 3 commits here, but there were several branches going into this.

review: Needs Fixing
73. By Le Chi Thu <email address hidden> <email address hidden>

Undo the UUID changes

Revision history for this message
Le Chi Thu (le-chi-thu) wrote :

Hi

I did not merge the
https://code.launchpad.net/~zkrynicki/abrek/save-tests-as-uuid/+merge/58356
and I
found the uuid is included in
https://code.launchpad.net/~zkrynicki/abrek/use-document-io

Now I manually removed the uuid changes in 58356 and push the changes to
this mp.

BR

/Chi Thu

On 7 June 2011 18:39, Paul Larson <email address hidden> wrote:

> Review: Needs Fixing
> This seems to work, but somehow you seem to have picked up the changes from
> https://code.launchpad.net/~zkrynicki/abrek/save-tests-as-uuid/+merge/58356which I asked that we *not* pick up for now.
>
> It also might have been easier to spot this if you had done a commit for
> each merge. You only have 3 commits here, but there were several branches
> going into this.
> --
> https://code.launchpad.net/~le-chi-thu/abrek/merging_w1121/+merge/63709
> You are the owner of lp:~le-chi-thu/abrek/merging_w1121.
>

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

Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'abrek/api.py'
2--- abrek/api.py 1970-01-01 00:00:00 +0000
3+++ abrek/api.py 2011-06-07 21:21:22 +0000
4@@ -0,0 +1,44 @@
5+"""
6+Public API for extending Abrek
7+"""
8+from abc import abstractmethod, abstractproperty
9+
10+
11+class ITest(object):
12+ """
13+ Abrek test.
14+
15+ Something that can be installed and invoked by abre.
16+ """
17+
18+ @abstractmethod
19+ def install(self):
20+ """
21+ Install the test suite.
22+
23+ This creates an install directory under the user's XDG_DATA_HOME
24+ directory to mark that the test is installed. The installer's
25+ install() method is then called from this directory to complete any
26+ test specific install that may be needed.
27+ """
28+
29+ @abstractmethod
30+ def uninstall(self):
31+ """
32+ Uninstall the test suite.
33+
34+ Uninstalling just recursively removes the test specific directory under
35+ the user's XDG_DATA_HOME directory. This will both mark the test as
36+ removed, and clean up any files that were downloaded or installed under
37+ that directory. Dependencies are intentionally not removed by this.
38+ """
39+
40+ @abstractmethod
41+ def run(self, quiet=False):
42+ # TODO: Document me
43+ pass
44+
45+ @abstractmethod
46+ def parse(self, resultname):
47+ # TODO: Document me
48+ pass
49
50=== added file 'abrek/bundle.py'
51--- abrek/bundle.py 1970-01-01 00:00:00 +0000
52+++ abrek/bundle.py 2011-06-07 21:21:22 +0000
53@@ -0,0 +1,44 @@
54+# Copyright (c) 2011 Linaro
55+#
56+# This program is free software: you can redistribute it and/or modify
57+# it under the terms of the GNU General Public License as published by
58+# the Free Software Foundation, either version 3 of the License, or
59+# (at your option) any later version.
60+#
61+# This program is distributed in the hope that it will be useful,
62+# but WITHOUT ANY WARRANTY; without even the implied warranty of
63+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
64+# GNU General Public License for more details.
65+#
66+# You should have received a copy of the GNU General Public License
67+# along with this program. If not, see <http://www.gnu.org/licenses/>.
68+
69+"""
70+This module attempts to use the linaro-dashboard-bundle package, if possible.
71+
72+Using that package adds proper support for loading and saving bundle
73+documents. In particular it supports loosles decimals, better, more stable
74+load-modify-write cycles, data validation, transparent migration and many
75+other features.
76+
77+It is not a hard dependency to make it possible to run abrek from a checkout
78+without having to install (too many) dependencies.
79+"""
80+
81+try:
82+ from linaro_dashboard_bundle import DocumentIO
83+except ImportError:
84+ import json
85+
86+ class DocumentIO(object):
87+ """ Bare replacement DocumentIO without any fancy features """
88+
89+ @classmethod
90+ def dumps(cls, doc):
91+ return json.dumps(doc, indent=2)
92+
93+ @classmethod
94+ def loads(cls, text):
95+ doc = json.loads(text)
96+ fmt = doc.get("format")
97+ return fmt, doc
98\ No newline at end of file
99
100=== modified file 'abrek/dashboard.py'
101--- abrek/dashboard.py 2010-10-14 13:57:35 +0000
102+++ abrek/dashboard.py 2011-06-07 21:21:22 +0000
103@@ -14,7 +14,6 @@
104 # along with this program. If not, see <http://www.gnu.org/licenses/>.
105
106 import base64
107-import json
108 import os
109 import socket
110 import sys
111@@ -24,6 +23,7 @@
112 from getpass import getpass
113 from optparse import make_option
114
115+from abrek.bundle import DocumentIO
116 from abrek.command import AbrekCmd, AbrekCmdWithSubcommands
117 from abrek.config import get_config
118 from abrek.testdef import testloader
119@@ -147,7 +147,7 @@
120 "dashboard setup [host]'"
121 sys.exit(1)
122 try:
123- result = server.put(json.dumps(bundle, indent=2), result_name,
124+ result = server.put(DocumentIO.dumps(bundle), result_name,
125 stream_name)
126 print "Bundle successfully uploaded to id: %s" % result
127 except xmlrpclib.Fault as strerror:
128@@ -173,7 +173,7 @@
129 sys.exit(1)
130 bundle = generate_bundle(self.args[0])
131 try:
132- print json.dumps(bundle, indent=2)
133+ print DocumentIO.dumps(bundle)
134 except IOError:
135 pass
136
137@@ -182,17 +182,24 @@
138 config = get_config()
139 resultdir = os.path.join(config.resultsdir, result)
140 if not os.path.exists(resultdir):
141+ # FIXME: UI and sys.exit mixed with internal implementation, yuck
142 print "Result directory not found"
143 sys.exit(1)
144- testdatafile = os.path.join(resultdir, "testdata.json")
145- testdata = json.loads(file(testdatafile).read())
146- test = testloader(testdata['test_runs'][0]['test_id'])
147- try:
148- test.parse(result)
149- except Exception as strerror:
150- print "Test parse error: %s" % strerror
151- sys.exit(1)
152- testdata['test_runs'][0].update(test.parser.results)
153- return testdata
154+ with open(os.path.join(resultdir, "testdata.json")) as stream:
155+ bundle_text = stream.read()
156+ with open(os.path.join(resultdir, "testoutput.log")) as stream:
157+ output_text = stream.read()
158+ fmt, bundle = DocumentIO.loads(bundle_text)
159+ test = testloader(bundle['test_runs'][0]['test_id'])
160+ test.parse(result)
161+ bundle['test_runs'][0]["test_results"] = test.parser.results["test_results"]
162+ bundle['test_runs'][0]["attachments"] = [
163+ {
164+ "pathname": "testoutput.log",
165+ "mime_type": "text/plain",
166+ "content": base64.standard_b64encode(output_text)
167+ }
168+ ]
169+ return bundle
170
171
172
173=== modified file 'abrek/main.py'
174--- abrek/main.py 2010-10-11 23:05:37 +0000
175+++ abrek/main.py 2011-06-07 21:21:22 +0000
176@@ -26,3 +26,9 @@
177 print "command '%s' not found" % cmd
178 return 1
179 return cmd_func.main(argv)
180+
181+if __name__ == '__main__':
182+ import os
183+ import sys
184+ exit_code = main(sys.argv)
185+ sys.exit(exit_code)
186\ No newline at end of file
187
188=== modified file 'abrek/testdef.py'
189--- abrek/testdef.py 2011-04-20 08:39:25 +0000
190+++ abrek/testdef.py 2011-06-07 21:21:22 +0000
191@@ -14,7 +14,6 @@
192 # along with this program. If not, see <http://www.gnu.org/licenses/>.
193
194 import hashlib
195-import json
196 import os
197 import re
198 import shutil
199@@ -22,15 +21,15 @@
200 import time
201 from commands import getstatusoutput
202 from datetime import datetime
203-from uuid import uuid1
204
205+from abrek import swprofile, hwprofile
206+from abrek.api import ITest
207+from abrek.bundle import DocumentIO
208 from abrek.config import get_config
209 from abrek.utils import Tee, geturl, run_and_log, write_file
210-from abrek import hwprofile
211-from abrek import swprofile
212-
213-
214-class AbrekTest(object):
215+
216+
217+class AbrekTest(ITest):
218 """Base class for defining tests.
219
220 This can be used by test definition files to create an object that
221@@ -94,21 +93,21 @@
222
223 def _savetestdata(self):
224 TIMEFORMAT = '%Y-%m-%dT%H:%M:%SZ'
225- testdata = {}
226- test_runs = [{}]
227- testdata['format'] = "Dashboard Bundle Format 1.2"
228+ bundle = {
229+ 'format': 'Dashboard Bundle Format 1.2',
230+ 'test_runs': [
231+ {
232+ 'test_id': self.testname,
233+ 'analyzer_assigned_date': self.runner.starttime.strftime(TIMEFORMAT),
234+ 'time_check_performed': False,
235+ 'hardware_context': hwprofile.get_hardware_context(),
236+ 'software_context': swprofile.get_software_context(),
237+ 'test_results': []
238+ }
239+ ]
240+ }
241 filename = os.path.join(self.resultsdir, 'testdata.json')
242- test_runs[0]['test_id'] = self.testname
243- test_runs[0]['analyzer_assigned_uuid'] = str(uuid1())
244- test_runs[0]['time_check_performed'] = False
245- test_runs[0]['analyzer_assigned_date'] = datetime.strftime(
246- self.runner.starttime,TIMEFORMAT)
247- hw = hwprofile.get_hardware_context()
248- test_runs[0]['hardware_context'] = hw
249- sw = swprofile.get_software_context()
250- test_runs[0]['software_context'] = sw
251- testdata['test_runs'] = test_runs
252- write_file(json.dumps(testdata, indent=2), filename)
253+ write_file(DocumentIO.dumps(bundle), filename)
254
255 def run(self, quiet=False):
256 if not self.runner:
257@@ -120,10 +119,12 @@
258 str(time.mktime(datetime.utcnow().timetuple())))
259 self.resultsdir = os.path.join(config.resultsdir, resultname)
260 os.makedirs(self.resultsdir)
261- os.chdir(installdir)
262- self.runner.run(self.resultsdir, quiet=quiet)
263- self._savetestdata()
264- os.chdir(self.origdir)
265+ try:
266+ os.chdir(installdir)
267+ self.runner.run(self.resultsdir, quiet=quiet)
268+ self._savetestdata()
269+ finally:
270+ os.chdir(self.origdir)
271 result_id = os.path.basename(self.resultsdir)
272 print("ABREK TEST RUN COMPLETE: Result id is '%s'" % result_id)
273 return result_id
274@@ -278,12 +279,14 @@
275 except Exception as strerror:
276 raise RuntimeError("AbrekTestParser - Invalid regular expression '%s' - %s" %(self.pattern,strerror))
277
278- with open(filename, 'r') as fd:
279- for line in fd.readlines():
280+ with open(filename, 'r') as stream:
281+ for lineno, line in enumerate(stream, 1):
282 match = pat.search(line)
283 if not match:
284 continue
285 data = match.groupdict()
286+ data["log_filename"] = filename
287+ data["log_lineno"] = lineno
288 self.results['test_results'].append(data)
289 if self.fixupdict:
290 self.fixresults(self.fixupdict)
291
292=== modified file 'tests/test_dashboard.py'
293--- tests/test_dashboard.py 2011-04-07 05:26:43 +0000
294+++ tests/test_dashboard.py 2011-06-07 21:21:22 +0000
295@@ -76,37 +76,54 @@
296 cmd = cmd_dashboard.cmd_bundle()
297 (testname, testuuid) = make_stream_result(self.config)
298 expected_dict = {
299+ "format": "Dashboard Bundle Format 1.2",
300 "test_runs": [{
301 "analyzer_assigned_date": "2010-10-10T00:00:00Z",
302 "analyzer_assigned_uuid": testuuid,
303- "hardware_context": {},
304+ "hardware_context": {
305+ "devices": []
306+ },
307 "software_context": {},
308 "test_id": "stream",
309 "test_results": [{
310 "measurement": 1111.1111,
311 "result": "pass",
312 "test_case_id": "Copy",
313- "units": "MB/s"
314+ "units": "MB/s",
315+ "log_filename": "testoutput.log",
316+ "log_lineno": 3
317 },
318 {
319 "measurement": 2222.2222,
320 "result": "pass",
321 "test_case_id": "Scale",
322- "units": "MB/s"
323+ "units": "MB/s",
324+ "log_filename": "testoutput.log",
325+ "log_lineno": 4
326 },
327 {
328 "measurement": 3333.3333,
329 "result": "pass",
330 "test_case_id": "Add",
331- "units": "MB/s"
332+ "units": "MB/s",
333+ "log_filename": "testoutput.log",
334+ "log_lineno": 5
335 },
336 {
337 "measurement": 4444.4444,
338 "result": "pass",
339 "test_case_id": "Triad",
340- "units": "MB/s"
341+ "units": "MB/s",
342+ "log_filename": "testoutput.log",
343+ "log_lineno": 6
344 }],
345- "time_check_performed": False
346+ "time_check_performed": False,
347+ "attachments": [
348+ {
349+ "mime_type": "text/plain",
350+ "pathname": "testoutput.log",
351+ "content": "CkZ1bmN0aW9uICAgICAgUmF0ZSAoTUIvcykgICBBdmcgdGltZSAgICAgTWluIHRpbWUgICAgIE1heCB0aW1lCkNvcHk6ICAgICAgICAxMTExLjExMTEgICAgICAgMC4wMTgwICAgICAgIDAuMDExMiAgICAgICAwLjAyNDIKU2NhbGU6ICAgICAgIDIyMjIuMjIyMiAgICAgICAwLjAxOTggICAgICAgMC4wMTIyICAgICAgIDAuMDI0MwpBZGQ6ICAgICAgICAgMzMzMy4zMzMzICAgICAgIDAuMDIwMSAgICAgICAwLjAxNzYgICAgICAgMC4wMjIzClRyaWFkOiAgICAgICA0NDQ0LjQ0NDQgICAgICAgMC4wMTk3ICAgICAgIDAuMDEzOCAgICAgICAwLjAyMjMK"
352+ }]
353 }]
354 }
355 cmd.main(argv=[testname])
356@@ -159,13 +176,18 @@
357 testname = "stream000"
358 testuuid = str(uuid1())
359 testdata_data = """
360-{"test_runs": [{
361+{
362+"format": "Dashboard Bundle Format 1.2",
363+"test_runs": [{
364 "analyzer_assigned_date": "2010-10-10T00:00:00Z",
365 "analyzer_assigned_uuid": "%s",
366- "hardware_context": {},
367+ "hardware_context": {
368+ "devices": []
369+ },
370 "software_context": {},
371 "test_id": "stream",
372- "time_check_performed": false
373+ "time_check_performed": false,
374+ "test_results": []
375 }]
376 }
377 """ % testuuid

Subscribers

People subscribed via source and target branches