Status: | Merged |
---|---|
Merged at revision: | 22 |
Proposed branch: | lp:~pwlars/lava-test/hwsw |
Merge into: | lp:lava-test/0.0 |
Diff against target: |
206 lines (+34/-28) 5 files modified
abrek/swprofile.py (+1/-4) abrek/test_definitions/stream.py (+2/-2) abrek/testdef.py (+25/-16) tests/test_abrektestparser.py (+4/-4) tests/test_swprofile.py (+2/-2) |
To merge this branch: | bzr merge lp:~pwlars/lava-test/hwsw |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
James Westby (community) | Approve | ||
Review via email: mp+32229@code.launchpad.net |
Commit message
Description of the change
A few minor cleanups to make fields more compliant with what the dashboard will expect, and add the hardware/software profile to the data that is generated when the test is executed.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'abrek/swprofile.py' | |||
2 | --- abrek/swprofile.py 2010-08-04 17:29:48 +0000 | |||
3 | +++ abrek/swprofile.py 2010-08-10 17:31:01 +0000 | |||
4 | @@ -19,8 +19,7 @@ | |||
5 | 19 | packages.append(pkg) | 19 | packages.append(pkg) |
6 | 20 | return packages | 20 | return packages |
7 | 21 | 21 | ||
10 | 22 | def get_sw_context(test_id, time_check=False, apt_cache=None, | 22 | def get_sw_context(apt_cache=None, lsb_information=None): |
9 | 23 | lsb_information=None): | ||
11 | 24 | """ Return dict used for storing sw_context information | 23 | """ Return dict used for storing sw_context information |
12 | 25 | 24 | ||
13 | 26 | test_id - Unique identifier for this test | 25 | test_id - Unique identifier for this test |
14 | @@ -32,8 +31,6 @@ | |||
15 | 32 | sw_context = {} | 31 | sw_context = {} |
16 | 33 | sw_context['sw_image'] = get_sw_image(lsb_information) | 32 | sw_context['sw_image'] = get_sw_image(lsb_information) |
17 | 34 | sw_context['packages'] = get_packages(apt_cache) | 33 | sw_context['packages'] = get_packages(apt_cache) |
18 | 35 | sw_context['time_check_performed'] = time_check | ||
19 | 36 | sw_context['test_id'] = test_id | ||
20 | 37 | return sw_context | 34 | return sw_context |
21 | 38 | 35 | ||
22 | 39 | def get_sw_image(lsb_information=None): | 36 | def get_sw_image(lsb_information=None): |
23 | 40 | 37 | ||
24 | === modified file 'abrek/test_definitions/stream.py' | |||
25 | --- abrek/test_definitions/stream.py 2010-07-26 14:20:59 +0000 | |||
26 | +++ abrek/test_definitions/stream.py 2010-08-10 17:31:01 +0000 | |||
27 | @@ -4,11 +4,11 @@ | |||
28 | 4 | MD5="b6cd43b848e0d8b0824703369392f3c5" | 4 | MD5="b6cd43b848e0d8b0824703369392f3c5" |
29 | 5 | INSTALLSTEPS = ['cc stream.c -O2 -fopenmp -o stream'] | 5 | INSTALLSTEPS = ['cc stream.c -O2 -fopenmp -o stream'] |
30 | 6 | RUNSTEPS = ['./stream'] | 6 | RUNSTEPS = ['./stream'] |
32 | 7 | PATTERN = "^(?P<testid>\w+):\W+(?P<result>\d+\.\d+)" | 7 | PATTERN = "^(?P<test_case_id>\w+):\W+(?P<measurement>\d+\.\d+)" |
33 | 8 | 8 | ||
34 | 9 | streaminst = abrek.testdef.AbrekTestInstaller(INSTALLSTEPS, url=URL, md5=MD5) | 9 | streaminst = abrek.testdef.AbrekTestInstaller(INSTALLSTEPS, url=URL, md5=MD5) |
35 | 10 | streamrun = abrek.testdef.AbrekTestRunner(RUNSTEPS) | 10 | streamrun = abrek.testdef.AbrekTestRunner(RUNSTEPS) |
36 | 11 | streamparser = abrek.testdef.AbrekTestParser(PATTERN, | 11 | streamparser = abrek.testdef.AbrekTestParser(PATTERN, |
38 | 12 | appendall={'units':'MB/s'}) | 12 | appendall={'units':'MB/s', 'result':'pass'}) |
39 | 13 | testobj = abrek.testdef.AbrekTest(testname="stream", installer=streaminst, | 13 | testobj = abrek.testdef.AbrekTest(testname="stream", installer=streaminst, |
40 | 14 | runner=streamrun, parser=streamparser) | 14 | runner=streamrun, parser=streamparser) |
41 | 15 | 15 | ||
42 | === modified file 'abrek/testdef.py' | |||
43 | --- abrek/testdef.py 2010-07-26 14:20:59 +0000 | |||
44 | +++ abrek/testdef.py 2010-08-10 17:31:01 +0000 | |||
45 | @@ -7,9 +7,12 @@ | |||
46 | 7 | import time | 7 | import time |
47 | 8 | from commands import getstatusoutput | 8 | from commands import getstatusoutput |
48 | 9 | from datetime import datetime | 9 | from datetime import datetime |
49 | 10 | from uuid import uuid1 | ||
50 | 10 | 11 | ||
51 | 11 | from abrek.config import get_config | 12 | from abrek.config import get_config |
52 | 12 | from abrek.utils import geturl, write_file | 13 | from abrek.utils import geturl, write_file |
53 | 14 | from abrek import hwprofile | ||
54 | 15 | from abrek import swprofile | ||
55 | 13 | 16 | ||
56 | 14 | class AbrekTest(object): | 17 | class AbrekTest(object): |
57 | 15 | """Base class for defining tests. | 18 | """Base class for defining tests. |
58 | @@ -72,12 +75,18 @@ | |||
59 | 72 | shutil.rmtree(path) | 75 | shutil.rmtree(path) |
60 | 73 | 76 | ||
61 | 74 | def _savetestdata(self): | 77 | def _savetestdata(self): |
62 | 78 | TIMEFORMAT = '%Y-%m-%dT%H:%M:%SZ' | ||
63 | 75 | testdata = {} | 79 | testdata = {} |
64 | 76 | filename = os.path.join(self.resultsdir, 'testdata.json') | 80 | filename = os.path.join(self.resultsdir, 'testdata.json') |
69 | 77 | testdata['testname'] = self.testname | 81 | testdata['test_id'] = self.testname |
70 | 78 | testdata['version'] = self.version | 82 | testdata['analyzer_assigned_uuid'] = str(uuid1()) |
71 | 79 | testdata['starttime'] = time.mktime(self.runner.starttime.timetuple()) | 83 | testdata['time_check_performed'] = False |
72 | 80 | testdata['endtime'] = time.mktime(self.runner.endtime.timetuple()) | 84 | testdata['analyzer_assigned_date'] = datetime.strftime( |
73 | 85 | self.runner.starttime,TIMEFORMAT) | ||
74 | 86 | hw = hwprofile.get_hw_context() | ||
75 | 87 | testdata['hw_context'] = hw | ||
76 | 88 | sw = swprofile.get_sw_context() | ||
77 | 89 | testdata['sw_context'] = sw | ||
78 | 81 | write_file(json.dumps(testdata), filename) | 90 | write_file(json.dumps(testdata), filename) |
79 | 82 | 91 | ||
80 | 83 | def run(self): | 92 | def run(self): |
81 | @@ -199,27 +208,27 @@ | |||
82 | 199 | "test01: PASS", then you could use a pattern like this: | 208 | "test01: PASS", then you could use a pattern like this: |
83 | 200 | "^(?P<testid>\w+):\W+(?P<result>\w+)" | 209 | "^(?P<testid>\w+):\W+(?P<result>\w+)" |
84 | 201 | This would result in identifying "test01" as testid and "PASS" | 210 | This would result in identifying "test01" as testid and "PASS" |
86 | 202 | as result. Once parse() has been called, self.results.testlist[] | 211 | as result. Once parse() has been called, self.results.test_results[] |
87 | 203 | contains a list of dicts of all the key,value pairs found for | 212 | contains a list of dicts of all the key,value pairs found for |
88 | 204 | each test result | 213 | each test result |
89 | 205 | fixupdict - dict of strings to convert test results to standard strings | 214 | fixupdict - dict of strings to convert test results to standard strings |
90 | 206 | For example: if you want to standardize on having pass/fail results | 215 | For example: if you want to standardize on having pass/fail results |
91 | 207 | in lower case, but your test outputs them in upper case, you could | 216 | in lower case, but your test outputs them in upper case, you could |
92 | 208 | use a fixupdict of something like: {'PASS':'pass','FAIL':'fail'} | 217 | use a fixupdict of something like: {'PASS':'pass','FAIL':'fail'} |
94 | 209 | appendall - Append a dict to the testlist entry for each result. | 218 | appendall - Append a dict to the test_results entry for each result. |
95 | 210 | For example: if you would like to add units="MB/s" to each result: | 219 | For example: if you would like to add units="MB/s" to each result: |
96 | 211 | appendall={'units':'MB/s'} | 220 | appendall={'units':'MB/s'} |
97 | 212 | """ | 221 | """ |
98 | 213 | def __init__(self, pattern=None, fixupdict=None, appendall={}): | 222 | def __init__(self, pattern=None, fixupdict=None, appendall={}): |
99 | 214 | self.pattern = pattern | 223 | self.pattern = pattern |
100 | 215 | self.fixupdict = fixupdict | 224 | self.fixupdict = fixupdict |
102 | 216 | self.results = {'testlist':[]} | 225 | self.results = {'test_results':[]} |
103 | 217 | self.appendall = appendall | 226 | self.appendall = appendall |
104 | 218 | 227 | ||
105 | 219 | def _find_testid(self, id): | 228 | def _find_testid(self, id): |
107 | 220 | for x in self.results['testlist']: | 229 | for x in self.results['test_results']: |
108 | 221 | if x['testid'] == id: | 230 | if x['testid'] == id: |
110 | 222 | return self.results['testlist'].index(x) | 231 | return self.results['test_results'].index(x) |
111 | 223 | 232 | ||
112 | 224 | def parse(self): | 233 | def parse(self): |
113 | 225 | """Parse test output to gather results | 234 | """Parse test output to gather results |
114 | @@ -235,27 +244,27 @@ | |||
115 | 235 | for line in fd.readlines(): | 244 | for line in fd.readlines(): |
116 | 236 | match = pat.search(line) | 245 | match = pat.search(line) |
117 | 237 | if match: | 246 | if match: |
119 | 238 | self.results['testlist'].append(match.groupdict()) | 247 | self.results['test_results'].append(match.groupdict()) |
120 | 239 | if self.fixupdict: | 248 | if self.fixupdict: |
121 | 240 | self.fixresults(self.fixupdict) | 249 | self.fixresults(self.fixupdict) |
122 | 241 | if self.appendall: | 250 | if self.appendall: |
123 | 242 | self.appendtoall(self.appendall) | 251 | self.appendtoall(self.appendall) |
124 | 243 | 252 | ||
125 | 244 | def append(self, testid, entry): | 253 | def append(self, testid, entry): |
127 | 245 | """Appends a dict to the testlist entry for a specified testid | 254 | """Appends a dict to the test_results entry for a specified testid |
128 | 246 | 255 | ||
129 | 247 | This lets you add a dict to the entry for a specific testid | 256 | This lets you add a dict to the entry for a specific testid |
130 | 248 | entry should be a dict, updates it in place | 257 | entry should be a dict, updates it in place |
131 | 249 | """ | 258 | """ |
132 | 250 | index = self._find_testid(testid) | 259 | index = self._find_testid(testid) |
134 | 251 | self.results['testlist'][index].update(entry) | 260 | self.results['test_results'][index].update(entry) |
135 | 252 | 261 | ||
136 | 253 | def appendtoall(self, entry): | 262 | def appendtoall(self, entry): |
138 | 254 | """Append entry to each item in the testlist. | 263 | """Append entry to each item in the test_results. |
139 | 255 | 264 | ||
141 | 256 | entry - dict of key,value pairs to add to each item in the testlist | 265 | entry - dict of key,value pairs to add to each item in the test_results |
142 | 257 | """ | 266 | """ |
144 | 258 | for t in self.results['testlist']: | 267 | for t in self.results['test_results']: |
145 | 259 | t.update(entry) | 268 | t.update(entry) |
146 | 260 | 269 | ||
147 | 261 | def fixresults(self, fixupdict): | 270 | def fixresults(self, fixupdict): |
148 | @@ -266,7 +275,7 @@ | |||
149 | 266 | {"TPASS":"pass", "TFAIL":"fail"} | 275 | {"TPASS":"pass", "TFAIL":"fail"} |
150 | 267 | This is really only used for qualitative tests | 276 | This is really only used for qualitative tests |
151 | 268 | """ | 277 | """ |
153 | 269 | for t in self.results['testlist']: | 278 | for t in self.results['test_results']: |
154 | 270 | if t.has_key("result"): | 279 | if t.has_key("result"): |
155 | 271 | t['result'] = fixupdict[t['result']] | 280 | t['result'] = fixupdict[t['result']] |
156 | 272 | 281 | ||
157 | 273 | 282 | ||
158 | === modified file 'tests/test_abrektestparser.py' | |||
159 | --- tests/test_abrektestparser.py 2010-07-22 14:49:49 +0000 | |||
160 | +++ tests/test_abrektestparser.py 2010-08-10 17:31:01 +0000 | |||
161 | @@ -28,8 +28,8 @@ | |||
162 | 28 | self.writeoutputlog("test001: pass") | 28 | self.writeoutputlog("test001: pass") |
163 | 29 | parser = self.makeparser(pattern) | 29 | parser = self.makeparser(pattern) |
164 | 30 | parser.parse() | 30 | parser.parse() |
167 | 31 | self.assertTrue(parser.results["testlist"][0]["testid"] == "test001" and | 31 | self.assertTrue(parser.results["test_results"][0]["testid"] == "test001" and |
168 | 32 | parser.results["testlist"][0]["result"] == "pass") | 32 | parser.results["test_results"][0]["result"] == "pass") |
169 | 33 | 33 | ||
170 | 34 | def test_fixupdict(self): | 34 | def test_fixupdict(self): |
171 | 35 | pattern = "^(?P<testid>\w+):\W+(?P<result>\w+)" | 35 | pattern = "^(?P<testid>\w+):\W+(?P<result>\w+)" |
172 | @@ -37,7 +37,7 @@ | |||
173 | 37 | self.writeoutputlog("test001: pass") | 37 | self.writeoutputlog("test001: pass") |
174 | 38 | parser = self.makeparser(pattern, fixupdict=fixup) | 38 | parser = self.makeparser(pattern, fixupdict=fixup) |
175 | 39 | parser.parse() | 39 | parser.parse() |
177 | 40 | self.assertEquals("PASS", parser.results["testlist"][0]["result"]) | 40 | self.assertEquals("PASS", parser.results["test_results"][0]["result"]) |
178 | 41 | 41 | ||
179 | 42 | def test_appendall(self): | 42 | def test_appendall(self): |
180 | 43 | pattern = "^(?P<testid>\w+):\W+(?P<result>\w+)" | 43 | pattern = "^(?P<testid>\w+):\W+(?P<result>\w+)" |
181 | @@ -45,5 +45,5 @@ | |||
182 | 45 | self.writeoutputlog("test001: pass") | 45 | self.writeoutputlog("test001: pass") |
183 | 46 | parser = self.makeparser(pattern, appendall=append) | 46 | parser = self.makeparser(pattern, appendall=append) |
184 | 47 | parser.parse() | 47 | parser.parse() |
186 | 48 | self.assertEqual("foo/s", parser.results["testlist"][0]["units"]) | 48 | self.assertEqual("foo/s", parser.results["test_results"][0]["units"]) |
187 | 49 | 49 | ||
188 | 50 | 50 | ||
189 | === modified file 'tests/test_swprofile.py' | |||
190 | --- tests/test_swprofile.py 2010-08-04 17:29:48 +0000 | |||
191 | +++ tests/test_swprofile.py 2010-08-10 17:31:01 +0000 | |||
192 | @@ -26,12 +26,12 @@ | |||
193 | 26 | self.testpackage = Package('testpkg', '7.77') | 26 | self.testpackage = Package('testpkg', '7.77') |
194 | 27 | self.cache = AptCache([self.testpackage]) | 27 | self.cache = AptCache([self.testpackage]) |
195 | 28 | 28 | ||
197 | 29 | def make_profile(self, test_id='unit', cache=None, info=None): | 29 | def make_profile(self, cache=None, info=None): |
198 | 30 | if cache == None: | 30 | if cache == None: |
199 | 31 | cache = self.cache | 31 | cache = self.cache |
200 | 32 | if info == None: | 32 | if info == None: |
201 | 33 | info = self.lsb_information | 33 | info = self.lsb_information |
203 | 34 | return abrek.swprofile.get_sw_context(test_id, apt_cache=cache, | 34 | return abrek.swprofile.get_sw_context(apt_cache=cache, |
204 | 35 | lsb_information=info) | 35 | lsb_information=info) |
205 | 36 | 36 | ||
206 | 37 | def test_pkg_name(self): | 37 | def test_pkg_name(self): |
Looks good.
Thanks,
James