def test_cant_connect(init_config, instance, aggregator):
    ambari = AmbariCheck(init_config=init_config, instances=[instance])
    ambari._make_request = MagicMock(return_value=None)

    try:
        ambari.get_clusters('localhost')
    except CheckException:
        pass
    aggregator.assert_service_check(name="ambari.can_connect",
                                    status=AgentCheck.CRITICAL)
Beispiel #2
0
def test_cant_connect(init_config, instance, aggregator):
    instance['tags'] = ['foo:bar']
    ambari = AmbariCheck('Ambari', init_config, [instance])
    ambari._make_request = MagicMock(return_value=None)

    try:
        ambari.get_clusters()
    except CheckException:
        pass
    aggregator.assert_service_check(
        name="ambari.can_connect", status=AgentCheck.CRITICAL, tags=['foo:bar', 'url:localhost']
    )
Beispiel #3
0
def test_get_clusters(init_config, instance, aggregator):
    ambari = AmbariCheck(init_config=init_config, instances=[instance])
    ambari._make_request = MagicMock(
        return_value={
            'href': 'localhost/api/v1/clusters',
            'items': [{'href': 'localhost/api/v1/clusters/LabCluster', 'Clusters': {'cluster_name': 'LabCluster'}}],
        }
    )

    clusters = ambari.get_clusters('localhost', ['foo:bar'])

    ambari._make_request.assert_called_with('localhost/api/v1/clusters')
    aggregator.assert_service_check(name="ambari.can_connect", status=AgentCheck.OK, tags=['foo:bar', 'url:localhost'])
    assert clusters == ['LabCluster']
Beispiel #4
0
def test_get_clusters(init_config, instance):
    ambari = AmbariCheck(init_config=init_config, instances=[instance])
    ambari._make_request = MagicMock(
        return_value={
            'href':
            'localhost/api/v1/clusters',
            'items': [{
                'href': 'localhost/api/v1/clusters/LabCluster',
                'Clusters': {
                    'cluster_name': 'LabCluster'
                }
            }],
        })

    clusters = ambari.get_clusters('localhost')

    ambari._make_request.assert_called_with('localhost/api/v1/clusters')
    assert clusters == ['LabCluster']