def test_health_check_works_with_resident_task():
    """Verifies that resident tasks (common for Persistent Volumes) do not fail health checks.
       Marathon bug: https://jira.mesosphere.com/browse/MARATHON-7050
    """

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

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

    deployment_wait(service_id=app_id, max_attempts=500)
    tasks = client.get_tasks(app_def["id"])
    assert len(tasks) == 1, "The number of tasks is {}, but 1 was expected".format(len(tasks))

    assert_that(lambda: client.get_app(app_def['id']), eventually(has_value('tasksHealthy', 1), max_attempts=30))
def test_healtchcheck_and_volume():
    """Launches a Docker container on Marathon."""

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

    client = marathon.create_client()
    client.add_app(app_def)
    deployment_wait(service_id=app_id)

    tasks = client.get_tasks(app_id)
    app = client.get_app(app_id)

    assert len(tasks) == 1, "The number of tasks is {} after deployment, but only 1 was expected".format(len(tasks))
    assert len(app['container']['volumes']) == 2, "The container does not have the correct amount of volumes"

    # check if app becomes healthy
    assert_that(lambda: client.get_app(app_id), eventually(has_value('tasksHealthy', 1), max_attempts=30))
def test_task_failure_recovers():
    """Tests that if a task is KILLED, another one will be launched with a different ID."""

    app_def = apps.sleep_app()
    app_def['cmd'] = 'sleep 1000'
    app_id = app_def["id"]

    client = marathon.create_client()
    client.add_app(app_def)
    deployment_wait(service_id=app_id)

    tasks = client.get_tasks(app_id)
    old_task_id = tasks[0]['id']
    host = tasks[0]['host']

    common.kill_process_on_host(host, '[s]leep 1000')

    assert_that(lambda: client.get_tasks(app_id)[0],
                eventually(has_value('id', not_(equal_to(old_task_id))), max_attempts=30))
Exemple #4
0
def test_health_check_works_with_resident_task():
    """Verifies that resident tasks (common for Persistent Volumes) do not fail health checks.
       Marathon bug: https://jira.mesosphere.com/browse/MARATHON-7050
    """

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

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

    deployment_wait(service_id=app_id, max_attempts=500)
    tasks = client.get_tasks(app_def["id"])
    assert len(
        tasks) == 1, "The number of tasks is {}, but 1 was expected".format(
            len(tasks))

    assert_that(lambda: client.get_app(app_def['id']),
                eventually(has_value('tasksHealthy', 1), max_attempts=30))
Exemple #5
0
def test_task_failure_recovers():
    """Tests that if a task is KILLED, another one will be launched with a different ID."""

    app_def = apps.sleep_app()
    app_def['cmd'] = 'sleep 1000'
    app_id = app_def["id"]

    client = marathon.create_client()
    client.add_app(app_def)
    deployment_wait(service_id=app_id)

    tasks = client.get_tasks(app_id)
    old_task_id = tasks[0]['id']
    host = tasks[0]['host']

    common.kill_process_on_host(host, '[s]leep 1000')

    assert_that(
        lambda: client.get_tasks(app_id)[0],
        eventually(has_value('id', not_(equal_to(old_task_id))),
                   max_attempts=30))
Exemple #6
0
def test_healtchcheck_and_volume():
    """Launches a Docker container on Marathon."""

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

    client = marathon.create_client()
    client.add_app(app_def)
    deployment_wait(service_id=app_id)

    tasks = client.get_tasks(app_id)
    app = client.get_app(app_id)

    assert len(
        tasks
    ) == 1, "The number of tasks is {} after deployment, but only 1 was expected".format(
        len(tasks))
    assert len(
        app['container']['volumes']
    ) == 2, "The container does not have the correct amount of volumes"

    # check if app becomes healthy
    assert_that(lambda: client.get_app(app_id),
                eventually(has_value('tasksHealthy', 1), max_attempts=30))