How to use chaostoolkit - 10 common examples

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_action_needs_a_name():
    step = {
        "action": {
            "parameters": {
                "name": "cherrypy-webapp"
            }
        }
    }

    with pytest.raises(InvalidPlan) as excinfo:
        apply_action(step, layers)

    assert "action requires a name" in str(excinfo)
github chaostoolkit / chaostoolkit / tests / test_cli.py View on Github external
def test_json_encoder_failure():
    class Dummy:
        pass

    with pytest.raises(TypeError) as x:
        encoder(Dummy())
github chaostoolkit / chaostoolkit / tests / test_encoder.py View on Github external
def test_encode_decimal():
    d = decimal.Decimal("6.7")

    doc = json.dumps({"d": d}, default=encoder)
    assert str(d) in doc
github chaostoolkit / chaostoolkit / tests / test_cli.py View on Github external
def test_json_encoder_decimal():
    d = Decimal('1.38')
    assert encoder(d) == '1.38'
github chaostoolkit / chaostoolkit / tests / test_cli.py View on Github external
def test_json_encoder_datetime():
    now = datetime.utcnow()
    assert encoder(now) == now.isoformat()
github chaostoolkit / chaostoolkit / tests / test_cli.py View on Github external
def test_json_encoder_uuid():
    u = uuid.uuid4()
    assert encoder(u) == str(u)
github chaostoolkit / chaostoolkit / tests / test_encoder.py View on Github external
def test_encode_date_and_datetime():
    now = datetime.now()
    utcnow = datetime.utcnow()
    today = datetime.today()

    d = {"now": now, "utcnow": utcnow, "today": today}
    
    doc = json.dumps(d, default=encoder)

    assert now.isoformat() in doc
    assert utcnow.isoformat() in doc
    assert today.isoformat() in doc
github chaostoolkit / chaostoolkit / tests / test_probes.py View on Github external
def test_unhealthy_system_should_be_reported():
    step = {
        "layer": "fixtures.failing_probe_backend",
        "name": "all-microservices-healthy"
    }

    with pytest.raises(FailedProbe) as excinfo:
        microservices_all_healthy(step, layers[step["layer"]])
github chaostoolkit / chaostoolkit / tests / test_probes.py View on Github external
"layer": "fixtures.failing_probe_backend",
        "name": "microservice-available-and-healthy"
    }

    with pytest.raises(InvalidProbe) as excinfo:
        microservice_available_and_healthy(step, layers[step["layer"]])

    step = {
        "layer": "fixtures.failing_probe_backend",
        "name": "microservice-available-and-healthy",
        "parameters": {
            "name": "cherrypy-webapp"
        }
    }

    with pytest.raises(FailedProbe) as excinfo:
        microservice_available_and_healthy(step, layers[step["layer"]])

    assert "microservice 'cherrypy-webapp' is not healthy" in str(excinfo)
github chaostoolkit / chaostoolkit / tests / test_check.py View on Github external
def test_version_is_not_newer(requests):
    requests.get.return_value = FakeResponse(
        200,
        "https://releases.chaostoolkit.org/latest",
        {"version": __version__, "up_to_date": True}
    )

    latest_version = check_newer_version(command="init")
    assert latest_version is None