Ejemplo n.º 1
0
    def test_parser_serialization(self):
        parser1 = RegexParserFactory.create_from_intent(self.parser_intent1)
        parser2 = RegexParserFactory.create_from_intent(self.parser_intent2)
        parser3 = RegexParserFactory.create_from_intent(self.parser_intent3)
        parsers_list = [parser1, parser2, parser3]

        parsers_dao_list = [parser.serialize() for parser in parsers_list]
        dumped_parsers = yaml.dump_all(parsers_dao_list, explicit_start=True)
        loaded_parsers = [
            RegexParserFactory.from_dao(dumped_parser)
            for dumped_parser in yaml.load_all(dumped_parsers)
        ]
        dumped_parsers_again = yaml.dump_all(
            [parser.serialize() for parser in loaded_parsers],
            explicit_start=True)

        assert dumped_parsers_again == dumped_parsers
Ejemplo n.º 2
0
    def test_parser_serialization(self):
        parser1 = RegexParserFactory.create_from_intent(self.parser_intent1)
        parser2 = RegexParserFactory.create_from_intent(self.parser_intent2)
        parser3 = RegexParserFactory.create_from_intent(self.parser_intent3)
        parsers_list = [parser1, parser2, parser3]

        parsers_dao_list = [parser.serialize() for parser in parsers_list]
        dumped_parsers = yaml.dump_all(parsers_dao_list, explicit_start=True)
        loaded_parsers = [
            RegexParserFactory.from_dao(dumped_parser)
            for dumped_parser in yaml.load_all(dumped_parsers)
        ]
        dumped_parsers_again = yaml.dump_all(
            [parser.serialize() for parser in loaded_parsers],
            explicit_start=True
        )

        assert dumped_parsers_again == dumped_parsers
Ejemplo n.º 3
0
    def setUpClass(cls):
        cls.connection_error_line = "2015-12-03 12:08:09 Connection error occurred on alfa36. Host name: 2"
        cls.data_migration_line = "2015-12-03 12:10:10 Data migration from alfa36 to alfa21 failed. Host name: 2"
        cls.lost_data_line = "2015-12-03 12:11:00 Data is missing at alfa21. Loss = 567.02 GB. Host name: 101"
        cls.root_cause_line = "root cause"
        cls.data_missing_line = "2015-12-03 12:11:00 Data is missing"
        cls.data_missing_at_line = "2015-12-03 12:11:00 Data is missing at alfa21"
        cls.dummy_line = "dummy regex"

        regex1 = "^(\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d) Connection error occurred on (.*)\. Host name: (.*)$"
        regex2 = "^(\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d) Data migration from (.*) to (.*) failed\. Host name: (.*)$"
        regex3 = "^(\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d) Data is missing at (.*)\. Loss = (.*) GB\. Host name: (.*)$"
        regex4 = "^root cause$"
        regex5 = "^(\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d) Data is missing"
        regex6 = "^(\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d) Data is missing at (.*)$"
        regex7 = "^dummy regex"

        date_group = LineParamGroup(None, to_date)
        string_group = LineParamGroup(None, to_string)
        float_group = LineParamGroup(None, to_float)

        regex_type = AssistantType.REGEX

        # yapf: disable
        parser_intent1 = UserParserIntent(
            regex_type, "connectionerror", regex1, "hydra", [1], {
                1: date_group,
                2: string_group,
                3: string_group
            }, cls.connection_error_line, 1, "serwer1"
        )
        parser_intent2 = UserParserIntent(
            regex_type, "datamigration", regex2, "hydra", [1], {
                1: date_group,
                2: string_group,
                3: string_group,
                4: string_group
            }, cls.data_migration_line, 2, "serwer2"
        )
        parser_intent3 = UserParserIntent(
            regex_type, "lostdata", regex3, "filesystem", [1], {
                1: date_group,
                2: string_group,
                3: float_group,
                4: string_group
            }, cls.lost_data_line, 3, "serwer3"
        )
        parser_intent4 = UserParserIntent(
            regex_type, "rootcause", regex4, "filesystem", [], {}, cls.root_cause_line, 4, "serwer4"
        )
        parser_intent5 = UserParserIntent(
            regex_type, "date", regex5, "filesystem", [1], {1: date_group}, cls.data_missing_line,
            5, "serwer5"
        )
        parser_intent6 = UserParserIntent(
            regex_type, "onlymissdata", regex6, "filesystem", [1], {
                1: date_group,
                2: string_group
            }, cls.data_missing_at_line, 6, "serwer6"
        )
        parser_intent7 = UserParserIntent(
            regex_type, "dummy", regex7, "filesystem", [], {}, cls.dummy_line, 7, "serwer7"
        )
        # yapf: enable

        cls.connection_error = RegexParserFactory.create_from_intent(parser_intent1)
        cls.data_migration = RegexParserFactory.create_from_intent(parser_intent2)
        cls.lost_data = RegexParserFactory.create_from_intent(parser_intent3)
        cls.root_cause = RegexParserFactory.create_from_intent(parser_intent4)
        cls.lost_data_date = RegexParserFactory.create_from_intent(parser_intent5)
        cls.lost_data_suffix = RegexParserFactory.create_from_intent(parser_intent6)
        cls.dummy_parser = RegexParserFactory.create_from_intent(parser_intent7)
        cls.no_lost_data_parser_list = cls.get_no_lost_data_parser_list()
Ejemplo n.º 4
0
 def _create_parsers_from_intents(cls, user_rule_intent):
     return dict(
         (intent_id, RegexParserFactory.create_from_intent(parser_intent))
         for intent_id, parser_intent in six.iteritems(
             user_rule_intent.parsers))
Ejemplo n.º 5
0
 def _create_parsers_from_intents(cls, user_rule_intent):
     return dict(
         (intent_id, RegexParserFactory.create_from_intent(parser_intent))
         for intent_id, parser_intent in six.iteritems(user_rule_intent.parsers)
     )
Ejemplo n.º 6
0
 def _load_parsers(self):
     return dict(
         (parser_definition["name"], RegexParserFactory.from_dao(parser_definition))
         for parser_definition in self._load_file_with_config(self._parsers_path)
     )
Ejemplo n.º 7
0
 def _load_parsers(self):
     return dict((parser_definition["name"],
                  RegexParserFactory.from_dao(parser_definition))
                 for parser_definition in self._load_file_with_config(
                     self._parsers_path))
Ejemplo n.º 8
0
    def setUpClass(cls):
        cls.connection_error_line = "2015-12-03 12:08:09 Connection error occurred on alfa36. Host name: 2"
        cls.data_migration_line = "2015-12-03 12:10:10 Data migration from alfa36 to alfa21 failed. Host name: 2"
        cls.lost_data_line = "2015-12-03 12:11:00 Data is missing at alfa21. Loss = 567.02 GB. Host name: 101"
        cls.root_cause_line = "root cause"
        cls.data_missing_line = "2015-12-03 12:11:00 Data is missing"
        cls.data_missing_at_line = "2015-12-03 12:11:00 Data is missing at alfa21"
        cls.dummy_line = "dummy regex"

        regex1 = "^(\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d) Connection error occurred on (.*)\. Host name: (.*)$"
        regex2 = "^(\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d) Data migration from (.*) to (.*) failed\. Host name: (.*)$"
        regex3 = "^(\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d) Data is missing at (.*)\. Loss = (.*) GB\. Host name: (.*)$"
        regex4 = "^root cause$"
        regex5 = "^(\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d) Data is missing"
        regex6 = "^(\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d) Data is missing at (.*)$"
        regex7 = "^dummy regex"

        date_group = LineParamGroup(None, to_date)
        string_group = LineParamGroup(None, to_string)
        float_group = LineParamGroup(None, to_float)

        regex_type = AssistantType.REGEX

        # yapf: disable
        parser_intent1 = UserParserIntent(
            regex_type, "connectionerror", regex1, "hydra", [1], {
                1: date_group,
                2: string_group,
                3: string_group
            }, cls.connection_error_line, 1, "serwer1"
        )
        parser_intent2 = UserParserIntent(
            regex_type, "datamigration", regex2, "hydra", [1], {
                1: date_group,
                2: string_group,
                3: string_group,
                4: string_group
            }, cls.data_migration_line, 2, "serwer2"
        )
        parser_intent3 = UserParserIntent(
            regex_type, "lostdata", regex3, "filesystem", [1], {
                1: date_group,
                2: string_group,
                3: float_group,
                4: string_group
            }, cls.lost_data_line, 3, "serwer3"
        )
        parser_intent4 = UserParserIntent(
            regex_type, "rootcause", regex4, "filesystem", [], {}, cls.root_cause_line, 4, "serwer4"
        )
        parser_intent5 = UserParserIntent(
            regex_type, "date", regex5, "filesystem", [1], {1: date_group}, cls.data_missing_line,
            5, "serwer5"
        )
        parser_intent6 = UserParserIntent(
            regex_type, "onlymissdata", regex6, "filesystem", [1], {
                1: date_group,
                2: string_group
            }, cls.data_missing_at_line, 6, "serwer6"
        )
        parser_intent7 = UserParserIntent(
            regex_type, "dummy", regex7, "filesystem", [], {}, cls.dummy_line, 7, "serwer7"
        )
        # yapf: enable

        cls.connection_error = RegexParserFactory.create_from_intent(
            parser_intent1)
        cls.data_migration = RegexParserFactory.create_from_intent(
            parser_intent2)
        cls.lost_data = RegexParserFactory.create_from_intent(parser_intent3)
        cls.root_cause = RegexParserFactory.create_from_intent(parser_intent4)
        cls.lost_data_date = RegexParserFactory.create_from_intent(
            parser_intent5)
        cls.lost_data_suffix = RegexParserFactory.create_from_intent(
            parser_intent6)
        cls.dummy_parser = RegexParserFactory.create_from_intent(
            parser_intent7)
        cls.no_lost_data_parser_list = cls.get_no_lost_data_parser_list()