Esempio n. 1
0
def test_bgrep():
    """validates bgrep matches every line"""
    b = BucketGrep(
        'main',
        files=[os.path.join(current_dir(__file__), 'testdata', 'simple.log')])
    b.analyze()
    assert len(b.matches) == 2
Esempio n. 2
0
 def test_bgrep(self):
     """validates bgrep matches every line"""
     b = BucketGrep(
         "main",
         files=[
             os.path.join(current_dir(__file__), "testdata", "simple.log")
         ],
     )
     b.analyze()
     self.assertEqual(len(b.matches), 2)
Esempio n. 3
0
 def test_nodate(self):
     """validates bgrep matches lines without a date"""
     b = BucketGrep(
         ".*No such file or directory.*",
         files=[
             os.path.join(current_dir(__file__), "testdata",
                          "traceback.log")
         ],
     )
     b.analyze()
     self.assertEqual(len(b.matches), 1)
Esempio n. 4
0
 def test_no_matches(self):
     """should match no rows"""
     b = BucketGrep(
         "this should never match anything",
         files=[
             os.path.join(current_dir(__file__), "testdata",
                          "statusloggernew_debug.log")
         ],
     )
     b.analyze()
     self.assertFalse(b.matches)
Esempio n. 5
0
 def test_bgrep_when_statuslogger_lines_present(self):
     """statuslogger matching maybe breaking bgrep"""
     b = BucketGrep(
         "RANGE_SLICE messages were dropped",
         files=[
             os.path.join(current_dir(__file__), "testdata",
                          "statusloggernew_debug.log")
         ],
     )
     b.analyze()
     self.assertEqual(len(b.matches), 1)
Esempio n. 6
0
def run(args):
    """ run bgrep """
    files = None
    if args.files:
        files = args.files.split(',')
    b = BucketGrep(args.regex,
                   diag_dir=args.diag_dir,
                   files=files,
                   start=args.start,
                   end=args.end,
                   ignorecase=not args.case)
    b.print_report(interval=args.interval)
Esempio n. 7
0
def test_nodate():
    """validates bgrep matches lines without a date"""
    b = BucketGrep('.*No such file or directory.*', \
            files=[os.path.join(current_dir(__file__), 'testdata', 'traceback.log')])
    b.analyze()
    assert len(b.matches) == 1
Esempio n. 8
0
def test_no_matches():
    """should match no rows"""
    b = BucketGrep('this should never match anything', \
                   files=[os.path.join(current_dir(__file__), 'testdata', 'statusloggernew_debug.log')])
    b.analyze()
    assert not b.matches
Esempio n. 9
0
def test_bgrep_when_statuslogger_lines_present():
    """statuslogger matching maybe breaking bgrep"""
    b = BucketGrep('RANGE_SLICE messages were dropped', \
            files=[os.path.join(current_dir(__file__), 'testdata', 'statusloggernew_debug.log')])
    b.analyze()
    assert len(b.matches) == 1