Ejemplo n.º 1
0
    def test_service_check_tags(self):
        stats = MetricsAggregator('myhost')
        stats.submit_packets('_sc|check.1|0')
        stats.submit_packets('_sc|check.2|0|#t1')
        stats.submit_packets('_sc|check.3|0|h:i-abcd1234|#t1,t2|m:fakeout#t5')
        stats.submit_packets('_sc|check.4|0|#t1,t2:v2,t3,t4')

        service_checks = self.sort_service_checks(stats.flush_service_checks())

        assert len(service_checks) == 4
        first, second, third, fourth = service_checks

        nt.assert_equal(first['check'], 'check.1')
        assert first.get('tags') is None, "service_check['tags'] shouldn't be" + \
            "defined when no tags aren't explicited in the packet"

        nt.assert_equal(second['check'], 'check.2')
        nt.assert_equal(second['tags'], sorted(['t1']))

        nt.assert_equal(third['check'], 'check.3')
        nt.assert_equal(third['host_name'], 'i-abcd1234')
        nt.assert_equal(third['message'], 'fakeout#t5')
        nt.assert_equal(third['tags'], sorted(['t1', 't2']))

        nt.assert_equal(fourth['check'], 'check.4')
        nt.assert_equal(fourth['tags'], sorted(['t1', 't2:v2', 't3', 't4']))
Ejemplo n.º 2
0
    def test_service_check_tags(self):
        stats = MetricsAggregator('myhost')
        stats.submit_packets('_sc|check.1|0')
        stats.submit_packets('_sc|check.2|0|#t1')
        stats.submit_packets('_sc|check.3|0|h:i-abcd1234|#t1,t2|m:fakeout#t5')
        stats.submit_packets('_sc|check.4|0|#t1,t2:v2,t3,t4')

        service_checks = self.sort_service_checks(stats.flush_service_checks())

        assert len(service_checks) == 4
        first, second, third, fourth = service_checks

        nt.assert_equal(first['check'], 'check.1')
        assert first.get('tags') is None, "service_check['tags'] shouldn't be" + \
                                        "defined when no tags aren't explicited in the packet"

        nt.assert_equal(second['check'], 'check.2')
        nt.assert_equal(second['tags'], sorted(['t1']))

        nt.assert_equal(third['check'], 'check.3')
        nt.assert_equal(third['host_name'], 'i-abcd1234')
        nt.assert_equal(third['message'], 'fakeout#t5')
        nt.assert_equal(third['tags'], sorted(['t1', 't2']))

        nt.assert_equal(fourth['check'], 'check.4')
        nt.assert_equal(fourth['tags'], sorted(['t1', 't2:v2', 't3', 't4']))
Ejemplo n.º 3
0
    def test_service_check_basic(self):
        stats = MetricsAggregator('myhost')
        stats.submit_packets('_sc|check.1|0')
        stats.submit_packets('_sc|check.2|1')
        stats.submit_packets('_sc|check.3|2')

        service_checks = self.sort_service_checks(stats.flush_service_checks())

        assert len(service_checks) == 3
        first, second, third = service_checks

        nt.assert_equal(first['check'], 'check.1')
        nt.assert_equal(first['status'], 0)
        nt.assert_equal(second['check'], 'check.2')
        nt.assert_equal(second['status'], 1)
        nt.assert_equal(third['check'], 'check.3')
        nt.assert_equal(third['status'], 2)
Ejemplo n.º 4
0
    def test_service_check_basic(self):
        stats = MetricsAggregator('myhost')
        stats.submit_packets('_sc|check.1|0')
        stats.submit_packets('_sc|check.2|1')
        stats.submit_packets('_sc|check.3|2')

        service_checks = self.sort_service_checks(stats.flush_service_checks())

        assert len(service_checks) == 3
        first, second, third = service_checks

        nt.assert_equal(first['check'], 'check.1')
        nt.assert_equal(first['status'], 0)
        nt.assert_equal(second['check'], 'check.2')
        nt.assert_equal(second['status'], 1)
        nt.assert_equal(third['check'], 'check.3')
        nt.assert_equal(third['status'], 2)
Ejemplo n.º 5
0
    def test_service_check_basic(self):
        stats = MetricsAggregator('myhost')
        stats.submit_packets('_sc|check.1|0')
        stats.submit_packets('_sc|check.2|1')
        stats.submit_packets('_sc|check.3|2')

        service_checks = self.sort_service_checks(stats.flush_service_checks())

        assert len(service_checks) == 3
        first, second, third = service_checks

        assert first['check'] == 'check.1'
        assert first['status'] == 0
        assert second['check'] == 'check.2'
        assert second['status'] == 1
        assert third['check'] == 'check.3'
        assert third['status'] == 2
Ejemplo n.º 6
0
    def test_service_check_tag_key_ends_with_m(self):
        stats = MetricsAggregator('myhost')
        stats.submit_packets('_sc|check.1|0|#keym:value')
        stats.submit_packets('_sc|check.2|0|#key2m:value|m:fakeout')
        stats.submit_packets('_sc|check.3|0|#key:valuem:value2,key2:value2|m:fakeoutm\:|h:#5')

        service_checks = self.sort_service_checks(stats.flush_service_checks())
        assert len(service_checks) == 3
        first, second, third = service_checks

        assert first['check'] == 'check.1'
        assert first['tags'] == ['keym:value']
        assert 'message' not in first
        assert second['check'] == 'check.2'
        assert second['tags'] == ['key2m:value']
        assert second['message'] == 'fakeout'
        assert third['check'] == 'check.3'
        assert third['tags'] == sorted(['key:valuem:value2', 'key2:value2'])
        assert third['message'] == 'fakeoutm:|h:#5'
Ejemplo n.º 7
0
    def test_service_check_message(self):
        stats = MetricsAggregator('myhost')
        stats.submit_packets('_sc|check.1|0|m:testing')
        stats.submit_packets('_sc|check.2|0|m:First line\\nSecond line')
        stats.submit_packets(u'_sc|check.3|0|m:♬ †øU †øU ¥ºu T0µ ♪')
        stats.submit_packets('_sc|check.4|0|m:|t:|m\:|d:')

        service_checks = self.sort_service_checks(stats.flush_service_checks())

        assert len(service_checks) == 4
        first, second, third, fourth = service_checks

        nt.assert_equal(first['check'], 'check.1')
        nt.assert_equal(first['message'], 'testing')
        nt.assert_equal(second['check'], 'check.2')
        nt.assert_equal(second['message'], 'First line\nSecond line')
        nt.assert_equal(third['check'], 'check.3')
        nt.assert_equal(third['message'], u'♬ †øU †øU ¥ºu T0µ ♪')
        nt.assert_equal(fourth['check'], 'check.4')
        nt.assert_equal(fourth['message'], '|t:|m:|d:')
Ejemplo n.º 8
0
    def test_service_check_tag_key_ends_with_m(self):
        stats = MetricsAggregator('myhost')
        stats.submit_packets('_sc|check.1|0|#keym:value')
        stats.submit_packets('_sc|check.2|0|#key2m:value|m:fakeout')
        stats.submit_packets('_sc|check.3|0|#key:valuem:value2,key2:value2|m:fakeoutm\:|h:#5')

        service_checks = self.sort_service_checks(stats.flush_service_checks())

        assert len(service_checks) == 3
        first, second, third = service_checks

        nt.assert_equal(first['check'], 'check.1')
        nt.assert_equal(first['tags'], ['keym:value'])
        nt.assert_not_in('message', first)
        nt.assert_equal(second['check'], 'check.2')
        nt.assert_equal(second['tags'], ['key2m:value'])
        nt.assert_equal(second['message'], 'fakeout')
        nt.assert_equal(third['check'], 'check.3')
        nt.assert_equal(third['tags'], sorted(['key:valuem:value2', 'key2:value2']))
        nt.assert_equal(third['message'], 'fakeoutm:|h:#5')
Ejemplo n.º 9
0
    def test_service_check_message(self):
        stats = MetricsAggregator('myhost')
        stats.submit_packets('_sc|check.1|0|m:testing')
        stats.submit_packets('_sc|check.2|0|m:First line\\nSecond line')
        stats.submit_packets(u'_sc|check.3|0|m:♬ †øU †øU ¥ºu T0µ ♪')
        stats.submit_packets('_sc|check.4|0|m:|t:|m\:|d:')

        service_checks = self.sort_service_checks(stats.flush_service_checks())

        assert len(service_checks) == 4
        first, second, third, fourth = service_checks

        nt.assert_equal(first['check'], 'check.1')
        nt.assert_equal(first['message'], 'testing')
        nt.assert_equal(second['check'], 'check.2')
        nt.assert_equal(second['message'], 'First line\nSecond line')
        nt.assert_equal(third['check'], 'check.3')
        nt.assert_equal(third['message'], u'♬ †øU †øU ¥ºu T0µ ♪')
        nt.assert_equal(fourth['check'], 'check.4')
        nt.assert_equal(fourth['message'], '|t:|m:|d:')
Ejemplo n.º 10
0
    def test_service_check_tag_key_ends_with_m(self):
        stats = MetricsAggregator('myhost')
        stats.submit_packets('_sc|check.1|0|#keym:value')
        stats.submit_packets('_sc|check.2|0|#key2m:value|m:fakeout')
        stats.submit_packets('_sc|check.3|0|#key:valuem:value2,key2:value2|m:fakeoutm\:|h:#5')

        service_checks = self.sort_service_checks(stats.flush_service_checks())

        assert len(service_checks) == 3
        first, second, third = service_checks

        nt.assert_equal(first['check'], 'check.1')
        nt.assert_equal(first['tags'], ['keym:value'])
        #nt.assert_not_in('message', first)
        nt.assert_equal(second['check'], 'check.2')
        nt.assert_equal(second['tags'], ['key2m:value'])
        nt.assert_equal(second['message'], 'fakeout')
        nt.assert_equal(third['check'], 'check.3')
        nt.assert_equal(third['tags'], sorted(['key:valuem:value2', 'key2:value2']))
        nt.assert_equal(third['message'], 'fakeoutm:|h:#5')
    def test_service_check_message(self):
        stats = MetricsAggregator('myhost')
        stats.submit_packets('_sc|check.1|0|m:testing')
        stats.submit_packets('_sc|check.2|0|m:First line\\nSecond line')
        stats.submit_packets('_sc|check.3|0|m:♬ †øU †øU ¥ºu T0µ ♪')
        stats.submit_packets(r'_sc|check.4|0|m:|t:|m\:|d:')

        service_checks = self.sort_service_checks(stats.flush_service_checks())

        assert len(service_checks) == 4
        first, second, third, fourth = service_checks

        assert first['check'] == 'check.1'
        assert first['message'] == 'testing'
        assert second['check'] == 'check.2'
        assert second['message'] == 'First line\nSecond line'
        assert third['check'] == 'check.3'
        assert third['message'] == '♬ †øU †øU ¥ºu T0µ ♪'
        assert fourth['check'] == 'check.4'
        assert fourth['message'] == '|t:|m:|d:'