def test_positive_check_installer_logfile(self): """Look for ERROR or FATAL references in logfiles @id: 80537809-8be4-42db-9cc8-5155378ee4d4 @Steps: 1. search all relevant logfiles for ERROR/FATAL @Assert: No ERROR/FATAL notifcations occur in {katello-jobs, tomcat6, foreman, pulp, passenger-analytics, httpd, foreman_proxy, elasticsearch, postgresql, mongod} logfiles. """ logfiles = ( { 'path': '/var/log/candlepin/error.log', 'pattern': r'ERROR' }, { 'path': '/var/log/katello-installer/katello-installer.log', 'pattern': r'\[\s*(ERROR|FATAL)' }, ) for logfile in logfiles: try: log = LogFile(logfile['path'], logfile['pattern']) except IOError: self.fail( 'Could not find {0} file on server'.format(logfile['path']) ) self.assertEqual(len(log.filter()), 0)
def test_positive_check_installer_logfile(self): """Look for ERROR or FATAL references in logfiles @Feature: Installer @Steps: 1. search all relevant logfiles for ERROR/FATAL @Assert: No ERROR/FATAL notifcations occur in {katello-jobs, tomcat6, foreman, pulp, passenger-analytics, httpd, foreman_proxy, elasticsearch, postgresql, mongod} logfiles. """ logfiles = ( { 'path': '/var/log/candlepin/error.log', 'pattern': r'ERROR' }, { 'path': '/var/log/katello-installer/katello-installer.log', 'pattern': r'\[\s*(ERROR|FATAL)' }, ) for logfile in logfiles: try: log = LogFile(logfile['path'], logfile['pattern']) except IOError: self.fail('Could not find {0} file on server'.format( logfile['path'])) self.assertEqual(len(log.filter()), 0)
def test_installer_logfile_check(self): """ @test: Look for ERROR or FATAL references in logfiles @feature: Installer @steps: 1. search all relevant logfiles for ERROR/FATAL @assert: No ERROR/FATAL notifcations occur in {katello-jobs, tomcat6, foreman, pulp, passenger-analytics, httpd, foreman_proxy, elasticsearch, postgresql, mongod} logfiles. """ logfiles = ( {'path': '/var/log/candlepin/error.log', 'pattern': r'ERROR'}, {'path': '/var/log/katello/katello-install/katello-install.log', 'pattern': r'\[\s*(ERROR|FATAL)'}, ) for logfile in logfiles: try: log = LogFile(logfile['path'], logfile['pattern']) except IOError: self.fail('Could not find %s file on server' % logfile['path']) result = log.filter() self.assertEqual( len(result), 0, '"%s" pattern found in %s lines:\n%s' % (logfile['pattern'], logfile['path'], ''.join(result)))
def test_positive_check_installer_logfile(self): """Look for ERROR or FATAL references in logfiles :id: 80537809-8be4-42db-9cc8-5155378ee4d4 :Steps: search all relevant logfiles for ERROR/FATAL :expectedresults: No ERROR/FATAL notifcations occur in {katello-jobs, tomcat6, foreman, pulp, passenger-analytics, httpd, foreman_proxy, elasticsearch, postgresql, mongod} logfiles. """ logfiles = ( { 'path': '/var/log/candlepin/error.log', 'pattern': r'ERROR' }, { 'path': '/var/log/foreman-installer/satellite.log', 'pattern': r'\[\s*(ERROR|FATAL)' }, ) for logfile in logfiles: remote_file = logfile['path'] try: log = LogFile(remote_file, logfile['pattern']) except IOError: self.fail( 'Could not find {0} file on server'.format(remote_file)) else: errors = log.filter() self.assertEqual(len(errors), 0, msg='Errors found in {}: {}'.format( remote_file, errors))
def test_positive_check_installer_logfile(self): """Look for ERROR or FATAL references in logfiles :id: 80537809-8be4-42db-9cc8-5155378ee4d4 :Steps: search all relevant logfiles for ERROR/FATAL :expectedresults: No ERROR/FATAL notifcations occur in {katello-jobs, tomcat6, foreman, pulp, passenger-analytics, httpd, foreman_proxy, elasticsearch, postgresql, mongod} logfiles. """ logfiles = ( { 'path': '/var/log/candlepin/error.log', 'pattern': r'ERROR' }, { 'path': '/var/log/foreman-installer/satellite.log', 'pattern': r'\[\s*(ERROR|FATAL)' }, ) for logfile in logfiles: remote_file = logfile['path'] try: log = LogFile(remote_file, logfile['pattern']) except IOError: self.fail( 'Could not find {0} file on server'.format(remote_file) ) else: errors = log.filter() self.assertEqual( len(errors), 0, msg='Errors found in {}: {}'.format(remote_file, errors))
def test_positive_check_installer_logfile(self): """Look for ERROR or FATAL references in logfiles during installation time :id: 80537809-8be4-42db-9cc8-5155378ee4d4 :Steps: search all relevant logfiles for ERROR/FATAL with timestamp before installation has finished :expectedresults: No ERROR/FATAL notifcations occur in {katello-jobs, tomcat6, foreman, pulp, passenger-analytics, httpd, foreman_proxy, elasticsearch, postgresql, mongod} logfiles during installation phase. """ logfiles = ( { 'path': '/var/log/foreman-installer/satellite.log', 'pattern': r'\[\s*(ERROR|FATAL)' }, { 'path': '/var/log/candlepin/error.log', 'pattern': r'ERROR' }, ) datetime_pattern = r'\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}' datetime_format = '%Y-%m-%d %H:%M:%S' try: logs = [ LogFile(logfile['path'], logfile['pattern']) for logfile in logfiles ] except IOError as exception: self.fail('Could not find log file on server\n{}'.format( str(exception))) if len(logs[0].data) == 0: self.skipTest( 'Installer log is empty, impossible to distinguish installer ' 'errors from post-install errors') install_time_line = logs[0].data[-1] datetime_regex = re.compile(datetime_pattern) install_time = datetime.strptime( datetime_regex.search(install_time_line).group(0), datetime_format) for log in logs: with self.subTest(log.remote_path): errors = log.filter() installer_errors = [] for error in errors: error_time = datetime.strptime( datetime_regex.search(error).group(0), datetime_format) if error_time <= install_time: installer_errors.append(error) self.assertEqual(len(installer_errors), 0, msg='Errors found in {}: {}'.format( log.remote_path, installer_errors))