How to use the chaostoolkit.errors.UnknownProbe function in chaostoolkit

To help you get started, we’ve selected a few chaostoolkit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github chaostoolkit / chaostoolkit / tests / test_plan.py View on Github external
def test_close_probe_must_be_implemented():
    step = {
        "probes": {
            "close": {
                "layer": "noop",
                "name": "microservice-should-be-happy"
            }
        }
    }

    with pytest.raises(UnknownProbe) as excinfo:
        apply_close_probe(step, layers)

    assert "probe 'microservice_should_be_happy' is not implemented" in\
        str(excinfo)
github chaostoolkit / chaostoolkit / tests / test_plan.py View on Github external
def test_steady_probe_must_be_implemented():
    step = {
        "probes": {
            "steady": {
                "layer": "noop",
                "name": "microservice-should-be-happy"
            }
        }
    }

    with pytest.raises(UnknownProbe) as excinfo:
        apply_steady_probe(step, layers)

    assert "probe 'microservice_should_be_happy' is not implemented" in\
        str(excinfo)
github chaostoolkit / chaostoolkit / chaostoolkit / probes.py View on Github external
def apply_probe(name: str, probe: Probe, layer: Layer) -> Any:
    """
    Apply the given probe and return its result. The name of the probe
    matches a function in this module by replacing dashes with underscores.

    If no function matches, raises :exc:`UnknownProbe`.
    """
    if not name:
        raise ValueError("missing probe name")

    name = name.replace('-', '_')
    probe_func = get_probe_function(name)
    if not probe_func:
        raise UnknownProbe(name)

    return probe_func(probe, layer)