def test_regex_string(self):
     filter = EventsFilter(regex="lalala")
     self.assertEqual(filter._regex, re.compile("lalala", re.MULTILINE | re.DOTALL))
     self.assertEqual(filter._regex.pattern, "lalala")
     self.assertEqual(filter.regex, "lalala")
     self.assertEqual(filter, pickle.loads(pickle.dumps(filter)))
     filter.to_json()
 def test_regex_pattern(self):
     pattern = re.compile("lalala")
     filter = EventsFilter(regex=pattern)
     self.assertEqual(filter._regex, pattern)
     self.assertEqual(filter.regex, pattern.pattern)
     self.assertEqual(filter, pickle.loads(pickle.dumps(filter)))
     filter.to_json()
 def test_eval_filter_event_class_common_parent(self):
     filter = EventsFilter(event_class=DatabaseLogEvent)
     self.assertEqual(filter, pickle.loads(pickle.dumps(filter)))
     filter.to_json()
     event1 = DatabaseLogEvent.BAD_ALLOC()
     event2 = DatabaseLogEvent.NO_SPACE_ERROR()
     self.assertTrue(filter.eval_filter(event1))
     self.assertTrue(filter.eval_filter(event2))
 def test_regex_pattern(self):
     pattern = re.compile("lalala")
     db_events_filter = EventsFilter(regex=pattern)
     self.assertEqual(db_events_filter._regex, pattern)  # pylint: disable=protected-access
     self.assertEqual(db_events_filter.regex, pattern.pattern)
     self.assertEqual(db_events_filter,
                      pickle.loads(pickle.dumps(db_events_filter)))
     db_events_filter.to_json()
 def test_eval_filter_event_class_and_regex(self):
     filter = EventsFilter(event_class=DatabaseLogEvent.BAD_ALLOC, regex=".*xyz.*")
     event1 = DatabaseLogEvent.BAD_ALLOC().add_info(node="node1", line="xyz", line_number=1)
     event2 = DatabaseLogEvent.NO_SPACE_ERROR().add_info(node="node1", line="xyz", line_number=1)
     event3 = DatabaseLogEvent.NO_SPACE_ERROR().add_info(node="node1", line="abc", line_number=1)
     self.assertTrue(filter.eval_filter(event1))
     self.assertFalse(filter.eval_filter(event2))
     self.assertFalse(filter.eval_filter(event3))
 def test_regex_string(self):
     db_events_filter = EventsFilter(regex="lalala")
     self.assertEqual(
         db_events_filter._regex,  # pylint: disable=protected-access
         re.compile("lalala", re.MULTILINE | re.DOTALL))
     self.assertEqual(db_events_filter._regex.pattern, "lalala")  # pylint: disable=protected-access
     self.assertEqual(db_events_filter.regex, "lalala")
     self.assertEqual(db_events_filter,
                      pickle.loads(pickle.dumps(db_events_filter)))
     db_events_filter.to_json()
    def test_ycsb_filter(self):
        with self.wait_for_n_events(self.get_events_logger(), count=4, timeout=3):
            with EventsFilter(event_class=YcsbStressEvent,
                              regex=".*Internal server error: exceptions::unavailable_exception.*"):
                YcsbStressEvent.error(
                    node="Node alternator-3h-silence--loader-node-bb90aa05-2"
                         " [34.251.153.122 | 10.0.220.55] (seed: False)",
                    stress_cmd="ycsb",
                    errors=["237951 [Thread-47] ERROR site.ycsb.db.DynamoDBClient"
                            " -com.amazonaws.AmazonServiceException: Internal server error:"
                            " exceptions::unavailable_exception (Cannot achieve consistency"
                            " level for cl LOCAL_ONE. Requires 1, alive 0) (Service: AmazonDynamoDBv2;"
                            " Status Code: 500; Error Code: Internal Server Error; Request ID: null)"]).publish()
                TestFrameworkEvent(source="", source_method="").publish()

        log_content = self.get_event_log_file("events.log")

        self.assertIn("TestFrameworkEvent", log_content)
        self.assertNotIn("YcsbStressEvent", log_content)

        with self.wait_for_n_events(self.get_events_logger(), count=1):
            YcsbStressEvent.error(
                node="Node alternator-3h-silence--loader-node-bb90aa05-2"
                     " [34.251.153.122 | 10.0.220.55] (seed: False)",
                stress_cmd="ycsb",
                errors=["237951 [Thread-47] ERROR site.ycsb.db.DynamoDBClient"
                        " -com.amazonaws.AmazonServiceException: Internal server error:"
                        " exceptions::unavailable_exception (Cannot achieve consistency"
                        " level for cl LOCAL_ONE. Requires 1, alive 0) (Service: AmazonDynamoDBv2;"
                        " Status Code: 500; Error Code: Internal Server Error; Request ID: null)"]).publish()

        log_content = self.get_event_log_file("events.log")

        self.assertIn("TestFrameworkEvent", log_content)
        self.assertIn("YcsbStressEvent", log_content)
    def test_general_filter(self):
        with self.wait_for_n_events(self.get_events_logger(), count=4, timeout=3):
            with EventsFilter(event_class=CoreDumpEvent):
                CoreDumpEvent(corefile_url="http://",
                              backtrace="asfasdfsdf",
                              node="node xy",
                              download_instructions="test_general_filter",
                              timestamp=1578998425.0).publish()  # Tue 2020-01-14 10:40:25 UTC
                TestFrameworkEvent(source="", source_method="").publish()

        log_content = self.get_event_log_file("events.log")

        self.assertIn("TestFrameworkEvent", log_content)
        self.assertNotIn("test_general_filter", log_content)
 def test_eval_filter_event_class(self):
     db_events_filter = EventsFilter(event_class=DatabaseLogEvent.BAD_ALLOC)
     self.assertEqual(db_events_filter,
                      pickle.loads(pickle.dumps(db_events_filter)))
     db_events_filter.to_json()
     event1 = DatabaseLogEvent.BAD_ALLOC()
     event2 = DatabaseLogEvent.NO_SPACE_ERROR()
     self.assertTrue(db_events_filter.eval_filter(event1))
     self.assertFalse(db_events_filter.eval_filter(event2))
    def test_general_filter_regex(self):
        with self.wait_for_n_events(self.get_events_logger(), count=4, timeout=3):
            with EventsFilter(regex=".*1234567890.*") as filter:
                CoreDumpEvent(corefile_url="http://",
                              backtrace="asfasdfsdf",
                              node="node xy",
                              download_instructions="gsutil cp gs://upload.scylladb.com/core.scylla-jmx.996.1234567890"
                                                    ".3968.1566979933000/core.scylla-jmx.996.d173729352e34c76aaf8db334"
                                                    "2153c3e.3968.1566979933000000 .",
                              timestamp=1578998425.0).publish()  # Tue 2020-01-14 10:40:25 UTC
                TestFrameworkEvent(source="", source_method="").publish()

        log_content = self.get_event_log_file("events.log")

        self.assertIn("TestFrameworkEvent", log_content)
        self.assertNotIn("1234567890", log_content)
def ignore_ycsb_connection_refused():
    with EventsFilter(
            event_class=YcsbStressEvent,
            regex='*Unable to execute HTTP request: Connection refused.*'):
        yield
Exemple #12
0
def ignore_view_error_gate_closed_exception():
    with EventsFilter(
            event_class=DatabaseLogEvent,
            regex='.*view - Error applying view update.*gate_closed_exception'
    ):
        yield
 def test_event_class_and_regex_none(self):
     filter = EventsFilter(event_class=DatabaseLogEvent, regex=None)
     self.assertEqual(filter.event_class, "DatabaseLogEvent.")
     self.assertIsNone(filter.regex)