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
=== added file 'abrek/api.py'
--- abrek/api.py 1970-01-01 00:00:00 +0000
+++ abrek/api.py 2011-06-07 21:21:22 +0000
@@ -0,0 +1,44 @@
1"""
2Public API for extending Abrek
3"""
4from abc import abstractmethod, abstractproperty
5
6
7class ITest(object):
8 """
9 Abrek test.
10
11 Something that can be installed and invoked by abre.
12 """
13
14 @abstractmethod
15 def install(self):
16 """
17 Install the test suite.
18
19 This creates an install directory under the user's XDG_DATA_HOME
20 directory to mark that the test is installed. The installer's
21 install() method is then called from this directory to complete any
22 test specific install that may be needed.
23 """
24
25 @abstractmethod
26 def uninstall(self):
27 """
28 Uninstall the test suite.
29
30 Uninstalling just recursively removes the test specific directory under
31 the user's XDG_DATA_HOME directory. This will both mark the test as
32 removed, and clean up any files that were downloaded or installed under
33 that directory. Dependencies are intentionally not removed by this.
34 """
35
36 @abstractmethod
37 def run(self, quiet=False):
38 # TODO: Document me
39 pass
40
41 @abstractmethod
42 def parse(self, resultname):
43 # TODO: Document me
44 pass
045
=== added file 'abrek/bundle.py'
--- abrek/bundle.py 1970-01-01 00:00:00 +0000
+++ abrek/bundle.py 2011-06-07 21:21:22 +0000
@@ -0,0 +1,44 @@
1# Copyright (c) 2011 Linaro
2#
3# This program is free software: you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation, either version 3 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16"""
17This module attempts to use the linaro-dashboard-bundle package, if possible.
18
19Using that package adds proper support for loading and saving bundle
20documents. In particular it supports loosles decimals, better, more stable
21load-modify-write cycles, data validation, transparent migration and many
22other features.
23
24It is not a hard dependency to make it possible to run abrek from a checkout
25without having to install (too many) dependencies.
26"""
27
28try:
29 from linaro_dashboard_bundle import DocumentIO
30except ImportError:
31 import json
32
33 class DocumentIO(object):
34 """ Bare replacement DocumentIO without any fancy features """
35
36 @classmethod
37 def dumps(cls, doc):
38 return json.dumps(doc, indent=2)
39
40 @classmethod
41 def loads(cls, text):
42 doc = json.loads(text)
43 fmt = doc.get("format")
44 return fmt, doc
0\ No newline at end of file45\ No newline at end of file
146
=== modified file 'abrek/dashboard.py'
--- abrek/dashboard.py 2010-10-14 13:57:35 +0000
+++ abrek/dashboard.py 2011-06-07 21:21:22 +0000
@@ -14,7 +14,6 @@
14# along with this program. If not, see <http://www.gnu.org/licenses/>.14# along with this program. If not, see <http://www.gnu.org/licenses/>.
1515
16import base6416import base64
17import json
18import os17import os
19import socket18import socket
20import sys19import sys
@@ -24,6 +23,7 @@
24from getpass import getpass23from getpass import getpass
25from optparse import make_option24from optparse import make_option
2625
26from abrek.bundle import DocumentIO
27from abrek.command import AbrekCmd, AbrekCmdWithSubcommands27from abrek.command import AbrekCmd, AbrekCmdWithSubcommands
28from abrek.config import get_config28from abrek.config import get_config
29from abrek.testdef import testloader29from abrek.testdef import testloader
@@ -147,7 +147,7 @@
147 "dashboard setup [host]'"147 "dashboard setup [host]'"
148 sys.exit(1)148 sys.exit(1)
149 try:149 try:
150 result = server.put(json.dumps(bundle, indent=2), result_name,150 result = server.put(DocumentIO.dumps(bundle), result_name,
151 stream_name)151 stream_name)
152 print "Bundle successfully uploaded to id: %s" % result152 print "Bundle successfully uploaded to id: %s" % result
153 except xmlrpclib.Fault as strerror:153 except xmlrpclib.Fault as strerror:
@@ -173,7 +173,7 @@
173 sys.exit(1)173 sys.exit(1)
174 bundle = generate_bundle(self.args[0])174 bundle = generate_bundle(self.args[0])
175 try:175 try:
176 print json.dumps(bundle, indent=2)176 print DocumentIO.dumps(bundle)
177 except IOError:177 except IOError:
178 pass178 pass
179179
@@ -182,17 +182,24 @@
182 config = get_config()182 config = get_config()
183 resultdir = os.path.join(config.resultsdir, result)183 resultdir = os.path.join(config.resultsdir, result)
184 if not os.path.exists(resultdir):184 if not os.path.exists(resultdir):
185 # FIXME: UI and sys.exit mixed with internal implementation, yuck
185 print "Result directory not found"186 print "Result directory not found"
186 sys.exit(1)187 sys.exit(1)
187 testdatafile = os.path.join(resultdir, "testdata.json")188 with open(os.path.join(resultdir, "testdata.json")) as stream:
188 testdata = json.loads(file(testdatafile).read())189 bundle_text = stream.read()
189 test = testloader(testdata['test_runs'][0]['test_id'])190 with open(os.path.join(resultdir, "testoutput.log")) as stream:
190 try:191 output_text = stream.read()
191 test.parse(result)192 fmt, bundle = DocumentIO.loads(bundle_text)
192 except Exception as strerror:193 test = testloader(bundle['test_runs'][0]['test_id'])
193 print "Test parse error: %s" % strerror194 test.parse(result)
194 sys.exit(1)195 bundle['test_runs'][0]["test_results"] = test.parser.results["test_results"]
195 testdata['test_runs'][0].update(test.parser.results)196 bundle['test_runs'][0]["attachments"] = [
196 return testdata197 {
198 "pathname": "testoutput.log",
199 "mime_type": "text/plain",
200 "content": base64.standard_b64encode(output_text)
201 }
202 ]
203 return bundle
197204
198205
199206
=== modified file 'abrek/main.py'
--- abrek/main.py 2010-10-11 23:05:37 +0000
+++ abrek/main.py 2011-06-07 21:21:22 +0000
@@ -26,3 +26,9 @@
26 print "command '%s' not found" % cmd26 print "command '%s' not found" % cmd
27 return 127 return 1
28 return cmd_func.main(argv)28 return cmd_func.main(argv)
29
30if __name__ == '__main__':
31 import os
32 import sys
33 exit_code = main(sys.argv)
34 sys.exit(exit_code)
29\ No newline at end of file35\ No newline at end of file
3036
=== modified file 'abrek/testdef.py'
--- abrek/testdef.py 2011-04-20 08:39:25 +0000
+++ abrek/testdef.py 2011-06-07 21:21:22 +0000
@@ -14,7 +14,6 @@
14# along with this program. If not, see <http://www.gnu.org/licenses/>.14# along with this program. If not, see <http://www.gnu.org/licenses/>.
1515
16import hashlib16import hashlib
17import json
18import os17import os
19import re18import re
20import shutil19import shutil
@@ -22,15 +21,15 @@
22import time21import time
23from commands import getstatusoutput22from commands import getstatusoutput
24from datetime import datetime23from datetime import datetime
25from uuid import uuid1
2624
25from abrek import swprofile, hwprofile
26from abrek.api import ITest
27from abrek.bundle import DocumentIO
27from abrek.config import get_config28from abrek.config import get_config
28from abrek.utils import Tee, geturl, run_and_log, write_file29from abrek.utils import Tee, geturl, run_and_log, write_file
29from abrek import hwprofile30
30from abrek import swprofile31
3132class AbrekTest(ITest):
32
33class AbrekTest(object):
34 """Base class for defining tests.33 """Base class for defining tests.
3534
36 This can be used by test definition files to create an object that35 This can be used by test definition files to create an object that
@@ -94,21 +93,21 @@
9493
95 def _savetestdata(self):94 def _savetestdata(self):
96 TIMEFORMAT = '%Y-%m-%dT%H:%M:%SZ'95 TIMEFORMAT = '%Y-%m-%dT%H:%M:%SZ'
97 testdata = {}96 bundle = {
98 test_runs = [{}]97 'format': 'Dashboard Bundle Format 1.2',
99 testdata['format'] = "Dashboard Bundle Format 1.2"98 'test_runs': [
99 {
100 'test_id': self.testname,
101 'analyzer_assigned_date': self.runner.starttime.strftime(TIMEFORMAT),
102 'time_check_performed': False,
103 'hardware_context': hwprofile.get_hardware_context(),
104 'software_context': swprofile.get_software_context(),
105 'test_results': []
106 }
107 ]
108 }
100 filename = os.path.join(self.resultsdir, 'testdata.json')109 filename = os.path.join(self.resultsdir, 'testdata.json')
101 test_runs[0]['test_id'] = self.testname110 write_file(DocumentIO.dumps(bundle), filename)
102 test_runs[0]['analyzer_assigned_uuid'] = str(uuid1())
103 test_runs[0]['time_check_performed'] = False
104 test_runs[0]['analyzer_assigned_date'] = datetime.strftime(
105 self.runner.starttime,TIMEFORMAT)
106 hw = hwprofile.get_hardware_context()
107 test_runs[0]['hardware_context'] = hw
108 sw = swprofile.get_software_context()
109 test_runs[0]['software_context'] = sw
110 testdata['test_runs'] = test_runs
111 write_file(json.dumps(testdata, indent=2), filename)
112111
113 def run(self, quiet=False):112 def run(self, quiet=False):
114 if not self.runner:113 if not self.runner:
@@ -120,10 +119,12 @@
120 str(time.mktime(datetime.utcnow().timetuple())))119 str(time.mktime(datetime.utcnow().timetuple())))
121 self.resultsdir = os.path.join(config.resultsdir, resultname)120 self.resultsdir = os.path.join(config.resultsdir, resultname)
122 os.makedirs(self.resultsdir)121 os.makedirs(self.resultsdir)
123 os.chdir(installdir)122 try:
124 self.runner.run(self.resultsdir, quiet=quiet)123 os.chdir(installdir)
125 self._savetestdata()124 self.runner.run(self.resultsdir, quiet=quiet)
126 os.chdir(self.origdir)125 self._savetestdata()
126 finally:
127 os.chdir(self.origdir)
127 result_id = os.path.basename(self.resultsdir)128 result_id = os.path.basename(self.resultsdir)
128 print("ABREK TEST RUN COMPLETE: Result id is '%s'" % result_id)129 print("ABREK TEST RUN COMPLETE: Result id is '%s'" % result_id)
129 return result_id130 return result_id
@@ -278,12 +279,14 @@
278 except Exception as strerror:279 except Exception as strerror:
279 raise RuntimeError("AbrekTestParser - Invalid regular expression '%s' - %s" %(self.pattern,strerror))280 raise RuntimeError("AbrekTestParser - Invalid regular expression '%s' - %s" %(self.pattern,strerror))
280281
281 with open(filename, 'r') as fd:282 with open(filename, 'r') as stream:
282 for line in fd.readlines():283 for lineno, line in enumerate(stream, 1):
283 match = pat.search(line)284 match = pat.search(line)
284 if not match:285 if not match:
285 continue286 continue
286 data = match.groupdict()287 data = match.groupdict()
288 data["log_filename"] = filename
289 data["log_lineno"] = lineno
287 self.results['test_results'].append(data)290 self.results['test_results'].append(data)
288 if self.fixupdict:291 if self.fixupdict:
289 self.fixresults(self.fixupdict)292 self.fixresults(self.fixupdict)
290293
=== modified file 'tests/test_dashboard.py'
--- tests/test_dashboard.py 2011-04-07 05:26:43 +0000
+++ tests/test_dashboard.py 2011-06-07 21:21:22 +0000
@@ -76,37 +76,54 @@
76 cmd = cmd_dashboard.cmd_bundle()76 cmd = cmd_dashboard.cmd_bundle()
77 (testname, testuuid) = make_stream_result(self.config)77 (testname, testuuid) = make_stream_result(self.config)
78 expected_dict = {78 expected_dict = {
79 "format": "Dashboard Bundle Format 1.2",
79 "test_runs": [{80 "test_runs": [{
80 "analyzer_assigned_date": "2010-10-10T00:00:00Z",81 "analyzer_assigned_date": "2010-10-10T00:00:00Z",
81 "analyzer_assigned_uuid": testuuid,82 "analyzer_assigned_uuid": testuuid,
82 "hardware_context": {},83 "hardware_context": {
84 "devices": []
85 },
83 "software_context": {},86 "software_context": {},
84 "test_id": "stream",87 "test_id": "stream",
85 "test_results": [{88 "test_results": [{
86 "measurement": 1111.1111,89 "measurement": 1111.1111,
87 "result": "pass",90 "result": "pass",
88 "test_case_id": "Copy",91 "test_case_id": "Copy",
89 "units": "MB/s"92 "units": "MB/s",
93 "log_filename": "testoutput.log",
94 "log_lineno": 3
90 },95 },
91 {96 {
92 "measurement": 2222.2222,97 "measurement": 2222.2222,
93 "result": "pass",98 "result": "pass",
94 "test_case_id": "Scale",99 "test_case_id": "Scale",
95 "units": "MB/s"100 "units": "MB/s",
101 "log_filename": "testoutput.log",
102 "log_lineno": 4
96 },103 },
97 {104 {
98 "measurement": 3333.3333,105 "measurement": 3333.3333,
99 "result": "pass",106 "result": "pass",
100 "test_case_id": "Add",107 "test_case_id": "Add",
101 "units": "MB/s"108 "units": "MB/s",
109 "log_filename": "testoutput.log",
110 "log_lineno": 5
102 },111 },
103 {112 {
104 "measurement": 4444.4444,113 "measurement": 4444.4444,
105 "result": "pass",114 "result": "pass",
106 "test_case_id": "Triad",115 "test_case_id": "Triad",
107 "units": "MB/s"116 "units": "MB/s",
117 "log_filename": "testoutput.log",
118 "log_lineno": 6
108 }],119 }],
109 "time_check_performed": False120 "time_check_performed": False,
121 "attachments": [
122 {
123 "mime_type": "text/plain",
124 "pathname": "testoutput.log",
125 "content": "CkZ1bmN0aW9uICAgICAgUmF0ZSAoTUIvcykgICBBdmcgdGltZSAgICAgTWluIHRpbWUgICAgIE1heCB0aW1lCkNvcHk6ICAgICAgICAxMTExLjExMTEgICAgICAgMC4wMTgwICAgICAgIDAuMDExMiAgICAgICAwLjAyNDIKU2NhbGU6ICAgICAgIDIyMjIuMjIyMiAgICAgICAwLjAxOTggICAgICAgMC4wMTIyICAgICAgIDAuMDI0MwpBZGQ6ICAgICAgICAgMzMzMy4zMzMzICAgICAgIDAuMDIwMSAgICAgICAwLjAxNzYgICAgICAgMC4wMjIzClRyaWFkOiAgICAgICA0NDQ0LjQ0NDQgICAgICAgMC4wMTk3ICAgICAgIDAuMDEzOCAgICAgICAwLjAyMjMK"
126 }]
110 }]127 }]
111 }128 }
112 cmd.main(argv=[testname])129 cmd.main(argv=[testname])
@@ -159,13 +176,18 @@
159 testname = "stream000"176 testname = "stream000"
160 testuuid = str(uuid1())177 testuuid = str(uuid1())
161 testdata_data = """178 testdata_data = """
162{"test_runs": [{179{
180"format": "Dashboard Bundle Format 1.2",
181"test_runs": [{
163 "analyzer_assigned_date": "2010-10-10T00:00:00Z",182 "analyzer_assigned_date": "2010-10-10T00:00:00Z",
164 "analyzer_assigned_uuid": "%s",183 "analyzer_assigned_uuid": "%s",
165 "hardware_context": {},184 "hardware_context": {
185 "devices": []
186 },
166 "software_context": {},187 "software_context": {},
167 "test_id": "stream",188 "test_id": "stream",
168 "time_check_performed": false189 "time_check_performed": false,
190 "test_results": []
169 }]191 }]
170}192}
171""" % testuuid193""" % testuuid

Subscribers

People subscribed via source and target branches