Exemplo n.º 1
0
def test_alerta_required_error(alerta_api_url, expected_data):
    try:
        rule = {
            'name': 'Test Alerta rule!',
            'timeframe': datetime.timedelta(hours=1),
            'timestamp_field': '@timestamp',
            'type': 'any',
            'alert': 'alerta'
        }

        if alerta_api_url:
            rule['alerta_api_url'] = alerta_api_url

        rules_loader = FileRulesLoader({})
        rules_loader.load_modules(rule)
        alert = AlertaAlerter(rule)

        actual_data = alert.get_info()
        assert expected_data == actual_data
    except Exception as ea:
        assert expected_data in str(ea)
Exemplo n.º 2
0
def test_alerta_getinfo():
    rule = {
        'name': 'Test Alerta rule!',
        'alerta_api_url': 'http://*****:*****@timestamp',
        'type': 'any',
        'alert': 'alerta'
    }

    rules_loader = FileRulesLoader({})
    rules_loader.load_modules(rule)
    alert = AlertaAlerter(rule)

    expected_data = {
        'type': 'alerta',
        'alerta_url': 'http://elastalerthost:8080/api/alert'
    }
    actual_data = alert.get_info()

    assert expected_data == actual_data