Beispiel #1
0
    def setUpClass(cls):
        cls.connection_error_line = "2016-04-12 23:54:45 Connection error occurred on comp1. Host name: host1"
        cls.lost_data_line = "2016-04-12 23:54:43 Data is missing at comp2. Loss = 230 GB. Host name: host2"
        cls.data_migration_line = "2016-04-12 23:54:40 Data migration from comp1 to comp2 failed. Host name: host2"

        path = os.path.join(*path_test_files)
        multiple_path = os.path.join(path, 'test_investigation_plan_files')
        parsers_path, rules_path, log_types_path = ConfigPathFactory.get_path_to_config_files(
            path, False)
        multiple_parsers_path, multiple_rules_path, _ = ConfigPathFactory.get_path_to_config_files(
            multiple_path, False)

        cls.simple_config = YamlConfig(parsers_path, rules_path,
                                       log_types_path)
        cls.multiple_parsers_config = YamlConfig(multiple_parsers_path,
                                                 rules_path, log_types_path)
        cls.complexed_config = YamlConfig(multiple_parsers_path,
                                          multiple_rules_path, log_types_path)
    def setUpClass(cls):
        cls.connection_error_line = "2016-04-12 23:54:45 Connection error occurred on comp1. Host name: host1"
        cls.lost_data_line = "2016-04-12 23:54:43 Data is missing at comp2. Loss = 230 GB. Host name: host2"
        cls.data_migration_line = "2016-04-12 23:54:40 Data migration from comp1 to comp2 failed. Host name: host2"

        path = os.path.join(*path_test_files)
        multiple_path = os.path.join(path, 'test_investigation_plan_files')
        parsers_path, rules_path, log_types_path = ConfigPathFactory.get_path_to_config_files(
            path, False
        )
        multiple_parsers_path, multiple_rules_path, _ = ConfigPathFactory.get_path_to_config_files(
            multiple_path, False
        )

        cls.simple_config = YamlConfig(parsers_path, rules_path, log_types_path)
        cls.multiple_parsers_config = YamlConfig(multiple_parsers_path, rules_path, log_types_path)
        cls.complexed_config = YamlConfig(
            multiple_parsers_path, multiple_rules_path, log_types_path
        )
Beispiel #3
0
 def _prepare_config(cls, path):
     # preparing Whylog structures special for temporary assign file to log type test
     whylog_config = YamlConfig(*ConfigPathFactory.get_path_to_config_files(path))
     whylog_config._log_types = {"default": DEFAULT_LOG_TYPE}
     for parser in six.itervalues(whylog_config._parsers):
         parser.log_type = "default"
     whylog_config._parser_name_generator = ParserNameGenerator(whylog_config._parsers)
     whylog_config._parsers_grouped_by_log_type["default"] = whylog_config._parsers_grouped_by_log_type.pop(
         "test_log_type"
     )
     return whylog_config
Beispiel #4
0
 def _prepare_config(cls, path):
     # preparing Whylog structures special for temporary assign file to log type test
     whylog_config = YamlConfig(
         *ConfigPathFactory.get_path_to_config_files(path))
     whylog_config._log_types = {"default": AbstractConfig.DEFAULT_LOG_TYPE}
     for parser in six.itervalues(whylog_config._parsers):
         parser.log_type = "default"
     whylog_config._parser_name_generator = ParserNameGenerator(
         whylog_config._parsers)
     whylog_config._parsers_grouped_by_log_type[
         "default"] = whylog_config._parsers_grouped_by_log_type.pop(
             "test_log_type")
     return whylog_config
Beispiel #5
0
    def test_one(self, test_name):
        input_path, original_log_file, path, result_log_file, results_yaml_file = self._prepare_files_path(test_name)
        effect_line_offset, line_content = self._gather_effect_line_data(input_path, original_log_file)

        # preparing Whylog structures, normally prepared by Front
        whylog_config = YamlConfig(*ConfigPathFactory.get_path_to_config_files(path))
        log_reader = LogReader(whylog_config)
        effect_line = FrontInput(
            effect_line_offset,
            line_content,
            LineSource("localhost", os.path.join(path, self._get_starting_file_name(input_path))),
        )

        results = log_reader.get_causes(effect_line)
        expected_results = self._investigation_results_from_yaml(results_yaml_file, result_log_file)
        self._check_results(results, expected_results)
Beispiel #6
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()
Beispiel #7
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()
Beispiel #8
0
    def test_one(self, test_name):
        input_path, original_log_file, path, result_log_file, results_yaml_file = self._prepare_files_path(
            test_name)
        effect_line_offset, line_content = self._gather_effect_line_data(
            input_path, original_log_file)

        # preparing Whylog structures, normally prepared by Front
        whylog_config = YamlConfig(
            *ConfigPathFactory.get_path_to_config_files(path))
        log_reader = LogReader(whylog_config)
        effect_line = FrontInput(
            effect_line_offset, line_content,
            LineSource(
                'localhost',
                os.path.join(path, self._get_starting_file_name(input_path))))

        results = log_reader.get_causes(effect_line)
        expected_results = self._investigation_results_from_yaml(
            results_yaml_file, result_log_file)
        self._check_results(results, expected_results)