How to use the dockerflow.health function in dockerflow

To help you get started, we’ve selected a few dockerflow 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 mozilla-services / python-dockerflow / tests / flask / test_flask.py View on Github external
def test_db_check_sqlalchemy_error(mocker, db):
    engine_connect = mocker.patch.object(db.engine, "connect")
    engine_connect.side_effect = SQLAlchemyError
    errors = checks.check_database_connected(db)
    assert len(errors) == 1
    assert errors[0].id == health.ERROR_SQLALCHEMY_EXCEPTION
github mozilla-services / python-dockerflow / tests / django / test_django.py View on Github external
def test_check_database_connected_cannot_connect(mocker):
    ensure_connection = mocker.patch("django.db.connection.ensure_connection")
    ensure_connection.side_effect = OperationalError
    errors = checks.check_database_connected([])
    assert len(errors) == 1
    assert errors[0].id == health.ERROR_CANNOT_CONNECT_DATABASE
github mozilla-services / python-dockerflow / tests / sanic / test_sanic.py View on Github external
        ("redis", {health.ERROR_REDIS_EXCEPTION: 'Redis error: "fake"'}),
        ("malformed", {health.ERROR_REDIS_PING_FAILED: "Redis ping failed"}),
    ],
)
def test_redis_check_error(dockerflow_redis, mocker, test_client, error, messages):
    assert "check_redis_connected" in dockerflow_redis.checks
    fake_redis_error = functools.partial(fake_redis, error=error)
    mocker.patch.object(sanic_redis.core, "create_redis_pool", fake_redis_error)
    _, response = test_client.get("/__heartbeat__")
    assert response.status == 500
    assert response.json["status"] == "error"
    assert response.json["details"]["check_redis_connected"]["messages"] == messages
github mozilla-services / python-dockerflow / tests / django / test_django.py View on Github external
def test_check_database_connected_unsuable(mocker):
    mocker.patch("django.db.connection.is_usable", return_value=False)
    errors = checks.check_database_connected([])
    assert len(errors) == 1
    assert errors[0].id == health.ERROR_UNUSABLE_DATABASE