diff --git a/branches/ucs-3.2/ucs-3.2-3/test/ucs-test/tests/00_base/99check_log_files b/branches/ucs-3.2/ucs-3.2-3/test/ucs-test/tests/00_base/99check_log_files index 803eee6..2d3bfde 100755 --- a/branches/ucs-3.2/ucs-3.2-3/test/ucs-test/tests/00_base/99check_log_files +++ b/branches/ucs-3.2/ucs-3.2-3/test/ucs-test/tests/00_base/99check_log_files @@ -14,7 +14,7 @@ from sys import exit from univention.management.console.modules.setup.setup_script import Profile import univention.testing.utils as utils -import check_log_files_definitions as definitions +from check_log_files_definitions import Errors, Tracebacks, Warnings class CheckLogFiles(object): @@ -23,8 +23,9 @@ class CheckLogFiles(object): """ Test constructor """ - self.DefinitionsErrors = definitions.Errors - self.DefinitionsWarnings = definitions.Warnings + self.errors = Errors() + self.warnings = Warnings() + self.tracebacks = Tracebacks() self.log_file = '' self.line_counter = 0 @@ -48,8 +49,7 @@ class CheckLogFiles(object): self.line_counter += 1 trace_line += 1 - if (trace_line >= self.max_trace_lines or re.match('.*Error: .*', - line)): + if trace_line >= self.max_trace_lines or 'Error: ' in line: last_line = line.strip() # break loop if the trace is too big or # if last trace line with error name was found @@ -67,10 +67,9 @@ class CheckLogFiles(object): Extracts the traceback message and appends it to the output 'errors' with a given 'msg' in the beginning. """ - for pattern in definitions.Tracebacks.wanted: - if pattern.match(line): - errors.append(msg + '\n' + self.extract_traceback_message()) - return errors + if self.tracebacks.wanted(line): + errors.append(msg + '\n' + self.extract_traceback_message()) + return errors return errors @@ -80,14 +79,12 @@ class CheckLogFiles(object): adds message 'msg' to list 'result' if pattern is in 'wanted'. Ignores the patterns matching 'ignore'. Returns 'result'. """ - for pattern in definition.ignore: - if pattern.match(line): - return result + if definition.ignore(line): + return result - for pattern in definition.wanted: - if pattern.match(line): - result.append(msg) - return result + if definition.wanted(line): + result.append(msg) + return result return result @@ -123,11 +120,11 @@ class CheckLogFiles(object): # skip the message if it is repeated from the previous line: if line != previous_line: errors = self.check_line(line, - self.DefinitionsErrors, + self.errors, errors, msg) warnings = self.check_line(line, - self.DefinitionsWarnings, + self.warnings, warnings, msg) @@ -156,13 +153,8 @@ class CheckLogFiles(object): # adding warnings and errors caused by absence of # join procedure to the ignore lists - self.DefinitionsErrors.ignore_list.extend(join_errors) - self.DefinitionsWarnings.ignore_list.extend(join_warnings) - - self.DefinitionsErrors.ignore = map(re.compile, - self.DefinitionsErrors.ignore_list) - self.DefinitionsWarnings.ignore = map(re.compile, - self.DefinitionsWarnings.ignore_list) + self.errors = Errors(ignore=join_errors) + self.warnings = Warnings(ignore=join_warnings) def check_installation_profile(self): """ diff --git a/branches/ucs-3.2/ucs-3.2-3/test/ucs-test/tests/00_base/check_log_files_definitions.py b/branches/ucs-3.2/ucs-3.2-3/test/ucs-test/tests/00_base/check_log_files_definitions.py index c3289e9..b96a3da 100644 --- a/branches/ucs-3.2/ucs-3.2-3/test/ucs-test/tests/00_base/check_log_files_definitions.py +++ b/branches/ucs-3.2/ucs-3.2-3/test/ucs-test/tests/00_base/check_log_files_definitions.py @@ -2,77 +2,90 @@ import re -class Errors(object): - wanted = map(lambda p: re.compile(p, re.IGNORECASE), - [".*(error).*", - ".*(failed).*", - ".*(usage).*", - "^E:"]) +class LogMessage(object): + def __init__(self, wanted=None, ignore=None): + self.wanted = self.recomp(self.wanted_list + (wanted or [])).match + self.ignore = self.recomp(self.ignore_list + (ignore or [])).match - # possible (ignored) errors: - ignore_list = [ - '.*failedmirror=.*', - 'All done, no errors.', - 'I: .* libgpg-error0', - 'Installation finished. No error.* reported', - 'Not updating .*', - 'Error: There are no (services|hosts|host groups|contacts|contact groups) defined!', - 'Total Errors:\s+\d+', - 'Cannot find nagios object .*', - 'invoke-rc.d: initscript udev, action "reload" failed.', # Bug 19227 - 'yes: write error', - '.*Update aborted by pre-update script of release.*', - '.*update failed. Please check /var/log/univention/.*', - '.*failed to convert the username listfilter to the uid.*', - '.*Can not write log, .* failed.*', - '.*Starting Univention Directory Policy:.*', - '.*LISTENER .* : failed to connect to any notifier.*', - '.*liberror-perl.*', - '.*CONSISTENCY CHECK FAILED: cyls is too large .* setting to possible max .*', - '.*error adding .*.pem', - '.*failed .*VM used: java-6-cacao.*', - '.*/etc/ca-certificates/update.d/.* exited with code 1'] + @staticmethod + def recomp(patterns, ignore_case=True): + pattern = '|'.join('(?:%s)' % _ for _ in patterns) + return re.compile(pattern, re.IGNORECASE if ignore_case else 0) - ignore = map(re.compile, ignore_list) +class Errors(LogMessage): + wanted_list = [ + ".*error.*", + ".*failed.*", + ".*usage.*", + "^E:", + ] -class Tracebacks(object): - wanted = map(lambda p: re.compile(p, re.IGNORECASE), - [".*(traceback).*"]) + # possible (ignored) errors: + ignore_list = [ + '.*failedmirror=.*', + 'All done, no errors.', + 'I: .* libgpg-error0', + 'Installation finished. No error.* reported', + 'Not updating .*', + 'Error: There are no (?:services|hosts|host groups|contacts|contact groups) defined!', + 'Total Errors:\s+\d+', + 'Cannot find nagios object .*', + 'invoke-rc.d: initscript udev, action "reload" failed.', # Bug 19227 + 'yes: write error', + '.*Update aborted by pre-update script of release.*', + '.*update failed. Please check /var/log/univention/.*', + '.*failed to convert the username listfilter to the uid.*', + '.*Can not write log, .* failed.*', + '.*Starting Univention Directory Policy:.*', + '.*LISTENER .* : failed to connect to any notifier.*', + '.*liberror-perl.*', + '.*CONSISTENCY CHECK FAILED: cyls is too large .* setting to possible max .*', + '.*error adding .*.pem', + '.*failed .*VM used: java-6-cacao.*', + '.*/etc/ca-certificates/update.d/.* exited with code 1', + ] -class Warnings(object): - wanted = map(lambda p: re.compile(p, re.IGNORECASE), - [".*(warning).*"]) +class Tracebacks(LogMessage): + wanted_list = [ + ".*traceback.*", + ] - # possible (ignored) warnings: - ignore_list = [ - 'WARNING: The following packages cannot be authenticated!', - 'Authentication warning overridden.', - '^Create .*/warning', - 'WARNING: You are logged in using SSH -- this may interrupt the update and result in an inconsistent system!', - 'dpkg - warning: ignoring request to remove .* which isn.t installed.', - 'dpkg: warning - unable to delete old directory .*: Directory not empty', - 'dpkg - warning, overriding problem because --force enabled', - 'dpkg: serious warning: files list file for package .* missing, assuming package has no files currently installed.', - '.*dpkg: warning: unable to delete old directory .* Directory not empty.*', - 'WARNING: cannot append .* to .*, value exists', - 'Warning: The config registry variable .*? does not exist', - 'Total Warnings:\s+\d+', - 'sys:1: DeprecationWarning: Non-ASCII character.*but no encoding declared; see http://www.python.org/peps/pep-0263.html for details', - 'warning: commands will be executed using /bin/.*', - 'Not updating .*', - 'Warning: The home dir .* you specified already exists.', - 'WARNING!', - '.*WARNING: All config files need \.conf: /etc/modprobe\.d/.+, it will be ignored in a future release\.', - 'update-rc\.d: warning: .* (start|stop) runlevel arguments \([^)]+\) do not match LSB Default-(Start|Stop) values ([^)]+)', - '.*warning: rule .* already exists.*', - '.*Not starting .*: no services enabled.*', - '.*Running /etc/init.d/.* is deprecated.*', - '.*The resulting partition is not properly aligned for best performance.*', - '.*Updating certificates in /etc/ssl/certs.* WARNING: Skipping duplicate certificate ca-certificates.crt.*', - '.*Permanently added .* to the list of known hosts.*', - '.*usr/sbin/grub-probe: warning: disk does not exist, so falling back to partition device.*', - '.*WARNING: cannot read /sys/block/vda.* (No such file or directory|Datei oder Verzeichnis nicht gefunden).*'] + ignore_list = [] - ignore = map(re.compile, ignore_list) + +class Warnings(LogMessage): + wanted_list = [ + ".*warning.*", + ] + + # possible (ignored) warnings: + ignore_list = [ + 'WARNING: The following packages cannot be authenticated!', + 'Authentication warning overridden.', + '^Create .*/warning', + 'WARNING: You are logged in using SSH -- this may interrupt the update and result in an inconsistent system!', + 'dpkg - warning: ignoring request to remove .* which isn.t installed.', + 'dpkg: warning - unable to delete old directory .*: Directory not empty', + 'dpkg - warning, overriding problem because --force enabled', + 'dpkg: serious warning: files list file for package .* missing, assuming package has no files currently installed.', + '.*dpkg: warning: unable to delete old directory .* Directory not empty.*', + 'WARNING: cannot append .* to .*, value exists', + 'Warning: The config registry variable .*? does not exist', + 'Total Warnings:\s+\d+', + 'sys:1: DeprecationWarning: Non-ASCII character.*but no encoding declared; see http://www.python.org/peps/pep-0263.html for details', + 'warning: commands will be executed using /bin/.*', + 'Not updating .*', + 'Warning: The home dir .* you specified already exists.', + 'WARNING!', + '.*WARNING: All config files need \.conf: /etc/modprobe\.d/.+, it will be ignored in a future release\.', + 'update-rc\.d: warning: .* (?:start|stop) runlevel arguments \([^)]+\) do not match LSB Default-(?:Start|Stop) values [^)]+', + '.*warning: rule .* already exists.*', + '.*Not starting .*: no services enabled.*', + '.*Running /etc/init.d/.* is deprecated.*', + '.*The resulting partition is not properly aligned for best performance.*', + '.*Updating certificates in /etc/ssl/certs.* WARNING: Skipping duplicate certificate ca-certificates.crt.*', + '.*Permanently added .* to the list of known hosts.*', + '.*usr/sbin/grub-probe: warning: disk does not exist, so falling back to partition device.*', + '.*WARNING: cannot read /sys/block/vda.* (?:No such file or directory|Datei oder Verzeichnis nicht gefunden).*']