Пример #1
0
def test_counter_eq_derive():
    """Test parsing of counters when expecting derives and vice versa"""

    def run_parse(parse_func):
        def wrapped(data):
            return list(parse_func(data))

        return wrapped

    types = "false_counter value:COUNTER:U:U\nfalse_derive value:DERIVE:U:U\n"
    with t.unlinking(t.temp_file(TYPESDB + types)) as path:
        parser = bucky.collectd.CollectDParser(types_dbs=[path])
        for pkts_file in ('collectd-counter.pkts', 'collectd-derive.pkts'):
            for data in pkts(pkts_file):
                t.not_raises(ProtocolError, run_parse(parser.parse), data)
        for pkts_file in ('collectd-false-counter.pkts',
                          'collectd-false-derive.pkts'):
            for data in pkts(pkts_file):
                t.raises(ProtocolError, run_parse(parser.parse), data)

        parser = bucky.collectd.CollectDParser(types_dbs=[path],
                                               counter_eq_derive=True)
        for pkts_file in ('collectd-counter.pkts', 'collectd-derive.pkts',
                          'collectd-false-counter.pkts',
                          'collectd-false-derive.pkts'):
            for data in pkts(pkts_file):
                t.not_raises(ProtocolError, run_parse(parser.parse), data)
Пример #2
0
def test_counter_eq_derive():
    """Test parsing of counters when expecting derives and vice versa"""
    def run_parse(parse_func):
        def wrapped(data):
            return list(parse_func(data))

        return wrapped

    types = "false_counter value:COUNTER:U:U\nfalse_derive value:DERIVE:U:U\n"
    with t.unlinking(t.temp_file(TYPESDB + types)) as path:
        parser = bucky.collectd.CollectDParser(types_dbs=[path])
        for pkts_file in ('collectd-counter.pkts', 'collectd-derive.pkts'):
            for data in pkts(pkts_file):
                t.not_raises(ProtocolError, run_parse(parser.parse), data)
        for pkts_file in ('collectd-false-counter.pkts',
                          'collectd-false-derive.pkts'):
            for data in pkts(pkts_file):
                t.raises(ProtocolError, run_parse(parser.parse), data)

        parser = bucky.collectd.CollectDParser(types_dbs=[path],
                                               counter_eq_derive=True)
        for pkts_file in ('collectd-counter.pkts', 'collectd-derive.pkts',
                          'collectd-false-counter.pkts',
                          'collectd-false-derive.pkts'):
            for data in pkts(pkts_file):
                t.not_raises(ProtocolError, run_parse(parser.parse), data)
Пример #3
0
def test_sigterm_handling():
    alarm_thread = threading.Timer(2, os.kill, (os.getpid(), 15))
    alarm_thread.start()
    bucky = Bucky(cfg)
    t.not_raises(BuckyError, bucky.run)