Example #1
0
 def test_update_by_pattern(self):
     ra = RegexAssistant()
     line = "Hello, Whylog guy!"
     line_id = 1
     ra.add_line(line_id, FrontInput(0, line, 0))
     unlikely_regex = r'^Hello, (Whylog (team|guy)!)$'
     assert not ra.regex_matches[line_id].regex == unlikely_regex
     ra.update_by_pattern(line_id, unlikely_regex)
     assert ra.regex_matches[line_id].regex == unlikely_regex
Example #2
0
 def test_guess_pattern_matches(self):
     line = r'2015-12-03 or [10/Oct/1999 21:15:05 +0500] "GET /index.html HTTP/1.0" 200 1043'
     front_input = FrontInput(0, line, 0)
     line_id = 1
     ra = RegexAssistant()
     ra.add_line(line_id, front_input)
     pattern_matches = ra.guess_pattern_matches(line_id)
     assert pattern_matches
     guessed_regexes = [pattern_match.pattern for pattern_match in pattern_matches.values()]
     for guessed_regex in guessed_regexes:
         self.verify_regex_match(guessed_regex, line)
Example #3
0
 def test_guess_pattern_matches(self):
     line = r'2015-12-03 or [10/Oct/1999 21:15:05 +0500] "GET /index.html HTTP/1.0" 200 1043'
     front_input = FrontInput(0, line, 0)
     line_id = 1
     ra = RegexAssistant()
     ra.add_line(line_id, front_input)
     pattern_matches = ra.guess_pattern_matches(line_id)
     assert pattern_matches
     guessed_regexes = [
         pattern_match.pattern
         for pattern_match in pattern_matches.values()
     ]
     for guessed_regex in guessed_regexes:
         self.verify_regex_match(guessed_regex, line)
Example #4
0
 def test_update_by_pattern(self):
     ra = RegexAssistant()
     line = "Hello, Whylog guy!"
     line_id = 1
     ra.add_line(line_id, FrontInput(0, line, 0))
     unlikely_regex = r'^Hello, (Whylog (team|guy)!)$'
     assert not ra.regex_matches[line_id].regex == unlikely_regex
     ra.update_by_pattern(line_id, unlikely_regex)
     assert ra.regex_matches[line_id].regex == unlikely_regex
Example #5
0
    def setUp(self):
        """
        Creates teacher with sample Rule.
        """
        test_files_dir = 'empty_config_files'
        path = os.path.join(*path_test_files + [test_files_dir])
        parsers_path, rules_path, log_types_path = ConfigPathFactory.get_path_to_config_files(
            path, False
        )

        self.test_files = [parsers_path, rules_path, log_types_path]
        self._clean_test_files()

        yaml_config = YamlConfig(parsers_path, rules_path, log_types_path)
        regex_assistant = RegexAssistant()
        self.teacher = Teacher(yaml_config, regex_assistant)

        self.effect_id = 0
        self.effect_front_input = FrontInput(
            offset=42,
            line_content=r'2015-12-03 12:11:00 Error occurred in reading test',
            line_source=LineSource('sample_host', 'sample_path')
        )

        self.cause1_id = 1
        self.cause1_front_input = FrontInput(
            offset=30,
            line_content=r'2015-12-03 12:10:55 Data is missing on comp21',
            line_source=LineSource('sample_host1', 'sample_path1')
        )

        self.cause2_id = 2
        self.cause2_front_input = FrontInput(
            offset=21,
            line_content=r'2015-12-03 12:10:50 Data migration to comp21 failed in test 123',
            line_source=LineSource('sample_host2', 'sample_path2')
        )

        self.identical_groups = [(self.cause1_id, 2), (self.cause2_id, 2)]
        self.date_groups = [(self.effect_id, 1), (self.effect_id, 1)]

        self._add_rule()