def test_haproxy_log_file_parsed(self):
     """Check that log files are parsed."""
     log_file = HaproxyLogFile(
         logfile='haproxy/tests/files/small.log'
     )
     self.assertEqual(log_file.cmd_counter(), 0)
     log_file.parse_file()
     self.assertTrue(log_file.cmd_counter() > 0)
Пример #2
0
 def test_haproxy_log_file_parsed(self):
     """Check that log files are parsed."""
     log_file = HaproxyLogFile(
         logfile='haproxy/tests/files/small.log'
     )
     self.assertEqual(log_file.cmd_counter(), 0)
     log_file.parse_file()
     self.assertTrue(log_file.cmd_counter() > 0)
 def test_haproxy_log_file_valid_and_invalid_lines(self):
     """Check that if some log lines can not be parsed both numbers are
     correctly reported.
     """
     log_file = HaproxyLogFile(
         logfile='haproxy/tests/files/2_ok_1_invalid.log'
     )
     log_file.parse_file()
     self.assertEqual(log_file.cmd_counter(), 2)
     self.assertEqual(log_file.cmd_counter_invalid(), 1)
Пример #4
0
 def test_haproxy_log_file_valid_and_invalid_lines(self):
     """Check that if some log lines can not be parsed both numbers are
     correctly reported.
     """
     log_file = HaproxyLogFile(
         logfile='haproxy/tests/files/2_ok_1_invalid.log'
     )
     log_file.parse_file()
     self.assertEqual(log_file.cmd_counter(), 2)
     self.assertEqual(log_file.cmd_counter_invalid(), 1)
    def test_haproxy_log_file_negate_filter(self):
        """Check that reversing a filter output works as expected."""
        filter_func = filters.filter_ssl()
        log_file = HaproxyLogFile(
            logfile='haproxy/tests/files/connection.log',
        )
        log_file.parse_file()

        # total number of log lines
        self.assertEqual(log_file.cmd_counter(), 12)

        # only SSL lines
        only_ssl = log_file.filter(filter_func)
        self.assertEqual(only_ssl.cmd_counter(), 7)

        # non SSL lines
        non_ssl = log_file.filter(filter_func, reverse=True)
        self.assertEqual(non_ssl.cmd_counter(), 5)

        # we did get all lines?
        self.assertEqual(
            log_file.cmd_counter(),
            only_ssl.cmd_counter() + non_ssl.cmd_counter()
        )
Пример #6
0
    def test_haproxy_log_file_negate_filter(self):
        """Check that reversing a filter output works as expected."""
        filter_func = filters.filter_ssl()
        log_file = HaproxyLogFile(
            logfile='haproxy/tests/files/connection.log',
        )
        log_file.parse_file()

        # total number of log lines
        self.assertEqual(log_file.cmd_counter(), 12)

        # only SSL lines
        only_ssl = log_file.filter(filter_func)
        self.assertEqual(only_ssl.cmd_counter(), 7)

        # non SSL lines
        non_ssl = log_file.filter(filter_func, reverse=True)
        self.assertEqual(non_ssl.cmd_counter(), 5)

        # we did get all lines?
        self.assertEqual(
            log_file.cmd_counter(),
            only_ssl.cmd_counter() + non_ssl.cmd_counter()
        )