def test_update_progress(self):
     test_update_progress_range = {
         'min_progress': 0.3,
         'max_progress': 0.7,
     }
     expected = ['sys.log', 0.0, 0.1]
     file_matchers = [
         FileMatcher(
             filename='sys.log',
             min_progress=0.0,
             max_progress=0.1,
             line_matchers={
                 'start': LineMatcher(
                     pattern=r'NOTICE (?P<message>.*)',
                     progress=IncrementalProgress(.1, .9, .1),
                     message_template='%(message)s',
                     unmatch_nextline_next_matcher_name='start',
                     match_nextline_next_matcher_name='exit'
                 ),
             }
         ),
     ]
     matcher = adapter_matcher.AdapterItemMatcher(
         file_matchers=file_matchers)
     matcher.update_progress_range(
         **test_update_progress_range)
     file_matcher = matcher.file_matchers_[0]
     result = []
     result.append(file_matcher.filename_)
     result.append(file_matcher.min_progress_)
     result.append(file_matcher.max_progress_)
     self.assertEqual(expected, result)
Exemple #2
0
    def test_update_total_progress_none(self):
        file_progress = Progress(message=None, progress=0.5, severity='info')

        total_progress = file_progress
        matcher = file_matcher.FileMatcher(
            filename='sys.log',
            min_progress=0.0,
            max_progress=0.1,
            line_matchers={
                'start':
                LineMatcher(pattern=r'NOTICE (?P<message>.*)',
                            progress=IncrementalProgress(.1, .9, .1),
                            message_template='%(message)s',
                            unmatch_nextline_next_matcher_name='start',
                            match_nextline_next_matcher_name='exit'),
            })
        res = matcher.update_total_progress(file_progress, total_progress)
        self.assertIsNone(res)
Exemple #3
0
 def test_update_absolute_progress_range(self):
     matcher = file_matcher.FileMatcher(
         filename='sys.log',
         min_progress=0.0,
         max_progress=0.1,
         line_matchers={
             'start':
             LineMatcher(pattern=r'NOTICE (?P<message>.*)',
                         progress=IncrementalProgress(.1, .9, .1),
                         message_template='%(message)s',
                         unmatch_nextline_next_matcher_name='start',
                         match_nextline_next_matcher_name='exit'),
         })
     matcher.update_absolute_progress_range(0.5, 1.0)
     expected = [0.5, 0.55]
     res = []
     res.append(matcher.absolute_min_progress_)
     res.append(matcher.absolute_max_progress_)
     self.assertEqual(expected, res)
Exemple #4
0
from compass.log_analyzor.line_matcher import LineMatcher, IncrementalProgress
from compass.log_analyzor.file_matcher import FileMatcher
from compass.log_analyzor.adapter_matcher import AdapterMatcher
from compass.log_analyzor.adapter_matcher import AdapterItemMatcher

# TODO(weidong): reconsider intialization method for the following.
OS_CONFIGURATIONS = {
    'CentOS':
    AdapterItemMatcher(file_matchers=[
        FileMatcher(filename='sys.log',
                    min_progress=0.0,
                    max_progress=0.1,
                    line_matchers={
                        'start':
                        LineMatcher(pattern=r'NOTICE (?P<message>.*)',
                                    progress=IncrementalProgress(.1, .9, .1),
                                    message_template='%(message)s',
                                    unmatch_nextline_next_matcher_name='start',
                                    match_nextline_next_matcher_name='exit'),
                    }),
        FileMatcher(
            filename='anaconda.log',
            min_progress=0.1,
            max_progress=1.0,
            line_matchers={
                'start':
                LineMatcher(
                    pattern=r'setting.*up.*kickstart',
                    progress=.1,
                    message_template=('Setting up kickstart configurations'),
                    unmatch_nextline_next_matcher_name='start',