Ejemplo n.º 1
0
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)
Ejemplo n.º 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']
    )
Ejemplo n.º 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']
Ejemplo n.º 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']