Exemple #1
0
def test_suppress_envoy_headers():
    # If we do not set the config, it should not appear.
    yaml = module_and_mapping_manifests(None, [])
    _test_router(yaml, expectations={})

    # If we set the config to false, it should not appear.
    yaml = module_and_mapping_manifests(['suppress_envoy_headers: false'], [])
    _test_router(yaml, expectations={})

    # If we set the config to true, it should appear.
    yaml = module_and_mapping_manifests(['suppress_envoy_headers: true'], [])
    _test_router(yaml, expectations={'suppress_envoy_headers': True})
def test_cluster_idle_timeout_ms_missing():
    # If we do not set the config, it should not appear in the Envoy conf.
    yaml = module_and_mapping_manifests(None, [])
    for v in SUPPORTED_ENVOY_VERSIONS:
        _test_common_http_protocol_options(yaml,
                                           expectations={},
                                           envoy_version=v)
def test_both_one_module_one_mapping():
    # If we set both configs, one on a Module, one on a Mapping, both should show up.
    yaml = module_and_mapping_manifests(["cluster_idle_timeout_ms: 4005"], ["cluster_max_connection_lifetime_ms: 2005"])
    _test_common_http_protocol_options(yaml, expectations={
        'max_connection_duration': '2.005s',
        'idle_timeout': '4.005s'
    })
def test_cluster_idle_timeout_ms_mapping_override():
    # If we set the config on the Module and Mapping, the Mapping value wins.
    yaml = module_and_mapping_manifests(["cluster_idle_timeout_ms: 4005"],
                                        ["cluster_idle_timeout_ms: 19105"])
    for v in SUPPORTED_ENVOY_VERSIONS:
        _test_common_http_protocol_options(
            yaml, expectations={'idle_timeout': '19.105s'}, envoy_version=v)
def test_cluster_idle_timeout_ms_mapping_only():
    # If we only set the config on the Mapping, it should show up.
    yaml = module_and_mapping_manifests(None,
                                        ["cluster_idle_timeout_ms: 4005"])
    for v in SUPPORTED_ENVOY_VERSIONS:
        _test_common_http_protocol_options(
            yaml, expectations={'idle_timeout': '4.005s'}, envoy_version=v)
def test_cluster_max_connection_lifetime_ms_module_only():
    # If we only set the config on the Module, it should show up.
    yaml = module_and_mapping_manifests(
        ["cluster_max_connection_lifetime_ms: 2005"], [])
    for v in SUPPORTED_ENVOY_VERSIONS:
        _test_common_http_protocol_options(
            yaml,
            expectations={'max_connection_duration': '2.005s'},
            envoy_version=v)
def test_cluster_max_connection_lifetime_ms_mapping_override():
    # If we set the config on the Module and Mapping, the Mapping value wins.
    yaml = module_and_mapping_manifests(
        ["cluster_max_connection_lifetime_ms: 2005"],
        ["cluster_max_connection_lifetime_ms: 17005"])
    for v in SUPPORTED_ENVOY_VERSIONS:
        _test_common_http_protocol_options(
            yaml,
            expectations={'max_connection_duration': '17.005s'},
            envoy_version=v)
def test_proper_case_and_enable_http_10():
    yaml = module_and_mapping_manifests(
        ["proper_case: true", "enable_http10: true"], [])
    _test_listener_http_protocol_options(yaml,
                                         expectations={
                                             'accept_http_10': True,
                                             'header_key_format': {
                                                 'proper_case_words': {}
                                             }
                                         })
Exemple #9
0
def test_all_listener_common_http_protocol_options():
    yaml = module_and_mapping_manifests([
        "headers_with_underscores_action: DROP_HEADER",
        "listener_idle_timeout_ms: 4005"
    ], [])
    _test_listener_common_http_protocol_options(
        yaml,
        expectations={
            'headers_with_underscores_action': 'DROP_HEADER',
            'idle_timeout': '4.005s'
        })
Exemple #10
0
def test_tracing_service_and_suppress_envoy_headers():
    # If we set both suppress_envoy_headers and include a TracingService,
    # we should see both suppress_envoy_headers and the default start_child_span
    # value (True).
    yaml = module_and_mapping_manifests(
        ['suppress_envoy_headers: true'],
        []) + "\n" + zipkin_tracing_service_manifest()
    _test_router(yaml,
                 expectations={
                     'start_child_span': True,
                     'suppress_envoy_headers': True
                 })
def test_both_mapping():
    # If we set both configs on the Mapping, both should show up.
    yaml = module_and_mapping_manifests(None, [
        "cluster_idle_timeout_ms: 4005",
        "cluster_max_connection_lifetime_ms: 2005"
    ])
    for v in SUPPORTED_ENVOY_VERSIONS:
        _test_common_http_protocol_options(yaml,
                                           expectations={
                                               'max_connection_duration':
                                               '2.005s',
                                               'idle_timeout': '4.005s'
                                           },
                                           envoy_version=v)
def _test_dd_entity_id(val, expected):
    # Setup by setting dd / statsd vars
    os.environ["STATSD_ENABLED"] = "true"
    os.environ["STATSD_HOST"] = "0.0.0.0"
    os.environ["DOGSTATSD"] = "true"
    if val:
        os.environ["DD_ENTITY_ID"] = val

    # Run the bootstrap test. We don't need any special yaml
    # since all of this behavior is driven by env vars.
    yaml = module_and_mapping_manifests(None, [])
    _test_bootstrap(yaml, expectations={'stats_config': expected})

    # Teardown by removing dd / statsd vars
    del os.environ["STATSD_ENABLED"]
    del os.environ["STATSD_HOST"]
    del os.environ["DOGSTATSD"]
    if val:
        del os.environ["DD_ENTITY_ID"]
Exemple #13
0
def test_headers_with_underscores_action_unset():
    yaml = module_and_mapping_manifests(None, [])
    _test_listener_common_http_protocol_options(yaml, expectations={})
def test_proper_case_true():
    yaml = module_and_mapping_manifests(["proper_case: true"], [])
    _test_listener_http_protocol_options(
        yaml, expectations={'header_key_format': {
            'proper_case_words': {}
        }})
def test_proper_case_false():
    yaml = module_and_mapping_manifests(["proper_case: false"], [])
    _test_listener_http_protocol_options(yaml, expectations={})
def test_emptiness():
    yaml = module_and_mapping_manifests([], [])
    _test_listener_http_protocol_options(yaml, expectations={})
Exemple #17
0
def test_tracing_service():
    # If we have a tracing service, we should see start_child_span
    yaml = module_and_mapping_manifests(None, []) + "\n" + zipkin_tracing_service_manifest()
    _test_router(yaml, expectations={'start_child_span': True})
Exemple #18
0
def test_preserve_external_request_id_module_false():
    # If we set the config to false, it should be false
    yaml = module_and_mapping_manifests(['preserve_external_request_id: false'], [])
    _test_hcm(yaml, expectations={'preserve_external_request_id': False})
Exemple #19
0
def test_strip_matching_host_port_module_true():
    # If we set the config to true, it should show up as true.
    yaml = module_and_mapping_manifests(['strip_matching_host_port: true'], [])
    _test_hcm(yaml, expectations={'strip_matching_host_port': True})
Exemple #20
0
def test_strip_matching_host_port_module_false():
    # If we set the config to false, it should be missing (noted in this test as None).
    yaml = module_and_mapping_manifests(['strip_matching_host_port: false'], [])
    _test_hcm(yaml, expectations={'strip_matching_host_port': None})
Exemple #21
0
def test_strip_matching_host_port_missing():
    # If we do not set the config, it should be missing (noted in this test as None).
    yaml = module_and_mapping_manifests(None, [])
    _test_hcm(yaml, expectations={'strip_matching_host_port': None})
Exemple #22
0
def test_preserve_external_request_id_module_true():
    # If we set the config to true, it should show up as true.
    yaml = module_and_mapping_manifests(['preserve_external_request_id: true'], [])
    _test_hcm(yaml, expectations={'preserve_external_request_id': True})
Exemple #23
0
def test_timeout_ms_mapping():
    # If we set a default on the Module, it should override the usual default of 3000ms.
    yaml = module_and_mapping_manifests(None, ["timeout_ms: 1234"])
    _test_route(yaml, expectations={'timeout':'1.234s'})
Exemple #24
0
def test_merge_slashes_module_true():
    # If we set the config to true, it should show up as true.
    yaml = module_and_mapping_manifests(['merge_slashes: true'], [])
    _test_hcm(yaml, expectations={'merge_slashes': True})
Exemple #25
0
def test_merge_slashes_module_false():
    # If we set the config to false, it should be missing (noted in this test as None).
    yaml = module_and_mapping_manifests(['merge_slashes: false'], [])
    _test_hcm(yaml, expectations={'merge_slashes': None})
Exemple #26
0
def test_merge_slashes_missing():
    # If we do not set the config, it should be missing (noted in this test as None).
    yaml = module_and_mapping_manifests(None, [])
    _test_hcm(yaml, expectations={'merge_slashes': None})
Exemple #27
0
def test_timeout_ms():
    # If we do not set the config, we should get the default 3000ms.
    yaml = module_and_mapping_manifests(None, [])
    _test_route(yaml, expectations={'timeout':'3.000s'})
Exemple #28
0
def test_headers_with_underscores_action_reject():
    yaml = module_and_mapping_manifests(
        ["headers_with_underscores_action: REJECT_REQUEST"], [])
    _test_listener_common_http_protocol_options(
        yaml,
        expectations={'headers_with_underscores_action': 'REJECT_REQUEST'})
Exemple #29
0
def test_timeout_ms_both():
    # If we set a default on the Module, it should override the usual default of 3000ms.
    yaml = module_and_mapping_manifests(["cluster_request_timeout_ms: 9000"], ["timeout_ms: 5001"])
    _test_route(yaml, expectations={'timeout':'5.001s'})
Exemple #30
0
def test_listener_idle_timeout_ms():
    yaml = module_and_mapping_manifests(["listener_idle_timeout_ms: 150000"],
                                        [])
    _test_listener_common_http_protocol_options(
        yaml, expectations={'idle_timeout': '150.000s'})