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
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 packages.append(pkg)
6 return packages
7
8-def get_sw_context(test_id, time_check=False, apt_cache=None,
9- lsb_information=None):
10+def get_sw_context(apt_cache=None, lsb_information=None):
11 """ Return dict used for storing sw_context information
12
13 test_id - Unique identifier for this test
14@@ -32,8 +31,6 @@
15 sw_context = {}
16 sw_context['sw_image'] = get_sw_image(lsb_information)
17 sw_context['packages'] = get_packages(apt_cache)
18- sw_context['time_check_performed'] = time_check
19- sw_context['test_id'] = test_id
20 return sw_context
21
22 def get_sw_image(lsb_information=None):
23
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 MD5="b6cd43b848e0d8b0824703369392f3c5"
29 INSTALLSTEPS = ['cc stream.c -O2 -fopenmp -o stream']
30 RUNSTEPS = ['./stream']
31-PATTERN = "^(?P<testid>\w+):\W+(?P<result>\d+\.\d+)"
32+PATTERN = "^(?P<test_case_id>\w+):\W+(?P<measurement>\d+\.\d+)"
33
34 streaminst = abrek.testdef.AbrekTestInstaller(INSTALLSTEPS, url=URL, md5=MD5)
35 streamrun = abrek.testdef.AbrekTestRunner(RUNSTEPS)
36 streamparser = abrek.testdef.AbrekTestParser(PATTERN,
37- appendall={'units':'MB/s'})
38+ appendall={'units':'MB/s', 'result':'pass'})
39 testobj = abrek.testdef.AbrekTest(testname="stream", installer=streaminst,
40 runner=streamrun, parser=streamparser)
41
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 import time
47 from commands import getstatusoutput
48 from datetime import datetime
49+from uuid import uuid1
50
51 from abrek.config import get_config
52 from abrek.utils import geturl, write_file
53+from abrek import hwprofile
54+from abrek import swprofile
55
56 class AbrekTest(object):
57 """Base class for defining tests.
58@@ -72,12 +75,18 @@
59 shutil.rmtree(path)
60
61 def _savetestdata(self):
62+ TIMEFORMAT = '%Y-%m-%dT%H:%M:%SZ'
63 testdata = {}
64 filename = os.path.join(self.resultsdir, 'testdata.json')
65- testdata['testname'] = self.testname
66- testdata['version'] = self.version
67- testdata['starttime'] = time.mktime(self.runner.starttime.timetuple())
68- testdata['endtime'] = time.mktime(self.runner.endtime.timetuple())
69+ testdata['test_id'] = self.testname
70+ testdata['analyzer_assigned_uuid'] = str(uuid1())
71+ testdata['time_check_performed'] = False
72+ testdata['analyzer_assigned_date'] = datetime.strftime(
73+ self.runner.starttime,TIMEFORMAT)
74+ hw = hwprofile.get_hw_context()
75+ testdata['hw_context'] = hw
76+ sw = swprofile.get_sw_context()
77+ testdata['sw_context'] = sw
78 write_file(json.dumps(testdata), filename)
79
80 def run(self):
81@@ -199,27 +208,27 @@
82 "test01: PASS", then you could use a pattern like this:
83 "^(?P<testid>\w+):\W+(?P<result>\w+)"
84 This would result in identifying "test01" as testid and "PASS"
85- as result. Once parse() has been called, self.results.testlist[]
86+ as result. Once parse() has been called, self.results.test_results[]
87 contains a list of dicts of all the key,value pairs found for
88 each test result
89 fixupdict - dict of strings to convert test results to standard strings
90 For example: if you want to standardize on having pass/fail results
91 in lower case, but your test outputs them in upper case, you could
92 use a fixupdict of something like: {'PASS':'pass','FAIL':'fail'}
93- appendall - Append a dict to the testlist entry for each result.
94+ appendall - Append a dict to the test_results entry for each result.
95 For example: if you would like to add units="MB/s" to each result:
96 appendall={'units':'MB/s'}
97 """
98 def __init__(self, pattern=None, fixupdict=None, appendall={}):
99 self.pattern = pattern
100 self.fixupdict = fixupdict
101- self.results = {'testlist':[]}
102+ self.results = {'test_results':[]}
103 self.appendall = appendall
104
105 def _find_testid(self, id):
106- for x in self.results['testlist']:
107+ for x in self.results['test_results']:
108 if x['testid'] == id:
109- return self.results['testlist'].index(x)
110+ return self.results['test_results'].index(x)
111
112 def parse(self):
113 """Parse test output to gather results
114@@ -235,27 +244,27 @@
115 for line in fd.readlines():
116 match = pat.search(line)
117 if match:
118- self.results['testlist'].append(match.groupdict())
119+ self.results['test_results'].append(match.groupdict())
120 if self.fixupdict:
121 self.fixresults(self.fixupdict)
122 if self.appendall:
123 self.appendtoall(self.appendall)
124
125 def append(self, testid, entry):
126- """Appends a dict to the testlist entry for a specified testid
127+ """Appends a dict to the test_results entry for a specified testid
128
129 This lets you add a dict to the entry for a specific testid
130 entry should be a dict, updates it in place
131 """
132 index = self._find_testid(testid)
133- self.results['testlist'][index].update(entry)
134+ self.results['test_results'][index].update(entry)
135
136 def appendtoall(self, entry):
137- """Append entry to each item in the testlist.
138+ """Append entry to each item in the test_results.
139
140- entry - dict of key,value pairs to add to each item in the testlist
141+ entry - dict of key,value pairs to add to each item in the test_results
142 """
143- for t in self.results['testlist']:
144+ for t in self.results['test_results']:
145 t.update(entry)
146
147 def fixresults(self, fixupdict):
148@@ -266,7 +275,7 @@
149 {"TPASS":"pass", "TFAIL":"fail"}
150 This is really only used for qualitative tests
151 """
152- for t in self.results['testlist']:
153+ for t in self.results['test_results']:
154 if t.has_key("result"):
155 t['result'] = fixupdict[t['result']]
156
157
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 self.writeoutputlog("test001: pass")
163 parser = self.makeparser(pattern)
164 parser.parse()
165- self.assertTrue(parser.results["testlist"][0]["testid"] == "test001" and
166- parser.results["testlist"][0]["result"] == "pass")
167+ self.assertTrue(parser.results["test_results"][0]["testid"] == "test001" and
168+ parser.results["test_results"][0]["result"] == "pass")
169
170 def test_fixupdict(self):
171 pattern = "^(?P<testid>\w+):\W+(?P<result>\w+)"
172@@ -37,7 +37,7 @@
173 self.writeoutputlog("test001: pass")
174 parser = self.makeparser(pattern, fixupdict=fixup)
175 parser.parse()
176- self.assertEquals("PASS", parser.results["testlist"][0]["result"])
177+ self.assertEquals("PASS", parser.results["test_results"][0]["result"])
178
179 def test_appendall(self):
180 pattern = "^(?P<testid>\w+):\W+(?P<result>\w+)"
181@@ -45,5 +45,5 @@
182 self.writeoutputlog("test001: pass")
183 parser = self.makeparser(pattern, appendall=append)
184 parser.parse()
185- self.assertEqual("foo/s", parser.results["testlist"][0]["units"])
186+ self.assertEqual("foo/s", parser.results["test_results"][0]["units"])
187
188
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 self.testpackage = Package('testpkg', '7.77')
194 self.cache = AptCache([self.testpackage])
195
196- def make_profile(self, test_id='unit', cache=None, info=None):
197+ def make_profile(self, cache=None, info=None):
198 if cache == None:
199 cache = self.cache
200 if info == None:
201 info = self.lsb_information
202- return abrek.swprofile.get_sw_context(test_id, apt_cache=cache,
203+ return abrek.swprofile.get_sw_context(apt_cache=cache,
204 lsb_information=info)
205
206 def test_pkg_name(self):

Subscribers

People subscribed via source and target branches