Merge lp:~pwlars/lava-test/hwsw into lp:lava-test/0.0

Proposed by Paul Larson
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
Reviewer Review Type Date Requested Status
James Westby (community) Approve
Review via email: mp+32229@code.launchpad.net

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.
Revision history for this message
James Westby (james-w) wrote :

Looks good.

Thanks,

James

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'abrek/swprofile.py'
--- abrek/swprofile.py 2010-08-04 17:29:48 +0000
+++ abrek/swprofile.py 2010-08-10 17:31:01 +0000
@@ -19,8 +19,7 @@
19 packages.append(pkg)19 packages.append(pkg)
20 return packages20 return packages
2121
22def get_sw_context(test_id, time_check=False, apt_cache=None,22def get_sw_context(apt_cache=None, lsb_information=None):
23 lsb_information=None):
24 """ Return dict used for storing sw_context information23 """ Return dict used for storing sw_context information
2524
26 test_id - Unique identifier for this test25 test_id - Unique identifier for this test
@@ -32,8 +31,6 @@
32 sw_context = {}31 sw_context = {}
33 sw_context['sw_image'] = get_sw_image(lsb_information)32 sw_context['sw_image'] = get_sw_image(lsb_information)
34 sw_context['packages'] = get_packages(apt_cache)33 sw_context['packages'] = get_packages(apt_cache)
35 sw_context['time_check_performed'] = time_check
36 sw_context['test_id'] = test_id
37 return sw_context34 return sw_context
3835
39def get_sw_image(lsb_information=None):36def get_sw_image(lsb_information=None):
4037
=== modified file 'abrek/test_definitions/stream.py'
--- abrek/test_definitions/stream.py 2010-07-26 14:20:59 +0000
+++ abrek/test_definitions/stream.py 2010-08-10 17:31:01 +0000
@@ -4,11 +4,11 @@
4MD5="b6cd43b848e0d8b0824703369392f3c5"4MD5="b6cd43b848e0d8b0824703369392f3c5"
5INSTALLSTEPS = ['cc stream.c -O2 -fopenmp -o stream']5INSTALLSTEPS = ['cc stream.c -O2 -fopenmp -o stream']
6RUNSTEPS = ['./stream']6RUNSTEPS = ['./stream']
7PATTERN = "^(?P<testid>\w+):\W+(?P<result>\d+\.\d+)"7PATTERN = "^(?P<test_case_id>\w+):\W+(?P<measurement>\d+\.\d+)"
88
9streaminst = abrek.testdef.AbrekTestInstaller(INSTALLSTEPS, url=URL, md5=MD5)9streaminst = abrek.testdef.AbrekTestInstaller(INSTALLSTEPS, url=URL, md5=MD5)
10streamrun = abrek.testdef.AbrekTestRunner(RUNSTEPS)10streamrun = abrek.testdef.AbrekTestRunner(RUNSTEPS)
11streamparser = abrek.testdef.AbrekTestParser(PATTERN,11streamparser = abrek.testdef.AbrekTestParser(PATTERN,
12 appendall={'units':'MB/s'})12 appendall={'units':'MB/s', 'result':'pass'})
13testobj = abrek.testdef.AbrekTest(testname="stream", installer=streaminst,13testobj = abrek.testdef.AbrekTest(testname="stream", installer=streaminst,
14 runner=streamrun, parser=streamparser)14 runner=streamrun, parser=streamparser)
1515
=== modified file 'abrek/testdef.py'
--- abrek/testdef.py 2010-07-26 14:20:59 +0000
+++ abrek/testdef.py 2010-08-10 17:31:01 +0000
@@ -7,9 +7,12 @@
7import time7import time
8from commands import getstatusoutput8from commands import getstatusoutput
9from datetime import datetime9from datetime import datetime
10from uuid import uuid1
1011
11from abrek.config import get_config12from abrek.config import get_config
12from abrek.utils import geturl, write_file13from abrek.utils import geturl, write_file
14from abrek import hwprofile
15from abrek import swprofile
1316
14class AbrekTest(object):17class AbrekTest(object):
15 """Base class for defining tests.18 """Base class for defining tests.
@@ -72,12 +75,18 @@
72 shutil.rmtree(path)75 shutil.rmtree(path)
7376
74 def _savetestdata(self):77 def _savetestdata(self):
78 TIMEFORMAT = '%Y-%m-%dT%H:%M:%SZ'
75 testdata = {}79 testdata = {}
76 filename = os.path.join(self.resultsdir, 'testdata.json')80 filename = os.path.join(self.resultsdir, 'testdata.json')
77 testdata['testname'] = self.testname81 testdata['test_id'] = self.testname
78 testdata['version'] = self.version82 testdata['analyzer_assigned_uuid'] = str(uuid1())
79 testdata['starttime'] = time.mktime(self.runner.starttime.timetuple())83 testdata['time_check_performed'] = False
80 testdata['endtime'] = time.mktime(self.runner.endtime.timetuple())84 testdata['analyzer_assigned_date'] = datetime.strftime(
85 self.runner.starttime,TIMEFORMAT)
86 hw = hwprofile.get_hw_context()
87 testdata['hw_context'] = hw
88 sw = swprofile.get_sw_context()
89 testdata['sw_context'] = sw
81 write_file(json.dumps(testdata), filename)90 write_file(json.dumps(testdata), filename)
8291
83 def run(self):92 def run(self):
@@ -199,27 +208,27 @@
199 "test01: PASS", then you could use a pattern like this:208 "test01: PASS", then you could use a pattern like this:
200 "^(?P<testid>\w+):\W+(?P<result>\w+)"209 "^(?P<testid>\w+):\W+(?P<result>\w+)"
201 This would result in identifying "test01" as testid and "PASS"210 This would result in identifying "test01" as testid and "PASS"
202 as result. Once parse() has been called, self.results.testlist[]211 as result. Once parse() has been called, self.results.test_results[]
203 contains a list of dicts of all the key,value pairs found for212 contains a list of dicts of all the key,value pairs found for
204 each test result213 each test result
205 fixupdict - dict of strings to convert test results to standard strings214 fixupdict - dict of strings to convert test results to standard strings
206 For example: if you want to standardize on having pass/fail results215 For example: if you want to standardize on having pass/fail results
207 in lower case, but your test outputs them in upper case, you could216 in lower case, but your test outputs them in upper case, you could
208 use a fixupdict of something like: {'PASS':'pass','FAIL':'fail'}217 use a fixupdict of something like: {'PASS':'pass','FAIL':'fail'}
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.
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:
211 appendall={'units':'MB/s'}220 appendall={'units':'MB/s'}
212 """221 """
213 def __init__(self, pattern=None, fixupdict=None, appendall={}):222 def __init__(self, pattern=None, fixupdict=None, appendall={}):
214 self.pattern = pattern223 self.pattern = pattern
215 self.fixupdict = fixupdict224 self.fixupdict = fixupdict
216 self.results = {'testlist':[]}225 self.results = {'test_results':[]}
217 self.appendall = appendall226 self.appendall = appendall
218227
219 def _find_testid(self, id):228 def _find_testid(self, id):
220 for x in self.results['testlist']:229 for x in self.results['test_results']:
221 if x['testid'] == id:230 if x['testid'] == id:
222 return self.results['testlist'].index(x)231 return self.results['test_results'].index(x)
223232
224 def parse(self):233 def parse(self):
225 """Parse test output to gather results234 """Parse test output to gather results
@@ -235,27 +244,27 @@
235 for line in fd.readlines():244 for line in fd.readlines():
236 match = pat.search(line)245 match = pat.search(line)
237 if match:246 if match:
238 self.results['testlist'].append(match.groupdict())247 self.results['test_results'].append(match.groupdict())
239 if self.fixupdict:248 if self.fixupdict:
240 self.fixresults(self.fixupdict)249 self.fixresults(self.fixupdict)
241 if self.appendall:250 if self.appendall:
242 self.appendtoall(self.appendall)251 self.appendtoall(self.appendall)
243252
244 def append(self, testid, entry):253 def append(self, testid, entry):
245 """Appends a dict to the testlist entry for a specified testid254 """Appends a dict to the test_results entry for a specified testid
246255
247 This lets you add a dict to the entry for a specific testid256 This lets you add a dict to the entry for a specific testid
248 entry should be a dict, updates it in place257 entry should be a dict, updates it in place
249 """258 """
250 index = self._find_testid(testid)259 index = self._find_testid(testid)
251 self.results['testlist'][index].update(entry)260 self.results['test_results'][index].update(entry)
252261
253 def appendtoall(self, entry):262 def appendtoall(self, entry):
254 """Append entry to each item in the testlist.263 """Append entry to each item in the test_results.
255264
256 entry - dict of key,value pairs to add to each item in the testlist265 entry - dict of key,value pairs to add to each item in the test_results
257 """266 """
258 for t in self.results['testlist']:267 for t in self.results['test_results']:
259 t.update(entry)268 t.update(entry)
260269
261 def fixresults(self, fixupdict):270 def fixresults(self, fixupdict):
@@ -266,7 +275,7 @@
266 {"TPASS":"pass", "TFAIL":"fail"}275 {"TPASS":"pass", "TFAIL":"fail"}
267 This is really only used for qualitative tests276 This is really only used for qualitative tests
268 """277 """
269 for t in self.results['testlist']:278 for t in self.results['test_results']:
270 if t.has_key("result"):279 if t.has_key("result"):
271 t['result'] = fixupdict[t['result']]280 t['result'] = fixupdict[t['result']]
272281
273282
=== modified file 'tests/test_abrektestparser.py'
--- tests/test_abrektestparser.py 2010-07-22 14:49:49 +0000
+++ tests/test_abrektestparser.py 2010-08-10 17:31:01 +0000
@@ -28,8 +28,8 @@
28 self.writeoutputlog("test001: pass")28 self.writeoutputlog("test001: pass")
29 parser = self.makeparser(pattern)29 parser = self.makeparser(pattern)
30 parser.parse()30 parser.parse()
31 self.assertTrue(parser.results["testlist"][0]["testid"] == "test001" and31 self.assertTrue(parser.results["test_results"][0]["testid"] == "test001" and
32 parser.results["testlist"][0]["result"] == "pass")32 parser.results["test_results"][0]["result"] == "pass")
3333
34 def test_fixupdict(self):34 def test_fixupdict(self):
35 pattern = "^(?P<testid>\w+):\W+(?P<result>\w+)"35 pattern = "^(?P<testid>\w+):\W+(?P<result>\w+)"
@@ -37,7 +37,7 @@
37 self.writeoutputlog("test001: pass")37 self.writeoutputlog("test001: pass")
38 parser = self.makeparser(pattern, fixupdict=fixup)38 parser = self.makeparser(pattern, fixupdict=fixup)
39 parser.parse()39 parser.parse()
40 self.assertEquals("PASS", parser.results["testlist"][0]["result"])40 self.assertEquals("PASS", parser.results["test_results"][0]["result"])
4141
42 def test_appendall(self):42 def test_appendall(self):
43 pattern = "^(?P<testid>\w+):\W+(?P<result>\w+)"43 pattern = "^(?P<testid>\w+):\W+(?P<result>\w+)"
@@ -45,5 +45,5 @@
45 self.writeoutputlog("test001: pass")45 self.writeoutputlog("test001: pass")
46 parser = self.makeparser(pattern, appendall=append)46 parser = self.makeparser(pattern, appendall=append)
47 parser.parse()47 parser.parse()
48 self.assertEqual("foo/s", parser.results["testlist"][0]["units"])48 self.assertEqual("foo/s", parser.results["test_results"][0]["units"])
4949
5050
=== modified file 'tests/test_swprofile.py'
--- tests/test_swprofile.py 2010-08-04 17:29:48 +0000
+++ tests/test_swprofile.py 2010-08-10 17:31:01 +0000
@@ -26,12 +26,12 @@
26 self.testpackage = Package('testpkg', '7.77')26 self.testpackage = Package('testpkg', '7.77')
27 self.cache = AptCache([self.testpackage])27 self.cache = AptCache([self.testpackage])
2828
29 def make_profile(self, test_id='unit', cache=None, info=None):29 def make_profile(self, cache=None, info=None):
30 if cache == None:30 if cache == None:
31 cache = self.cache31 cache = self.cache
32 if info == None:32 if info == None:
33 info = self.lsb_information33 info = self.lsb_information
34 return abrek.swprofile.get_sw_context(test_id, apt_cache=cache,34 return abrek.swprofile.get_sw_context(apt_cache=cache,
35 lsb_information=info)35 lsb_information=info)
3636
37 def test_pkg_name(self):37 def test_pkg_name(self):

Subscribers

People subscribed via source and target branches