Exemplo n.º 1
0
def test_unhealthy_app_can_be_rolled_back():
    """Verifies that an updated app gets rolled back due to being unhealthy."""

    app_def = apps.readiness_and_health_app()
    app_id = app_def["id"]

    @retrying.retry(
        wait_fixed=1000,
        stop_max_attempt_number=30,
        retry_on_exception=common.ignore_provided_exception(DCOSException)
    )
    def wait_for_deployment():
        deployment_wait(service_id=app_id)

    client = marathon.create_client()
    client.add_app(app_def)
    wait_for_deployment()

    tasks = client.get_tasks(app_id)
    assert len(tasks) == 1, "The number of tasks is {} after deployment, but 1 was expected".format(len(tasks))

    app_def['healthChecks'][0]['path'] = '/non-existent'
    app_def['instances'] = 2
    deployment_id = client.update_app(app_id, app_def)

    try:
        wait_for_deployment()
    except Exception:
        client.rollback_deployment(deployment_id)
        wait_for_deployment()

    tasks = client.get_tasks(app_id)
    assert len(tasks) == 1, "The number of tasks is {} after rollback, but 1 was expected".format(len(tasks))
Exemplo n.º 2
0
def test_unhealthy_app_can_be_rolled_back():
    """Verifies that an updated app gets rolled back due to being unhealthy."""

    app_def = apps.readiness_and_health_app()
    app_id = app_def["id"]

    @retrying.retry(
        wait_fixed=1000,
        stop_max_attempt_number=30,
        retry_on_exception=common.ignore_provided_exception(DCOSException)
    )
    def wait_for_deployment():
        shakedown.deployment_wait()

    client = marathon.create_client()
    client.add_app(app_def)
    wait_for_deployment()

    tasks = client.get_tasks(app_id)
    assert len(tasks) == 1, "The number of tasks is {} after deployment, but 1 was expected".format(len(tasks))

    app_def['healthChecks'][0]['path'] = '/non-existent'
    app_def['instances'] = 2
    deployment_id = client.update_app(app_id, app_def)

    try:
        wait_for_deployment()
    except Exception:
        client.rollback_deployment(deployment_id)
        wait_for_deployment()

    tasks = client.get_tasks(app_id)
    assert len(tasks) == 1, "The number of tasks is {} after rollback, but 1 was expected".format(len(tasks))