Merge lp:~raharper/curtin/trunk.fix-vmtest-install-ok-check into lp:~curtin-dev/curtin/trunk

Proposed by Ryan Harper
Status: Merged
Approved by: Scott Moser
Approved revision: 307
Merged at revision: 312
Proposed branch: lp:~raharper/curtin/trunk.fix-vmtest-install-ok-check
Merge into: lp:~curtin-dev/curtin/trunk
Diff against target: 57 lines (+33/-6)
1 file modified
tests/vmtests/__init__.py (+33/-6)
To merge this branch: bzr merge lp:~raharper/curtin/trunk.fix-vmtest-install-ok-check
Reviewer Review Type Date Requested Status
Scott Moser (community) Approve
Review via email: mp+277908@code.launchpad.net

Description of the change

Modify how vmtests checks if a curtin install was successful.

1. we missed finding failed installs on precise/trusty due to non-systemd output. systemd prepends non-pid-1 process output to console with the calling process, so we had 'cloud-init[.*]', however on pre-systemd systems, that's not present. Fix this by dropping the cloud-init portion of the regular expression

2. Add in additional error messages we've seen during debugging of test cases

3. Modify the check to first see if we can find curtin's successful install message; if that's not found, then look for common errors.

To post a comment you must log in.
306. By Ryan Harper

vmtest: move install log checking to a function

Move install log checking logic to separate function.

307. By Ryan Harper

from trunk

Revision history for this message
Scott Moser (smoser) wrote :

I like this a lot, the only thing i hesitate on is jenkins running. we want to make sure console logs or artifacts there have everything we can to debug.

Diogo, could you run some and give us a pointer?

Revision history for this message
Scott Moser (smoser) wrote :

my comment above should have been on ryan's trunk.change-vmtest-default-output.
after revno 306 here, i like approve this MP.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/vmtests/__init__.py'
2--- tests/vmtests/__init__.py 2015-11-18 17:15:08 +0000
3+++ tests/vmtests/__init__.py 2015-11-18 22:21:21 +0000
4@@ -295,13 +295,12 @@
5 logger.debug('Checking curtin install output for errors')
6 with open(cls.install_log) as l:
7 install_log = l.read()
8- errors = re.findall(
9- '\[.*\]\ cloud-init.*:.*Installation\ failed', install_log)
10- if len(errors) > 0:
11+ errmsg, errors = check_install_log(install_log)
12+ if errmsg:
13 for e in errors:
14- logger.debug(e)
15- logger.debug('Errors during curtin installer')
16- raise Exception('Errors during curtin installer')
17+ logger.error(e)
18+ logger.error(errmsg)
19+ raise Exception(cls.__name__ + ":" + errmsg)
20 else:
21 logger.debug('Install OK')
22 else:
23@@ -432,6 +431,34 @@
24 self.assertIn(diskname, contents)
25
26
27+def check_install_log(install_log):
28+ # look if install is OK via curtin 'Installation ok"
29+ # if we dont find that, scan for known error messages and report
30+ # if we don't see any errors, fail with general error
31+ errors = []
32+ errmsg = None
33+
34+ # regexps expected in curtin output
35+ install_pass = "Installation finished. No error reported."
36+ install_fail = "({})".format("|".join([
37+ 'Installation\ failed',
38+ 'ImportError: No module named.*',
39+ 'Unexpected error while running command',
40+ 'E: Unable to locate package.*']))
41+
42+ install_is_ok = re.findall(install_pass, install_log)
43+ if len(install_is_ok) == 0:
44+ errors = re.findall(install_fail, install_log)
45+ if len(errors) > 0:
46+ for e in errors:
47+ logger.error(e)
48+ errmsg = ('Errors during curtin installer')
49+ else:
50+ errmsg = ('Failed to verify Installation is OK')
51+
52+ return errmsg, errors
53+
54+
55 def get_apt_proxy():
56 # get setting for proxy. should have same result as in tools/launch
57 apt_proxy = os.environ.get('apt_proxy')

Subscribers

People subscribed via source and target branches