Exemplo n.º 1
0
def test_get_service_health_no_response(init_config, instance, aggregator):
    ambari = AmbariCheck('Ambari', init_config, [instance])
    ambari._make_request = MagicMock(return_value=None)

    ambari.get_service_checks('LabCluster', 'HDFS', service_tags=['ambari_cluster:LabCluster', 'ambari_service:hdfs'])

    ambari._make_request.assert_called_with('localhost/api/v1/clusters/LabCluster/services/HDFS?fields=ServiceInfo')
    aggregator.assert_service_check(
        name="ambari.state", status=AgentCheck.CRITICAL, tags=['ambari_cluster:LabCluster', 'ambari_service:hdfs']
    )
Exemplo n.º 2
0
def test_get_service_health(init_config, instance, aggregator):
    ambari = AmbariCheck('Ambari', init_config, [instance])
    ambari._make_request = MagicMock(return_value=responses.SERVICE_HEALTH_METRICS)

    ambari.get_service_checks('LabCluster', 'HDFS', service_tags=['ambari_cluster:LabCluster', 'ambari_service:hdfs'])

    ambari._make_request.assert_called_with('localhost/api/v1/clusters/LabCluster/services/HDFS?fields=ServiceInfo')
    aggregator.assert_service_check(
        name="ambari.state",
        status=AgentCheck.OK,
        tags=['ambari_cluster:LabCluster', 'ambari_service:hdfs', 'state:INSTALLED'],
    )
Exemplo n.º 3
0
def test_should_collect_service_status(instance):
    ambari = AmbariCheck('Ambari', {'collect_service_metrics': False, 'collect_service_status': True}, [instance])
    _mock_clusters(ambari)
    ambari.get_host_metrics = MagicMock()
    ambari.get_component_metrics = MagicMock()
    ambari.get_service_checks = MagicMock()
    ambari.check(instance)

    assert ambari.get_host_metrics.called
    assert not ambari.get_component_metrics.called
    assert ambari.get_service_checks.called