Merge lp:~jibel/update-manager/AutoUpgradeTester-junitxml into lp:update-manager

Proposed by Jean-Baptiste Lallement
Status: Merged
Merged at revision: 2293
Proposed branch: lp:~jibel/update-manager/AutoUpgradeTester-junitxml
Merge into: lp:update-manager
Diff against target: 340 lines (+90/-11)
23 files modified
AutoUpgradeTester/UpgradeTestBackend.py (+50/-2)
AutoUpgradeTester/UpgradeTestBackendQemu.py (+2/-2)
AutoUpgradeTester/UpgradeTestBackendSSH.py (+13/-2)
AutoUpgradeTester/profile/lts-main-all/DistUpgrade.cfg (+1/-0)
AutoUpgradeTester/profile/lts-server-amd64/pkgs.cfg (+2/-1)
AutoUpgradeTester/profile/lts-server-tasks/pkgs.cfg (+2/-1)
AutoUpgradeTester/profile/lts-server/pkgs.cfg (+2/-1)
AutoUpgradeTester/profile/lts-ubuntu-amd64/DistUpgrade.cfg (+1/-0)
AutoUpgradeTester/profile/lts-ubuntu-amd64/pkgs.cfg (+2/-1)
AutoUpgradeTester/profile/lts-ubuntu/DistUpgrade.cfg (+1/-0)
AutoUpgradeTester/profile/main-all-amd64/DistUpgrade.cfg (+1/-0)
AutoUpgradeTester/profile/main-all-amd64/pkgs.cfg (+1/-0)
AutoUpgradeTester/profile/main-all/DistUpgrade.cfg (+1/-0)
AutoUpgradeTester/profile/main-all/pkgs.cfg (+1/-0)
AutoUpgradeTester/profile/python-all/DistUpgrade.cfg (+1/-0)
AutoUpgradeTester/profile/python-all/pkgs.cfg (+1/-0)
AutoUpgradeTester/profile/server-amd64/pkgs.cfg (+1/-0)
AutoUpgradeTester/profile/server-tasks/pkgs.cfg (+2/-1)
AutoUpgradeTester/profile/server/pkgs.cfg (+1/-0)
AutoUpgradeTester/profile/ubuntu-amd64/DistUpgrade.cfg (+1/-0)
AutoUpgradeTester/profile/ubuntu-amd64/pkgs.cfg (+1/-0)
AutoUpgradeTester/profile/ubuntu/DistUpgrade.cfg (+1/-0)
AutoUpgradeTester/profile/ubuntu/pkgs.cfg (+1/-0)
To merge this branch: bzr merge lp:~jibel/update-manager/AutoUpgradeTester-junitxml
Reviewer Review Type Date Requested Status
Michael Vogt (community) Approve
Review via email: mp+85346@code.launchpad.net

Description of the change

This merge request includes the following changes:
- replace grub by grub-pc
- generate junit xml result file
- start run with a clean result directory to avoid mixing results between runs.

To post a comment you must log in.
Revision history for this message
Michael Vogt (mvo) wrote :

Looks great, thanks a bunch!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'AutoUpgradeTester/UpgradeTestBackend.py'
2--- AutoUpgradeTester/UpgradeTestBackend.py 2011-11-07 12:20:29 +0000
3+++ AutoUpgradeTester/UpgradeTestBackend.py 2011-12-12 14:49:25 +0000
4@@ -9,6 +9,7 @@
5 import os
6 import os.path
7 import tempfile
8+from shutil import rmtree
9
10 # refactor the code so that we have
11 # UpgradeTest - the controler object
12@@ -65,8 +66,11 @@
13 "NonInteractive", "ResultDir", "results-upgrade-tester")
14 self.resultdir = os.path.abspath(
15 os.path.join(base_resultdir, profiledir.split("/")[-1]))
16- if not os.path.exists(self.resultdir):
17- os.makedirs(self.resultdir)
18+
19+ # Cleanup result directory before new run
20+ if os.path.exists(self.resultdir):
21+ rmtree(self.resultdir)
22+ os.makedirs(self.resultdir)
23
24 self.fromDist = self.config.get("Sources","From")
25 if "http_proxy" in os.environ and not self.config.has_option("NonInteractive","Proxy"):
26@@ -117,3 +121,47 @@
27 def test(self):
28 " test if the upgrade was successful "
29 pass
30+
31+ def resultsToJunitXML(self, results, outputfile = None):
32+ """
33+ Filter results to get Junit XML output
34+
35+ :param results: list of results. Each result is a dictionary of the form
36+ name: name of the test
37+ result: (pass, fail, error)
38+ time: execution time of the test in seconds
39+ message: optional message in case of failure or error
40+ :param output: Output XML to this file instead of returning the value
41+ """
42+ from xml.sax.saxutils import escape
43+
44+ output = ""
45+ testsuite_name = ''
46+ res = [x['result'] for x in results]
47+ pass_count = res.count('pass')
48+ fail_count = res.count('fail')
49+ error_count = res.count('error')
50+ total_count = len(res)
51+ total_time = sum([x['time'] for x in results])
52+
53+ output = """<testsuite errors="%d" failures="%d" name="%s" tests="%d" time="%.3f">\n""" % (
54+ error_count, fail_count, testsuite_name, total_count,total_time)
55+
56+ for result in results:
57+ output += """<testcase classname="%s" name="%s" time="%.3f">\n""" % (
58+ self.profilename, result['name'], result['time'])
59+ if 'fail' in result['result']:
60+ output += """<failure type="%s">%s\n</failure>\n""" % (
61+ 'exception', escape(result['message']))
62+ elif 'error' in result['result']:
63+ output += """<error type="%s">%s\n</error>\n""" % (
64+ 'exception', escape(result['message']))
65+
66+ output += "</testcase>\n"
67+ output += "</testsuite>\n"
68+
69+ if outputfile:
70+ with open(outputfile, 'w') as f:
71+ f.write(output)
72+ else:
73+ return output
74
75=== modified file 'AutoUpgradeTester/UpgradeTestBackendQemu.py'
76--- AutoUpgradeTester/UpgradeTestBackendQemu.py 2011-11-08 09:36:44 +0000
77+++ AutoUpgradeTester/UpgradeTestBackendQemu.py 2011-12-12 14:49:25 +0000
78@@ -102,9 +102,9 @@
79 self.qemu_options.append("-hdb")
80 self.qemu_options.append(self.config.get("KVM","SwapImage"))
81 # regular image
82- profilename = self.config.get("NonInteractive","ProfileName")
83+ self.profilename = self.config.get("NonInteractive","ProfileName")
84 imagedir = self.config.get("KVM","ImageDir")
85- self.image = os.path.join(imagedir, "test-image.%s" % profilename)
86+ self.image = os.path.join(imagedir, "test-image.%s" % self.profilename)
87 # make ssh login possible (localhost 54321) available
88 ssh_port = int(self.config.getWithDefault("KVM","SshPort","54321"))
89 while is_port_already_listening(ssh_port):
90
91=== modified file 'AutoUpgradeTester/UpgradeTestBackendSSH.py'
92--- AutoUpgradeTester/UpgradeTestBackendSSH.py 2011-11-07 14:29:56 +0000
93+++ AutoUpgradeTester/UpgradeTestBackendSSH.py 2011-12-12 14:49:25 +0000
94@@ -7,6 +7,7 @@
95 import os
96 import os.path
97 import subprocess
98+import time
99
100
101 class UpgradeTestBackendSSH(UpgradeTestBackend):
102@@ -170,7 +171,6 @@
103 upgrader_args)])
104 return ret
105
106-
107 def test(self):
108 # - generate diff of upgrade vs fresh install
109 # ...
110@@ -181,9 +181,16 @@
111 crashfiles = glob.glob(self.resultdir+"/*.crash")
112 # run stuff in post_upgrade_tests dir
113 ok = True
114+ results = []
115 for script in glob.glob(self.post_upgrade_tests_dir+"*"):
116 if not os.access(script, os.X_OK):
117 continue
118+ result = {'name':os.path.basename(script),
119+ 'result':'pass',
120+ 'time':0,
121+ 'message':''
122+ }
123+ start_time = time.time()
124 logging.info("running '%s' post_upgrade_test" % script)
125 self._copyToImage(script, "/tmp/")
126 ret = self._runInImage(["/tmp/%s" % os.path.basename(script)])
127@@ -192,9 +199,14 @@
128 ok = False
129 log=open(self.resultdir+"/test-%s.FAIL" % os.path.basename(script), "w")
130 log.write("FAIL")
131+ result['result'] = 'fail'
132+ result['message'] = "post_upgrade_test '%s' failed" % script
133+ result['time'] = time.time() - start_time
134+ results.append(result)
135
136 # check for conffiles (the copy is done via a post upgrade script)
137 self._copyFromImage("/tmp/*.dpkg-dist", self.resultdir)
138+ self.resultsToJunitXML(results, os.path.join(self.resultdir, 'results.xml'))
139
140 self.stop()
141 if len(crashfiles) > 0:
142@@ -202,4 +214,3 @@
143 print crashfiles
144 return False
145 return ok
146-
147
148=== modified file 'AutoUpgradeTester/profile/lts-main-all/DistUpgrade.cfg'
149--- AutoUpgradeTester/profile/lts-main-all/DistUpgrade.cfg 2011-11-07 14:29:56 +0000
150+++ AutoUpgradeTester/profile/lts-main-all/DistUpgrade.cfg 2011-12-12 14:49:25 +0000
151@@ -3,5 +3,6 @@
152
153 [NonInteractive]
154 ProfileName = lts-main-all
155+AdditionalPkgs = pkgs.cfg
156 PostBootstrapScript=/usr/share/pyshared/AutoUpgradeTester/install_all.py
157
158
159=== modified file 'AutoUpgradeTester/profile/lts-server-amd64/pkgs.cfg'
160--- AutoUpgradeTester/profile/lts-server-amd64/pkgs.cfg 2011-12-03 23:30:58 +0000
161+++ AutoUpgradeTester/profile/lts-server-amd64/pkgs.cfg 2011-12-12 14:49:25 +0000
162@@ -1,2 +1,3 @@
163+grub-pc
164 python-apt
165-python-gnupginterface
166\ No newline at end of file
167+python-gnupginterface
168
169=== modified file 'AutoUpgradeTester/profile/lts-server-tasks/pkgs.cfg'
170--- AutoUpgradeTester/profile/lts-server-tasks/pkgs.cfg 2010-04-01 14:30:42 +0000
171+++ AutoUpgradeTester/profile/lts-server-tasks/pkgs.cfg 2011-12-12 14:49:25 +0000
172@@ -1,3 +1,4 @@
173+grub-pc
174 python-apt
175 python-gnupginterface
176 dns-server^
177@@ -6,4 +7,4 @@
178 openssh-server^
179 postgresql-server^
180 print-server^
181-samba-server^
182\ No newline at end of file
183+samba-server^
184
185=== modified file 'AutoUpgradeTester/profile/lts-server/pkgs.cfg'
186--- AutoUpgradeTester/profile/lts-server/pkgs.cfg 2007-11-30 13:41:59 +0000
187+++ AutoUpgradeTester/profile/lts-server/pkgs.cfg 2011-12-12 14:49:25 +0000
188@@ -1,2 +1,3 @@
189+grub-pc
190 python-apt
191-python-gnupginterface
192\ No newline at end of file
193+python-gnupginterface
194
195=== modified file 'AutoUpgradeTester/profile/lts-ubuntu-amd64/DistUpgrade.cfg'
196--- AutoUpgradeTester/profile/lts-ubuntu-amd64/DistUpgrade.cfg 2011-12-03 23:30:58 +0000
197+++ AutoUpgradeTester/profile/lts-ubuntu-amd64/DistUpgrade.cfg 2011-12-12 14:49:25 +0000
198@@ -4,6 +4,7 @@
199 [NonInteractive]
200 ProfileName=lts-ubuntu-amd64
201 BasePkg = ubuntu-desktop
202+AdditionalPkgs = pkgs.cfg
203
204 [KVM]
205 Arch=amd64
206
207=== modified file 'AutoUpgradeTester/profile/lts-ubuntu-amd64/pkgs.cfg'
208--- AutoUpgradeTester/profile/lts-ubuntu-amd64/pkgs.cfg 2011-12-03 23:30:58 +0000
209+++ AutoUpgradeTester/profile/lts-ubuntu-amd64/pkgs.cfg 2011-12-12 14:49:25 +0000
210@@ -1,2 +1,3 @@
211 ubuntu-minimal
212-ubuntu-standard
213\ No newline at end of file
214+ubuntu-standard
215+grub-pc
216
217=== modified file 'AutoUpgradeTester/profile/lts-ubuntu/DistUpgrade.cfg'
218--- AutoUpgradeTester/profile/lts-ubuntu/DistUpgrade.cfg 2011-12-06 14:48:44 +0000
219+++ AutoUpgradeTester/profile/lts-ubuntu/DistUpgrade.cfg 2011-12-12 14:49:25 +0000
220@@ -4,4 +4,5 @@
221 [NonInteractive]
222 ProfileName=lts-ubuntu
223 BasePkg = ubuntu-desktop
224+AdditionalPkgs = pkgs.cfg
225 ;UseUpgraderFromBzr=true
226
227=== modified file 'AutoUpgradeTester/profile/main-all-amd64/DistUpgrade.cfg'
228--- AutoUpgradeTester/profile/main-all-amd64/DistUpgrade.cfg 2011-12-03 23:30:58 +0000
229+++ AutoUpgradeTester/profile/main-all-amd64/DistUpgrade.cfg 2011-12-12 14:49:25 +0000
230@@ -1,5 +1,6 @@
231 [NonInteractive]
232 ProfileName = main-all-amd64
233+AdditionalPkgs = pkgs.cfg
234 PostBootstrapScript=/usr/share/pyshared/AutoUpgradeTester/install_all.py
235
236 [KVM]
237
238=== modified file 'AutoUpgradeTester/profile/main-all-amd64/pkgs.cfg'
239--- AutoUpgradeTester/profile/main-all-amd64/pkgs.cfg 2011-12-03 23:30:58 +0000
240+++ AutoUpgradeTester/profile/main-all-amd64/pkgs.cfg 2011-12-12 14:49:25 +0000
241@@ -1,1 +1,2 @@
242 python-apt
243+grub-pc
244
245=== modified file 'AutoUpgradeTester/profile/main-all/DistUpgrade.cfg'
246--- AutoUpgradeTester/profile/main-all/DistUpgrade.cfg 2011-11-07 13:29:55 +0000
247+++ AutoUpgradeTester/profile/main-all/DistUpgrade.cfg 2011-12-12 14:49:25 +0000
248@@ -1,3 +1,4 @@
249 [NonInteractive]
250 ProfileName = main-all
251+AdditionalPkgs = pkgs.cfg
252 PostBootstrapScript=/usr/share/pyshared/AutoUpgradeTester/install_all.py
253
254=== modified file 'AutoUpgradeTester/profile/main-all/pkgs.cfg'
255--- AutoUpgradeTester/profile/main-all/pkgs.cfg 2006-11-28 12:22:01 +0000
256+++ AutoUpgradeTester/profile/main-all/pkgs.cfg 2011-12-12 14:49:25 +0000
257@@ -1,1 +1,2 @@
258+grub-pc
259 python-apt
260
261=== modified file 'AutoUpgradeTester/profile/python-all/DistUpgrade.cfg'
262--- AutoUpgradeTester/profile/python-all/DistUpgrade.cfg 2011-11-07 13:29:55 +0000
263+++ AutoUpgradeTester/profile/python-all/DistUpgrade.cfg 2011-12-12 14:49:25 +0000
264@@ -1,5 +1,6 @@
265 [NonInteractive]
266 ProfileName=python-all
267 BasePkg = ubuntu-standard
268+AdditionalPkgs = pkgs.cfg
269 PostBootstrapScript=/usr/share/pyshared/AutoUpgradeTester/install_all-python.py
270
271
272=== modified file 'AutoUpgradeTester/profile/python-all/pkgs.cfg'
273--- AutoUpgradeTester/profile/python-all/pkgs.cfg 2011-03-17 07:55:37 +0000
274+++ AutoUpgradeTester/profile/python-all/pkgs.cfg 2011-12-12 14:49:25 +0000
275@@ -1,1 +1,2 @@
276+grub-pc
277 python-apt
278
279=== modified file 'AutoUpgradeTester/profile/server-amd64/pkgs.cfg'
280--- AutoUpgradeTester/profile/server-amd64/pkgs.cfg 2011-11-07 12:20:29 +0000
281+++ AutoUpgradeTester/profile/server-amd64/pkgs.cfg 2011-12-12 14:49:25 +0000
282@@ -1,1 +1,2 @@
283+grub-pc
284 python-apt
285
286=== modified file 'AutoUpgradeTester/profile/server-tasks/pkgs.cfg'
287--- AutoUpgradeTester/profile/server-tasks/pkgs.cfg 2010-04-01 15:22:10 +0000
288+++ AutoUpgradeTester/profile/server-tasks/pkgs.cfg 2011-12-12 14:49:25 +0000
289@@ -1,3 +1,4 @@
290+grub-pc
291 python-apt
292 python-gnupginterface
293 dns-server^
294@@ -6,4 +7,4 @@
295 openssh-server^
296 postgresql-server^
297 print-server^
298-samba-server^
299\ No newline at end of file
300+samba-server^
301
302=== modified file 'AutoUpgradeTester/profile/server/pkgs.cfg'
303--- AutoUpgradeTester/profile/server/pkgs.cfg 2009-06-26 20:10:00 +0000
304+++ AutoUpgradeTester/profile/server/pkgs.cfg 2011-12-12 14:49:25 +0000
305@@ -1,1 +1,2 @@
306+grub-pc
307 python-apt
308
309=== modified file 'AutoUpgradeTester/profile/ubuntu-amd64/DistUpgrade.cfg'
310--- AutoUpgradeTester/profile/ubuntu-amd64/DistUpgrade.cfg 2011-12-03 23:30:58 +0000
311+++ AutoUpgradeTester/profile/ubuntu-amd64/DistUpgrade.cfg 2011-12-12 14:49:25 +0000
312@@ -1,6 +1,7 @@
313 [NonInteractive]
314 ProfileName = ubuntu-amd64
315 BasePkg = ubuntu-desktop
316+AdditionalPkgs = pkgs.cfg
317
318 [KVM]
319 Arch=amd64
320
321=== added file 'AutoUpgradeTester/profile/ubuntu-amd64/pkgs.cfg'
322--- AutoUpgradeTester/profile/ubuntu-amd64/pkgs.cfg 1970-01-01 00:00:00 +0000
323+++ AutoUpgradeTester/profile/ubuntu-amd64/pkgs.cfg 2011-12-12 14:49:25 +0000
324@@ -0,0 +1,1 @@
325+grub-pc
326
327=== modified file 'AutoUpgradeTester/profile/ubuntu/DistUpgrade.cfg'
328--- AutoUpgradeTester/profile/ubuntu/DistUpgrade.cfg 2011-11-07 13:29:55 +0000
329+++ AutoUpgradeTester/profile/ubuntu/DistUpgrade.cfg 2011-12-12 14:49:25 +0000
330@@ -1,3 +1,4 @@
331 [NonInteractive]
332 ProfileName = ubuntu
333 BasePkg = ubuntu-desktop
334+AdditionalPkgs = pkgs.cfg
335
336=== added file 'AutoUpgradeTester/profile/ubuntu/pkgs.cfg'
337--- AutoUpgradeTester/profile/ubuntu/pkgs.cfg 1970-01-01 00:00:00 +0000
338+++ AutoUpgradeTester/profile/ubuntu/pkgs.cfg 2011-12-12 14:49:25 +0000
339@@ -0,0 +1,1 @@
340+grub-pc

Subscribers

People subscribed via source and target branches

to status/vote changes: