Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# -*- 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():
# -*- 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(
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