示例#1
0
文件: log.py 项目: kmaehashi/jubatest
 def test_node(self):
     filter2 = LogFilter(
         Log.parse_logs('anotherhost', sample_log + sample_log))
     filter3 = LogFilter(self.filter.get() + filter2.get())
     self.assertEqual(9, len(filter3.get()))
     self.assertEqual(3, len(filter3.node('localhost').get()))
     self.assertEqual(6, len(filter3.node('anotherhost').get()))
示例#2
0
文件: log.py 项目: kumagi/jubatest
 def test_node(self):
     filter2 = LogFilter(Log.parse_logs('anotherhost', sample_log + sample_log))
     filter3 = LogFilter(self.filter.get() + filter2.get())
     self.assertEqual(9, len(filter3.get()))
     self.assertEqual(3, len(filter3.node('localhost').get()))
     self.assertEqual(6, len(filter3.node('anotherhost').get()))
示例#3
0
文件: log.py 项目: kumagi/jubatest
 def setUp(self):
     self.filter = LogFilter(Log.parse_logs('localhost', sample_log))
示例#4
0
文件: log.py 项目: kumagi/jubatest
class LogFilterTest(JubaTestCase):
    def setUp(self):
        self.filter = LogFilter(Log.parse_logs('localhost', sample_log))

    def test_type(self):
        self.assertEqual(3, len(self.filter.get()))
        self.assertEqual(0, len(self.filter.type('test').get()))
        self.assertEqual(1, len(self.filter.type('zookeeper').get()))
        self.assertEqual(2, len(self.filter.type('jubatus').get()))

    def test_node(self):
        filter2 = LogFilter(Log.parse_logs('anotherhost', sample_log + sample_log))
        filter3 = LogFilter(self.filter.get() + filter2.get())
        self.assertEqual(9, len(filter3.get()))
        self.assertEqual(3, len(filter3.node('localhost').get()))
        self.assertEqual(6, len(filter3.node('anotherhost').get()))

    def test_level(self):
        self.assertEqual(2, len(self.filter.level(LogLevel.INFO).get()))
        self.assertEqual(1, len(self.filter.level(LogLevel.ERROR).get()))
        self.assertEqual(0, len(self.filter.level(LogLevel.WARN).get()))

    def test_time_range(self):
        log0 = self.filter.get()[0]
        log1 = self.filter.get()[1]
        log2 = self.filter.get()[2]

        begin = log0.time + timedelta(0, 0, 1)
        end = log2.time - timedelta(0, 0, 1)

        result = self.filter.time_range(begin, end)
        self.assertEqual(1, len(result.get()))
        self.assertEqual(log1, result.get()[0])

    def test_message(self):
        self.assertEqual(2, len(self.filter.message('config').get()))
        self.assertEqual(2, len(self.filter.message('2181').get()))

    def test_consume(self):
        log1 = self.filter.get()[1]
        self.assertEqual(1, len(self.filter.consume(log1).get()))

    def test_get(self):
        self.assertEqual(3, len(self.filter.get()))