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

Proposed by Jean-Baptiste Lallement
Status: Merged
Merged at revision: 2314
Proposed branch: lp:~jibel/update-manager/AutoUpgradeTester-debconf
Merge into: lp:update-manager
Diff against target: 162 lines (+79/-7)
6 files modified
AutoUpgradeTester/UpgradeTestBackend.py (+2/-2)
AutoUpgradeTester/UpgradeTestBackendQemu.py (+9/-4)
AutoUpgradeTester/UpgradeTestBackendSSH.py (+2/-0)
AutoUpgradeTester/post_upgrade_tests/debconf_test.py (+63/-0)
AutoUpgradeTester/profile/defaults.cfg.d/defaults.cfg (+1/-0)
DistUpgrade/DistUpgradeViewNonInteractive.py (+2/-1)
To merge this branch: bzr merge lp:~jibel/update-manager/AutoUpgradeTester-debconf
Reviewer Review Type Date Requested Status
Michael Vogt Pending
Review via email: mp+89054@code.launchpad.net
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 'AutoUpgradeTester/UpgradeTestBackend.py'
2--- AutoUpgradeTester/UpgradeTestBackend.py 2012-01-10 10:13:39 +0000
3+++ AutoUpgradeTester/UpgradeTestBackend.py 2012-01-18 14:54:29 +0000
4@@ -138,7 +138,6 @@
5 output = ""
6 testsuite_name = ''
7 res = [x['result'] for x in results]
8- #pass_count = res.count('pass')
9 fail_count = res.count('fail')
10 error_count = res.count('error')
11 total_count = len(res)
12@@ -149,7 +148,8 @@
13
14 for result in results:
15 output += """<testcase classname="%s" name="%s" time="%.3f">\n""" % (
16- self.profilename, result['name'], result['time'])
17+ self.profilename + '.PostUpgradeTest',
18+ result['name'][:-3], result['time'])
19 if 'fail' in result['result']:
20 output += """<failure type="%s">%s\n</failure>\n""" % (
21 'exception', escape(result['message']))
22
23=== modified file 'AutoUpgradeTester/UpgradeTestBackendQemu.py'
24--- AutoUpgradeTester/UpgradeTestBackendQemu.py 2012-01-05 08:25:38 +0000
25+++ AutoUpgradeTester/UpgradeTestBackendQemu.py 2012-01-18 14:54:29 +0000
26@@ -463,7 +463,7 @@
27 entry.type == "deb"):
28 print "adding %s to mirrors" % entry.uri
29 self._runInImage(["echo '%s' >> /upgrade-tester/new_mirrors.cfg" % entry.uri])
30-
31+
32 # upgrade *before* the regular upgrade runs
33 if self.config.getWithDefault("NonInteractive", "AddRepoUpgradeImmediately", False):
34 self._runInImage(["apt-get", "update"])
35@@ -477,12 +477,17 @@
36 # check if we have a bzr checkout dir to run against or
37 # if we should just run the normal upgrader
38 cmd_prefix=[]
39+ debconf_log = self.config.getWithDefault(
40+ 'NonInteractive', 'DebconfLog', '')
41+ if debconf_log:
42+ cmd_prefix=['export DEBIAN_FRONTEND=editor EDITOR="cat>>%s";' % debconf_log]
43+ print "Logging debconf prompts to %s" % debconf_log
44 if not self.config.getWithDefault("NonInteractive","ForceOverwrite", False):
45 print "Disabling ForceOverwrite"
46- cmd_prefix = ["export RELEASE_UPGRADE_NO_FORCE_OVERWRITE=1;"]
47+ cmd_prefix += ["export RELEASE_UPGRADE_NO_FORCE_OVERWRITE=1;"]
48 if (os.path.exists(self.upgradefilesdir) and
49- self.config.getWithDefault("NonInteractive",
50- "UseUpgraderFromBzr",
51+ self.config.getWithDefault("NonInteractive",
52+ "UseUpgraderFromBzr",
53 True)):
54 print "Using ./DistUpgrade/* for the upgrade"
55 self._copyUpgraderFilesFromBzrCheckout()
56
57=== modified file 'AutoUpgradeTester/UpgradeTestBackendSSH.py'
58--- AutoUpgradeTester/UpgradeTestBackendSSH.py 2011-12-12 14:37:37 +0000
59+++ AutoUpgradeTester/UpgradeTestBackendSSH.py 2012-01-18 14:54:29 +0000
60@@ -206,6 +206,8 @@
61
62 # check for conffiles (the copy is done via a post upgrade script)
63 self._copyFromImage("/tmp/*.dpkg-dist", self.resultdir)
64+ # Collect debconf prompts generated by debconf_test.py script
65+ self._copyFromImage("/tmp/debconf_*.log", self.resultdir)
66 self.resultsToJunitXML(results, os.path.join(self.resultdir, 'results.xml'))
67
68 self.stop()
69
70=== added file 'AutoUpgradeTester/post_upgrade_tests/debconf_test.py'
71--- AutoUpgradeTester/post_upgrade_tests/debconf_test.py 1970-01-01 00:00:00 +0000
72+++ AutoUpgradeTester/post_upgrade_tests/debconf_test.py 2012-01-18 14:54:29 +0000
73@@ -0,0 +1,63 @@
74+#!/usr/bin/python
75+"""
76+Parse debconf log file and split in a file per prompt
77+Exit with status 1 if there is a debconf prompt not in whitelist
78+"""
79+import re, os, sys
80+
81+# Keep this path in sync with the corresponding setting in
82+# profile/defaults.cfg.d/defaults.cfg
83+DEBCONF_LOG_PATH = '/var/log/dist-upgrade/debconf.log'
84+RESULT_DIR = '/tmp'
85+
86+# Prompts in this list won't generate a test failure
87+# i.e WHITELIST = ['libraries/restart-without-asking']
88+WHITELIST = []
89+
90+def run_test(logfile, resultdir):
91+ """ Run the test and slice debconf log
92+
93+ :param logfile: Path to debconf log
94+ :param resultdir: Output directory to write log file to
95+ """
96+ global WHITELIST
97+
98+ ret = 0
99+ if not os.path.exists(logfile):
100+ return ret
101+
102+ re_dsetting = re.compile('^\w')
103+ inprompt = False
104+ prompt = dsetting = ""
105+
106+ with open(logfile, 'r') as f_in:
107+ for line in f_in.readlines():
108+ # Only keep interesting bits of the prompt
109+ if line.startswith('#####'):
110+ inprompt = not inprompt
111+
112+ # Reached the second separator, write content to result file
113+ # One per prompt
114+ if not inprompt:
115+ print "Got debconf prompt for '%s'" % dsetting
116+ if dsetting in WHITELIST:
117+ print ' But it is in Whitelist. Skipping!'
118+ continue
119+ else:
120+ ret = 1
121+
122+ with open(os.path.join(
123+ resultdir,
124+ 'debconf_%s.log' % dsetting.replace('/', '_')),
125+ 'w') as f_out:
126+ f_out.write(prompt)
127+
128+ if inprompt:
129+ prompt += line
130+ if re_dsetting.match(line) and '=' in line:
131+ dsetting = line.split('=')[0]
132+
133+ return ret
134+
135+if __name__ == '__main__':
136+ sys.exit(run_test(DEBCONF_LOG_PATH, RESULT_DIR))
137
138=== modified file 'AutoUpgradeTester/profile/defaults.cfg.d/defaults.cfg'
139--- AutoUpgradeTester/profile/defaults.cfg.d/defaults.cfg 2011-12-30 22:06:53 +0000
140+++ AutoUpgradeTester/profile/defaults.cfg.d/defaults.cfg 2012-01-18 14:54:29 +0000
141@@ -29,6 +29,7 @@
142 DebugBrokenScripts=yes
143 UseUpgraderFromBzr=false
144 ;AddRepo=local_testing.list
145+DebconfLog=/var/log/dist-upgrade/debconf.log
146
147
148 [KVM]
149
150=== modified file 'DistUpgrade/DistUpgradeViewNonInteractive.py'
151--- DistUpgrade/DistUpgradeViewNonInteractive.py 2011-07-15 15:50:31 +0000
152+++ DistUpgrade/DistUpgradeViewNonInteractive.py 2012-01-18 14:54:29 +0000
153@@ -59,7 +59,8 @@
154 def __init__(self, logdir):
155 InstallProgress.__init__(self)
156 logging.debug("setting up environ for non-interactive use")
157- os.environ["DEBIAN_FRONTEND"] = "noninteractive"
158+ if not os.environ.has_key("DEBIAN_FRONTEND"):
159+ os.environ["DEBIAN_FRONTEND"] = "noninteractive"
160 os.environ["APT_LISTCHANGES_FRONTEND"] = "none"
161 os.environ["RELEASE_UPRADER_NO_APPORT"] = "1"
162 self.config = DistUpgradeConfig(".")

Subscribers

People subscribed via source and target branches

to status/vote changes: