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
=== modified file 'tests/vmtests/__init__.py'
--- tests/vmtests/__init__.py 2015-11-18 17:15:08 +0000
+++ tests/vmtests/__init__.py 2015-11-18 22:21:21 +0000
@@ -295,13 +295,12 @@
295 logger.debug('Checking curtin install output for errors')295 logger.debug('Checking curtin install output for errors')
296 with open(cls.install_log) as l:296 with open(cls.install_log) as l:
297 install_log = l.read()297 install_log = l.read()
298 errors = re.findall(298 errmsg, errors = check_install_log(install_log)
299 '\[.*\]\ cloud-init.*:.*Installation\ failed', install_log)299 if errmsg:
300 if len(errors) > 0:
301 for e in errors:300 for e in errors:
302 logger.debug(e)301 logger.error(e)
303 logger.debug('Errors during curtin installer')302 logger.error(errmsg)
304 raise Exception('Errors during curtin installer')303 raise Exception(cls.__name__ + ":" + errmsg)
305 else:304 else:
306 logger.debug('Install OK')305 logger.debug('Install OK')
307 else:306 else:
@@ -432,6 +431,34 @@
432 self.assertIn(diskname, contents)431 self.assertIn(diskname, contents)
433432
434433
434def check_install_log(install_log):
435 # look if install is OK via curtin 'Installation ok"
436 # if we dont find that, scan for known error messages and report
437 # if we don't see any errors, fail with general error
438 errors = []
439 errmsg = None
440
441 # regexps expected in curtin output
442 install_pass = "Installation finished. No error reported."
443 install_fail = "({})".format("|".join([
444 'Installation\ failed',
445 'ImportError: No module named.*',
446 'Unexpected error while running command',
447 'E: Unable to locate package.*']))
448
449 install_is_ok = re.findall(install_pass, install_log)
450 if len(install_is_ok) == 0:
451 errors = re.findall(install_fail, install_log)
452 if len(errors) > 0:
453 for e in errors:
454 logger.error(e)
455 errmsg = ('Errors during curtin installer')
456 else:
457 errmsg = ('Failed to verify Installation is OK')
458
459 return errmsg, errors
460
461
435def get_apt_proxy():462def get_apt_proxy():
436 # get setting for proxy. should have same result as in tools/launch463 # get setting for proxy. should have same result as in tools/launch
437 apt_proxy = os.environ.get('apt_proxy')464 apt_proxy = os.environ.get('apt_proxy')

Subscribers

People subscribed via source and target branches