Beispiel #1
0
def test_openmetrics_error(aggregator, instance, error_metrics):
    check = CertManagerCheck('cert_manager', {}, [MOCK_INSTANCE])
    with pytest.raises(Exception):
        check.check(MOCK_INSTANCE)
        aggregator.assert_service_check(
            'cert_manager.prometheus.health',
            status=CertManagerCheck.CRITICAL,
            tags=['endpoint:http://fake.tld/prometheus'],
            count=1,
        )
Beispiel #2
0
def test_check(aggregator, instance, mock_metrics):
    check = CertManagerCheck('cert_manager', {}, [MOCK_INSTANCE])
    check.check(MOCK_INSTANCE)

    for metric_name, metric_type in EXPECTED_METRICS.items():
        aggregator.assert_metric(metric_name, metric_type=metric_type)

    aggregator.assert_all_metrics_covered()

    aggregator.assert_service_check(
        'cert_manager.prometheus.health',
        status=CertManagerCheck.OK,
        tags=['endpoint:http://fake.tld/prometheus'],
        count=1,
    )
Beispiel #3
0
def test_config():
    with pytest.raises(CheckException):
        CertManagerCheck('cert_manager', {}, [{}])

    # this should not fail
    CertManagerCheck('cert_manager', {}, [MOCK_INSTANCE])