How to use the chaostoolkit.layers.load_layers 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_probes.py View on Github external
# -*- coding: utf-8 -*-
import pytest

from chaostoolkit.layers import load_layers
from chaostoolkit.probes import apply_probe, microservices_all_healthy, \
    microservice_available_and_healthy, microservice_is_not_available
from chaostoolkit.errors import FailedProbe, InvalidProbe

layers = load_layers({
    "platforms": [{
        "key": "fixtures.failing_probe_backend"
    }]
})


def test_cannot_apply_an_unamed_probe():
    step = {}

    with pytest.raises(ValueError) as excinfo:
        apply_probe(step.get("name"), step, None)

    assert "missing probe name" in str(excinfo)


def test_unhealthy_system_should_be_reported():
github chaostoolkit / chaostoolkit / tests / test_plan.py View on Github external
# -*- coding: utf-8 -*-
import os.path

from jsonschema import ValidationError
import pytest

from chaostoolkit.layers import load_layers
from chaostoolkit.plan import apply_action, apply_steady_probe, \
    apply_close_probe, execute_plan, load_plan
from chaostoolkit.errors import FailedProbe, InvalidPlan, UnknownAction,\
    UnknownProbe

layers = load_layers({"platforms": [{"key": "noop"}]})


def test_plan_that_do_not_exist_cannot_be_loaded():
    with pytest.raises(IOError) as excinfo:
        load_plan("wherever.json")


#def test_invalid_plan_should_be_reported():
#    with pytest.raises(ValidationError) as excinfo:
#        load_plan(
#            os.path.join(os.path.dirname(__file__), "fixtures",
#                         "invalid-plan.json"))


def test_valid_plan_should_be_loaded():
    plan = load_plan(
github chaostoolkit / chaostoolkit / chaostoolkit / plan.py View on Github external
def run_plan(plan_path: str, dry_run: bool = False) -> Report:
    """
    Execute the given plan and return a report once done.
    """
    with Report() as report:
        logger.info("Executing plan '{path}'".format(path=plan_path))
        plan = load_plan(plan_path)
        if dry_run:
            switch_to_dry_run(plan)

        report.with_plan(plan)

        layers = load_layers(plan.get("target-layers"))

        execute_plan(plan, layers)
        return report