Esempio n. 1
0
def test_check(aggregator, instance):
    # type: (AggregatorStub, Dict[str, Any]) -> None
    check = IbmICheck('ibm_i', {}, [instance])
    check.check(instance)

    aggregator.assert_all_metrics_covered()
    aggregator.assert_metrics_using_metadata(get_metadata_metrics())
Esempio n. 2
0
def test_check_no_query_manager(aggregator, instance):
    check = IbmICheck('ibm_i', {}, [instance])
    check.log = mock.MagicMock()
    check.load_configuration_models()
    with mock.patch('datadog_checks.ibm_i.IbmICheck.fetch_system_info',
                    return_value=None):
        check.check(instance)
    assert check._query_manager is None
    check.log.warning.assert_called_once()
    aggregator.assert_all_metrics_covered()
Esempio n. 3
0
def test_check_query_error(aggregator, instance):
    check = IbmICheck('ibm_i', {}, [instance])
    check.log = mock.MagicMock()
    check.load_configuration_models()

    with mock.patch('datadog_checks.ibm_i.IbmICheck.fetch_system_info',
                    return_value=SystemInfo("host", 7, 4)), mock.patch(
                        'datadog_checks.ibm_i.IbmICheck.execute_query',
                        side_effect=Exception("boom")):
        assert check._query_manager is None
        check.check(instance)
        assert check._query_manager is not None
        assert check._query_manager.hostname == "host"
        check.check(instance)
    aggregator.assert_service_check("ibm_i.can_connect",
                                    count=2,
                                    status=AgentCheck.CRITICAL)
    aggregator.assert_all_metrics_covered()