Example #1
0
def test_extract_monitoring_info():
    module = 'paasta_tools.monitoring.config_providers'
    extract_method = module + '.extract_classic_monitoring_info'

    with mock.patch(extract_method, return_value=-1, autospec=True):
        assert extract_monitoring_info('classic', {}) == -1

    with pytest.raises(Exception):
        extract_monitoring_info('foobar', {})
def test_extract_monitoring_info():
    module = "paasta_tools.monitoring.config_providers"
    extract_method = module + ".extract_classic_monitoring_info"

    with mock.patch(extract_method, return_value=-1):
        assert extract_monitoring_info("classic", {}) == -1

    with pytest.raises(Exception):
        extract_monitoring_info("foobar", {})
def extract_replication_info(service_config):
    """Extract monitoring information from yelpsoa-configs

    To be monitored a service *must* supply a team.

    Mandatory keys:
        team: The team to send pages to
        notification_email: The email to send emails to
        service_type: Must be "classic" for this check to run

    :param service_config: The configuration dictionary for the service

    :returns (do_monitoring, monitoring_config): Which is a tuple of a bool
        and a monitoring dictionary that has keys specified by
        config_providers.monitoring_keys
    """
    monitoring_config = extract_monitoring_info('classic', service_config)

    # If we do not meet required information, do nothing
    if not (monitoring_config['team']
            and monitoring_config.get('service_type') == 'classic'):
        return False, {}
    return True, monitoring_config
def extract_replication_info(service_config):
    """Extract monitoring information from yelpsoa-configs

    To be monitored a service *must* supply a team.

    Mandatory keys:
        team: The team to send pages to
        notification_email: The email to send emails to
        service_type: Must be "classic" for this check to run

    :param service_config: The configuration dictionary for the service

    :returns (do_monitoring, monitoring_config): Which is a tuple of a bool
        and a monitoring dictionary that has keys specified by
        config_providers.monitoring_keys
    """
    monitoring_config = extract_monitoring_info('classic', service_config)

    # If we do not meet required information, do nothing
    if not (monitoring_config['team'] and
            monitoring_config.get('service_type') == 'classic'):
        return False, {}
    return True, monitoring_config