コード例 #1
0
def test_bad_value_in_env_var():
    settings = global_settings()
    assert settings.utilization.logical_processors == 0

    local_config, = AgentProtocol._connect_payload('', [], [], settings)
    util_conf = local_config['utilization'].get('config')
    assert util_conf == {'hostname': 'env-hostname', 'total_ram_mib': 98765}
コード例 #2
0
def test_billing_hostname_with_set_in_ini_not_in_env():
    settings = global_settings()
    assert settings.utilization.billing_hostname == 'file-hostname'

    local_config, = AgentProtocol._connect_payload('', [], [], settings)
    util_conf = local_config['utilization'].get('config')
    assert util_conf == {'hostname': 'file-hostname'}
コード例 #3
0
def test_billing_hostname_from_env_vars():
    settings = global_settings()
    assert settings.utilization.billing_hostname == 'env-hostname'

    local_config, = AgentProtocol._connect_payload('', [], [], settings)
    util_conf = local_config['utilization'].get('config')
    assert util_conf == {'hostname': 'env-hostname'}
コード例 #4
0
def test_billing_hostname_precedence():
    # ini-file takes precedence over env vars
    settings = global_settings()
    assert settings.utilization.billing_hostname == 'file-hostname'

    local_config, = AgentProtocol._connect_payload('', [], [], settings)
    util_conf = local_config['utilization'].get('config')
    assert util_conf == {'hostname': 'file-hostname'}
コード例 #5
0
def test_billing_hostname_with_blank_ini_file_no_env():
    settings = global_settings()
    assert settings.utilization.billing_hostname is None

    # if no utilization config settings are set, the 'config' section is not in
    # the payload at all
    local_config, = AgentProtocol._connect_payload('', [], [], settings)
    util_conf = local_config['utilization'].get('config')
    assert util_conf is None
コード例 #6
0
    def _test_utilization_data():

        data = _get_response_body_for_test(test)
        client_cls = create_client_cls(200, data)
        monkeypatch.setattr(CommonUtilization, "CLIENT_CLS", client_cls)

        with UpdatedSettings() as settings:
            # Ignoring docker will ensure that there is nothing extra in the
            # gathered utilization data
            monkeypatch.setattr(settings.utilization, "detect_docker", False)

            local_config, = AgentProtocol._connect_payload(
                '', [], [], settings)
            util_output = local_config['utilization']
            expected_output = test['expected_output_json']

            # The agent does not record full_hostname and it's not required
            expected_output.pop("full_hostname")

            assert expected_output == util_output