コード例 #1
0
def ignore_launch_mesos_mom_default_graceperiod():
    """ Test the 'taskKillGracePeriodSeconds' in a MoM environment.  Read more details
        on this test in `test_root_marathon.py::test_launch_mesos_root_marathon_default_graceperiod`
    """

    app_id = uuid.uuid4().hex
    app_def = app_mesos(app_id)

    fetch = [{
            "uri": "https://downloads.mesosphere.com/testing/test.py"
    }]
    app_def['fetch'] = fetch
    app_def['cmd'] = '/opt/mesosphere/bin/python test.py'

    with marathon_on_marathon():
        client = marathon.create_client()
        client.add_app(app_def)
        shakedown.deployment_wait()

        task = shakedown.get_service_task('marathon-user', app_id)
        assert task is not None
        task_id = task.get('id')
        client.scale_app(app_id, 0)
        task = shakedown.get_service_task('marathon-user', app_id)
        assert task is not None

        # 3 sec is the default
        # task should be gone after 3 secs
        default_graceperiod = 3
        time.sleep(default_graceperiod + 1)
        task = shakedown.get_service_task('marathon-user', app_id)
        assert task is None
コード例 #2
0
def test_launch_mesos_graceperiod(marathon_service_name):
    """ Test the 'taskKillGracePeriodSeconds' in a Marathon environment.  Read more details
        on this test in `test_root_marathon.py::test_launch_mesos_root_marathon_graceperiod`
    """

    app_id = uuid.uuid4().hex
    app_def = app_mesos(app_id)
    default_graceperiod = 3
    graceperiod = 20

    app_def['taskKillGracePeriodSeconds'] = graceperiod
    fetch = [{"uri": "https://downloads.mesosphere.com/testing/test.py"}]
    app_def['fetch'] = fetch
    app_def['cmd'] = '/opt/mesosphere/bin/python test.py'

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

    tasks = shakedown.get_service_task(marathon_service_name, app_id)
    assert tasks is not None

    client.scale_app(app_id, 0)
    tasks = shakedown.get_service_task(marathon_service_name, app_id)
    assert tasks is not None

    # task should still be here after the default_graceperiod
    time.sleep(default_graceperiod + 1)
    tasks = shakedown.get_service_task(marathon_service_name, app_id)
    assert tasks is not None

    # but not after the set graceperiod
    time.sleep(graceperiod)
    tasks = shakedown.get_service_task(marathon_service_name, app_id)
    assert tasks is None
コード例 #3
0
def test_event_channel():
    """ Tests the event channel.  The way events are verified is by streaming the events
        to a test.txt file.   The fixture ensures the file is removed before and after the test.
        events checked are connecting, deploying a good task and killing a task.
    """
    app_def = common.app_mesos()
    app_id = app_def['id']

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

    @retrying.retry(wait_fixed=1000, stop_max_delay=10000)
    def check_deployment_message():
        status, stdout = shakedown.run_command_on_master('cat test.txt')
        assert 'event_stream_attached' in stdout
        assert 'deployment_info' in stdout
        assert 'deployment_step_success' in stdout

    check_deployment_message()
    client.remove_app(app_id, True)
    shakedown.deployment_wait()

    @retrying.retry(wait_fixed=1000, stop_max_delay=10000)
    def check_kill_message():
        status, stdout = shakedown.run_command_on_master('cat test.txt')
        assert 'KILLED' in stdout

    check_kill_message()
コード例 #4
0
def test_launch_mesos_root_marathon_graceperiod():
    delete_all_apps_wait()
    app_def = app_mesos()
    app_def['id'] = 'grace'
    app_def['taskKillGracePeriodSeconds'] = 20
    fetch = [{"uri": "https://downloads.mesosphere.com/testing/test.py"}]
    app_def['fetch'] = fetch
    app_def['cmd'] = '/opt/mesosphere/bin/python test.py'

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

    tasks = get_service_task('marathon', 'grace')
    assert tasks is not None

    client.scale_app('/grace', 0)
    tasks = get_service_task('marathon', 'grace')
    assert tasks is not None

    # 3 sec is the default
    # should have task still
    time.sleep(5)
    tasks = get_service_task('marathon', 'grace')
    assert tasks is not None
    time.sleep(20)
    tasks = get_service_task('marathon', 'grace')
    assert tasks is None
コード例 #5
0
def test_event_channel():
    """ Tests the event channel.  The way events are verified is by streaming the events
        to a test.txt file.   The fixture ensures the file is removed before and after the test.
        events checked are connecting, deploying a good task and killing a task.
    """
    app_def = common.app_mesos()
    app_id = app_def['id']

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

    @retrying.retry(wait_fixed=1000, stop_max_delay=10000)
    def check_deployment_message():
        status, stdout = shakedown.run_command_on_master('cat test.txt')
        assert 'event_stream_attached' in stdout
        assert 'deployment_info' in stdout
        assert 'deployment_step_success' in stdout

    client.remove_app(app_id, True)
    shakedown.deployment_wait()

    @retrying.retry(wait_fixed=1000, stop_max_delay=10000)
    def check_kill_message():
        status, stdout = shakedown.run_command_on_master('cat test.txt')
        assert 'Killed' in stdout
コード例 #6
0
def test_launch_mesos_root_marathon_graceperiod():
    """  Test the 'taskKillGracePeriodSeconds' of a launched task from the root marathon.
         The default is 3 seconds.  This tests setting that period to other than the default value.
    """
    app_def = common.app_mesos()
    app_def['id'] = 'grace'
    default_graceperiod = 3
    graceperiod = 20
    app_def['taskKillGracePeriodSeconds'] = graceperiod
    fetch = [{"uri": "https://downloads.mesosphere.com/testing/test.py"}]
    app_def['fetch'] = fetch
    app_def['cmd'] = '/opt/mesosphere/bin/python test.py'

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

    tasks = shakedown.get_service_task('marathon', 'grace')
    assert tasks is not None

    client.scale_app('/grace', 0)
    tasks = shakedown.get_service_task('marathon', 'grace')
    assert tasks is not None

    # task should still be here after the default_graceperiod
    time.sleep(default_graceperiod + 1)
    tasks = shakedown.get_service_task('marathon', 'grace')
    assert tasks is not None

    # but not after the set graceperiod
    time.sleep(graceperiod)
    tasks = shakedown.get_service_task('marathon', 'grace')
    assert tasks is None
コード例 #7
0
def test_launch_mesos_root_marathon_default_graceperiod():
    """  Test the 'taskKillGracePeriodSeconds' of a launched task from the root marathon.
         The graceperiod is the time after a kill sig to allow for a graceful shutdown.
         The default is 3 seconds.  The fetched test.py contains `signal.signal(signal.SIGTERM, signal.SIG_IGN)`.
    """
    app_def = common.app_mesos()
    app_def['id'] = 'grace'
    fetch = [{"uri": "https://downloads.mesosphere.com/testing/test.py"}]
    app_def['fetch'] = fetch
    app_def['cmd'] = '/opt/mesosphere/bin/python test.py'

    # with marathon_on_marathon():
    client = marathon.create_client()
    client.add_app(app_def)
    shakedown.deployment_wait()

    # after waiting for deployment it exists
    tasks = shakedown.get_service_task('marathon', 'grace')
    assert tasks is not None

    # still present after a scale down.
    client.scale_app('/grace', 0)
    tasks = shakedown.get_service_task('marathon', 'grace')
    assert tasks is not None

    # 3 sec is the default
    # task should be gone after 3 secs
    default_graceperiod = 3
    time.sleep(default_graceperiod + 1)
    tasks = shakedown.get_service_task('marathon', 'grace')
    assert tasks is None
コード例 #8
0
def test_launch_app_timed():
    """ Most tests wait until a task is launched with no reference to time.
    This simple test verifies that if a app is launched on marathon that within 3 secs
    it will be a task.
    """
    app_id = uuid.uuid4().hex
    client = marathon.create_client()
    client.add_app(app_mesos(app_id))
    # if not launched in 3 sec fail
    time.sleep(3)
    tasks = client.get_tasks(app_id)
    assert len(tasks) == 1
コード例 #9
0
def test_launch_mesos_container():
    """ Test the successful launch of a mesos container on Marathon.
    """
    client = marathon.create_client()
    app_id = uuid.uuid4().hex
    client.add_app(app_mesos(app_id))
    shakedown.deployment_wait()

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

    assert len(tasks) == 1
    assert app['container']['type'] == 'MESOS'
コード例 #10
0
def test_launch_mesos_container():
    """ Test the successful launch of a mesos container on Marathon.
        This is a UCR test with a standard command.
    """
    client = marathon.create_client()
    app_id = uuid.uuid4().hex
    client.add_app(app_mesos(app_id))
    shakedown.deployment_wait()

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

    assert len(tasks) == 1, "Num of tasks: {} is not 1 after deployment".format(len(tasks))
    assert app['container']['type'] == 'MESOS', "Container type is NOT MESOS"
コード例 #11
0
def test_update_app():
    """ Tests update an app.
    """
    app_id = uuid.uuid4().hex
    app_def = app_mesos(app_id)
    client = marathon.create_client()
    client.add_app(app_def)
    shakedown.deployment_wait()

    tasks = client.get_tasks(app_id)
    assert len(tasks) == 1

    app_def['cpus'] = 1
    app_def['instances'] = 2
    client.update_app(app_id, app_def)
    shakedown.deployment_wait()

    tasks = client.get_tasks(app_id)
    assert len(tasks) == 2
コード例 #12
0
def test_launch_mesos_graceperiod(marathon_service_name):
    """ Test the 'taskKillGracePeriodSeconds' in a Marathon environment.  Read more details
        on this test in `test_root_marathon.py::test_launch_mesos_root_marathon_graceperiod`
    """

    app_id = uuid.uuid4().hex
    app_def = app_mesos(app_id)
    default_graceperiod = 3
    graceperiod = 20

    app_def['taskKillGracePeriodSeconds'] = graceperiod
    fetch = [{
            "uri": "https://downloads.mesosphere.com/testing/test.py"
    }]
    app_def['fetch'] = fetch
    app_def['cmd'] = '/opt/mesosphere/bin/python test.py'

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

    tasks = shakedown.get_service_task(marathon_service_name, app_id)
    assert tasks is not None

    client.scale_app(app_id, 0)
    tasks = shakedown.get_service_task(marathon_service_name, app_id)
    assert tasks is not None

    # task should still be here after the default_graceperiod
    time.sleep(default_graceperiod + 1)
    tasks = shakedown.get_service_task(marathon_service_name, app_id)
    assert tasks is not None

    # but not after the set graceperiod
    time.sleep(graceperiod)
    tasks = shakedown.get_service_task(marathon_service_name, app_id)
    assert tasks is None