def test_once_task_does_not_restart_on_config_update():
    foldered_name = sdk_utils.get_foldered_name(config.SERVICE_NAME)
    config.check_running(foldered_name)

    sdk_plan.wait_for_completed_deployment(foldered_name)
    task_name = "hello-0-once"
    hello_once_id = get_completed_task_id(task_name)
    assert hello_once_id is not None
    log.info("%s ID: %s", task_name, hello_once_id)
    config.bump_hello_cpus(foldered_name)

    sdk_tasks.check_task_not_relaunched(
        foldered_name, task_name, hello_once_id, with_completed=True
    )
    config.check_running(foldered_name)
def test_once_task_does_not_restart_on_config_update():
    foldered_name = sdk_utils.get_foldered_name(config.SERVICE_NAME)
    config.check_running(foldered_name)

    sdk_plan.wait_for_completed_deployment(foldered_name)
    task_name = "hello-0-once"
    hello_once_id = get_completed_task_id(task_name)
    assert hello_once_id is not None
    log.info("%s ID: %s", task_name, hello_once_id)
    config.bump_hello_cpus(foldered_name)

    sdk_tasks.check_task_not_relaunched(foldered_name,
                                        task_name,
                                        hello_once_id,
                                        with_completed=True)
    config.check_running(foldered_name)
def test_bump_hello_cpus():
    hello_ids = sdk_tasks.get_task_ids(foldered_name, "hello")
    log.info("hello ids: " + str(hello_ids))

    updated_cpus = config.bump_hello_cpus(foldered_name)

    sdk_tasks.check_tasks_updated(foldered_name, "hello", hello_ids)
    sdk_plan.wait_for_completed_deployment(foldered_name)

    all_tasks = sdk_tasks.get_service_tasks(foldered_name, task_prefix="hello")
    running_tasks = [t for t in all_tasks if t.state == "TASK_RUNNING"]
    assert len(running_tasks) == config.hello_task_count(foldered_name)
    for t in running_tasks:
        assert config.close_enough(t.resources["cpus"], updated_cpus)
Exemple #4
0
def test_bump_hello_cpus():
    hello_ids = sdk_tasks.get_task_ids(foldered_name, "hello")
    log.info("hello ids: " + str(hello_ids))

    updated_cpus = config.bump_hello_cpus(foldered_name)

    sdk_tasks.check_tasks_updated(foldered_name, "hello", hello_ids)
    sdk_plan.wait_for_completed_deployment(foldered_name)

    all_tasks = sdk_tasks.get_service_tasks(foldered_name, task_prefix="hello")
    running_tasks = [t for t in all_tasks if t.state == "TASK_RUNNING"]
    assert len(running_tasks) == config.hello_task_count(foldered_name)
    for t in running_tasks:
        assert config.close_enough(t.resources["cpus"], updated_cpus)
Exemple #5
0
def test_bump_hello_cpus():
    check_running()
    hello_ids = tasks.get_task_ids(PACKAGE_NAME, 'hello')
    sdk_utils.out('hello ids: ' + str(hello_ids))

    updated_cpus = bump_hello_cpus()

    tasks.check_tasks_updated(PACKAGE_NAME, 'hello', hello_ids)
    check_running()

    all_tasks = shakedown.get_service_tasks(PACKAGE_NAME)
    running_tasks = [t for t in all_tasks if t['name'].startswith('hello') and t['state'] == "TASK_RUNNING"]
    assert len(running_tasks) == hello_task_count()
    for t in running_tasks:
        assert close_enough(t['resources']['cpus'], updated_cpus)
Exemple #6
0
def test_bump_hello_cpus():
    config.check_running(FOLDERED_SERVICE_NAME)
    hello_ids = sdk_tasks.get_task_ids(FOLDERED_SERVICE_NAME, 'hello')
    log.info('hello ids: ' + str(hello_ids))

    updated_cpus = config.bump_hello_cpus(FOLDERED_SERVICE_NAME)

    sdk_tasks.check_tasks_updated(FOLDERED_SERVICE_NAME, 'hello', hello_ids)
    config.check_running(FOLDERED_SERVICE_NAME)

    all_tasks = shakedown.get_service_tasks(FOLDERED_SERVICE_NAME)
    running_tasks = [t for t in all_tasks if t['name'].startswith('hello') and t['state'] == "TASK_RUNNING"]
    assert len(running_tasks) == config.hello_task_count(FOLDERED_SERVICE_NAME)
    for t in running_tasks:
        assert close_enough(t['resources']['cpus'], updated_cpus)
def test_bump_hello_cpus():
    config.check_running(FOLDERED_SERVICE_NAME)
    hello_ids = sdk_tasks.get_task_ids(FOLDERED_SERVICE_NAME, 'hello')
    log.info('hello ids: ' + str(hello_ids))

    updated_cpus = config.bump_hello_cpus(FOLDERED_SERVICE_NAME)

    sdk_tasks.check_tasks_updated(FOLDERED_SERVICE_NAME, 'hello', hello_ids)
    config.check_running(FOLDERED_SERVICE_NAME)

    all_tasks = shakedown.get_service_tasks(FOLDERED_SERVICE_NAME)
    running_tasks = [t for t in all_tasks if t['name'].startswith('hello') and t['state'] == "TASK_RUNNING"]
    assert len(running_tasks) == config.hello_task_count(FOLDERED_SERVICE_NAME)
    for t in running_tasks:
        assert close_enough(t['resources']['cpus'], updated_cpus)
def test_bump_hello_cpus():
    def close_enough(val0, val1):
        epsilon = 0.00001
        diff = abs(val0 - val1)
        return diff < epsilon

    config.check_running(config.SERVICE_NAME)
    hello_ids = sdk_tasks.get_task_ids(config.SERVICE_NAME, 'hello')
    log.info('hello ids: ' + str(hello_ids))

    updated_cpus = config.bump_hello_cpus(config.SERVICE_NAME)

    sdk_tasks.check_tasks_updated(config.SERVICE_NAME, 'hello', hello_ids)
    config.check_running(config.SERVICE_NAME)

    all_tasks = shakedown.get_service_tasks(config.SERVICE_NAME)
    running_tasks = [t for t in all_tasks if t['name'].startswith('hello') and t['state'] == "TASK_RUNNING"]
    for t in running_tasks:
        assert close_enough(t['resources']['cpus'], updated_cpus)
def test_bump_hello_cpus():
    def close_enough(val0, val1):
        epsilon = 0.00001
        diff = abs(val0 - val1)
        return diff < epsilon

    config.check_running(config.SERVICE_NAME)
    hello_ids = sdk_tasks.get_task_ids(config.SERVICE_NAME, "hello")
    log.info("hello ids: " + str(hello_ids))

    updated_cpus = config.bump_hello_cpus(config.SERVICE_NAME)

    sdk_tasks.check_tasks_updated(config.SERVICE_NAME, "hello", hello_ids)
    config.check_running(config.SERVICE_NAME)

    all_tasks = sdk_tasks.get_service_tasks(config.SERVICE_NAME, task_prefix="hello")
    running_tasks = [t for t in all_tasks if t.state == "TASK_RUNNING"]
    for t in running_tasks:
        assert close_enough(t.resources["cpus"], updated_cpus)
def test_bump_hello_cpus():
    def close_enough(val0, val1):
        epsilon = 0.00001
        diff = abs(val0 - val1)
        return diff < epsilon

    check_running(PACKAGE_NAME)
    hello_ids = sdk_tasks.get_task_ids(PACKAGE_NAME, 'hello')
    log.info('hello ids: ' + str(hello_ids))

    updated_cpus = bump_hello_cpus(PACKAGE_NAME)

    sdk_tasks.check_tasks_updated(PACKAGE_NAME, 'hello', hello_ids)
    check_running(PACKAGE_NAME)

    all_tasks = shakedown.get_service_tasks(PACKAGE_NAME)
    running_tasks = [t for t in all_tasks if t['name'].startswith('hello') and t['state'] == "TASK_RUNNING"]
    for t in running_tasks:
        assert close_enough(t['resources']['cpus'], updated_cpus)
Exemple #11
0
def test_bump_hello_cpus():
    def close_enough(val0, val1):
        epsilon = 0.00001
        diff = abs(val0 - val1)
        return diff < epsilon

    config.check_running(config.SERVICE_NAME)
    hello_ids = sdk_tasks.get_task_ids(config.SERVICE_NAME, "hello")
    log.info("hello ids: " + str(hello_ids))

    updated_cpus = config.bump_hello_cpus(config.SERVICE_NAME)

    sdk_tasks.check_tasks_updated(config.SERVICE_NAME, "hello", hello_ids)
    config.check_running(config.SERVICE_NAME)

    all_tasks = sdk_tasks.get_service_tasks(config.SERVICE_NAME,
                                            task_prefix="hello")
    running_tasks = [t for t in all_tasks if t.state == "TASK_RUNNING"]
    for t in running_tasks:
        assert close_enough(t.resources["cpus"], updated_cpus)
def test_increase_cpu():
    hello_0_ids = sdk_tasks.get_task_ids(config.SERVICE_NAME, "hello-0-server")
    config.bump_hello_cpus()

    pl = sdk_plan.wait_for_plan_status(config.SERVICE_NAME, "deploy",
                                       "WAITING")
    log.info(pl)

    assert pl["status"] == "WAITING"

    assert len(pl["phases"]) == 2

    phase = pl["phases"][0]
    assert phase["status"] == "WAITING"
    steps = phase["steps"]
    assert len(steps) == 5
    assert steps[0]["status"] == "WAITING"
    assert steps[1]["status"] == "WAITING"
    assert steps[2]["status"] == "PENDING"
    assert steps[3]["status"] == "PENDING"
    assert steps[4]["status"] == "PENDING"

    phase = pl["phases"][1]
    assert phase["status"] == "COMPLETE"
    steps = phase["steps"]
    assert len(steps) == 4
    assert steps[0]["status"] == "COMPLETE"
    assert steps[1]["status"] == "COMPLETE"
    assert steps[2]["status"] == "COMPLETE"
    assert steps[3]["status"] == "COMPLETE"

    # check that all prior tasks are still running, no changes yet
    expected_tasks = [
        "hello-0",
        "hello-1",
        "hello-2",
        "hello-3",
        "hello-4",
        "world-0",
        "world-1",
        "world-2",
        "world-3",
    ]
    sdk_tasks.check_running(config.SERVICE_NAME, len(expected_tasks))
    rc, stdout, _ = sdk_cmd.svc_cli(config.PACKAGE_NAME, config.SERVICE_NAME,
                                    "pod list")
    assert rc == 0, "Pod list failed"
    assert json.loads(stdout) == expected_tasks

    assert hello_0_ids == sdk_tasks.get_task_ids(config.SERVICE_NAME,
                                                 "hello-0-server")

    sdk_cmd.svc_cli(config.PACKAGE_NAME, config.SERVICE_NAME,
                    "plan continue deploy hello-deploy")

    sdk_tasks.check_tasks_updated(config.SERVICE_NAME, "hello-0-server",
                                  hello_0_ids)
    sdk_tasks.check_running(config.SERVICE_NAME, len(expected_tasks))

    pl = sdk_plan.wait_for_step_status(config.SERVICE_NAME, "deploy",
                                       "hello-deploy", "hello-0:[server]",
                                       "COMPLETE")
    log.info(pl)

    assert pl["status"] == "WAITING"

    assert len(pl["phases"]) == 2

    phase = pl["phases"][0]
    assert phase["status"] == "WAITING"
    steps = phase["steps"]
    assert len(steps) == 5
    assert steps[0]["status"] == "COMPLETE"
    assert steps[1]["status"] == "WAITING"
    assert steps[2]["status"] == "PENDING"
    assert steps[3]["status"] == "PENDING"
    assert steps[4]["status"] == "PENDING"

    phase = pl["phases"][1]
    assert phase["status"] == "COMPLETE"
    steps = phase["steps"]
    assert len(steps) == 4
    assert steps[0]["status"] == "COMPLETE"
    assert steps[1]["status"] == "COMPLETE"
    assert steps[2]["status"] == "COMPLETE"
    assert steps[3]["status"] == "COMPLETE"

    hello_1_ids = sdk_tasks.get_task_ids(config.SERVICE_NAME, "hello-1-server")
    sdk_cmd.svc_cli(config.PACKAGE_NAME, config.SERVICE_NAME,
                    "plan continue deploy hello-deploy")
    sdk_tasks.check_tasks_updated(config.SERVICE_NAME, "hello-1-server",
                                  hello_1_ids)

    pl = sdk_plan.wait_for_completed_deployment(config.SERVICE_NAME)
    log.info(pl)

    assert pl["status"] == "COMPLETE"

    assert len(pl["phases"]) == 2

    phase = pl["phases"][0]
    assert phase["status"] == "COMPLETE"
    steps = phase["steps"]
    assert len(steps) == 5
    assert steps[0]["status"] == "COMPLETE"
    assert steps[1]["status"] == "COMPLETE"
    assert steps[2]["status"] == "COMPLETE"
    assert steps[3]["status"] == "COMPLETE"
    assert steps[4]["status"] == "COMPLETE"

    phase = pl["phases"][1]
    assert phase["status"] == "COMPLETE"
    steps = phase["steps"]
    assert len(steps) == 4
    assert steps[0]["status"] == "COMPLETE"
    assert steps[1]["status"] == "COMPLETE"
    assert steps[2]["status"] == "COMPLETE"
    assert steps[3]["status"] == "COMPLETE"
Exemple #13
0
def test_config_update_then_zk_killed():
    hello_ids = sdk_tasks.get_task_ids(config.SERVICE_NAME, 'hello')
    config.bump_hello_cpus()
    sdk_cmd.kill_task_with_pattern('zookeeper')
    sdk_tasks.check_tasks_updated(config.SERVICE_NAME, 'hello', hello_ids)
    config.check_running()
Exemple #14
0
def test_increase_cpu():
    hello_0_ids = sdk_tasks.get_task_ids(config.SERVICE_NAME, 'hello-0-server')
    config.bump_hello_cpus()

    pl = sdk_plan.wait_for_plan_status(config.SERVICE_NAME, 'deploy',
                                       'WAITING')
    log.info(pl)

    assert pl['status'] == 'WAITING'

    assert len(pl['phases']) == 2

    phase = pl['phases'][0]
    assert phase['status'] == 'WAITING'
    steps = phase['steps']
    assert len(steps) == 5
    assert steps[0]['status'] == 'WAITING'
    assert steps[1]['status'] == 'WAITING'
    assert steps[2]['status'] == 'PENDING'
    assert steps[3]['status'] == 'PENDING'
    assert steps[4]['status'] == 'PENDING'

    phase = pl['phases'][1]
    assert phase['status'] == 'COMPLETE'
    steps = phase['steps']
    assert len(steps) == 4
    assert steps[0]['status'] == 'COMPLETE'
    assert steps[1]['status'] == 'COMPLETE'
    assert steps[2]['status'] == 'COMPLETE'
    assert steps[3]['status'] == 'COMPLETE'

    # check that all prior tasks are still running, no changes yet
    expected_tasks = [
        'hello-0', 'hello-1', 'hello-2', 'hello-3', 'hello-4', 'world-0',
        'world-1', 'world-2', 'world-3'
    ]
    sdk_tasks.check_running(config.SERVICE_NAME, len(expected_tasks))
    assert sdk_cmd.svc_cli(config.PACKAGE_NAME,
                           config.SERVICE_NAME,
                           'pod list',
                           json=True) == expected_tasks
    assert hello_0_ids == sdk_tasks.get_task_ids(config.SERVICE_NAME,
                                                 'hello-0-server')

    sdk_cmd.svc_cli(config.PACKAGE_NAME, config.SERVICE_NAME,
                    'plan continue deploy hello-deploy')

    sdk_tasks.check_tasks_updated(config.SERVICE_NAME, 'hello-0-server',
                                  hello_0_ids)
    sdk_tasks.check_running(config.SERVICE_NAME, len(expected_tasks))

    pl = sdk_plan.wait_for_step_status(config.SERVICE_NAME, 'deploy',
                                       'hello-deploy', 'hello-0:[server]',
                                       'COMPLETE')
    log.info(pl)

    assert pl['status'] == 'WAITING'

    assert len(pl['phases']) == 2

    phase = pl['phases'][0]
    assert phase['status'] == 'WAITING'
    steps = phase['steps']
    assert len(steps) == 5
    assert steps[0]['status'] == 'COMPLETE'
    assert steps[1]['status'] == 'WAITING'
    assert steps[2]['status'] == 'PENDING'
    assert steps[3]['status'] == 'PENDING'
    assert steps[4]['status'] == 'PENDING'

    phase = pl['phases'][1]
    assert phase['status'] == 'COMPLETE'
    steps = phase['steps']
    assert len(steps) == 4
    assert steps[0]['status'] == 'COMPLETE'
    assert steps[1]['status'] == 'COMPLETE'
    assert steps[2]['status'] == 'COMPLETE'
    assert steps[3]['status'] == 'COMPLETE'

    hello_1_ids = sdk_tasks.get_task_ids(config.SERVICE_NAME, 'hello-1-server')
    sdk_cmd.svc_cli(config.PACKAGE_NAME, config.SERVICE_NAME,
                    'plan continue deploy hello-deploy')
    sdk_tasks.check_tasks_updated(config.SERVICE_NAME, 'hello-1-server',
                                  hello_1_ids)

    pl = sdk_plan.wait_for_completed_deployment(config.SERVICE_NAME)
    log.info(pl)

    assert pl['status'] == 'COMPLETE'

    assert len(pl['phases']) == 2

    phase = pl['phases'][0]
    assert phase['status'] == 'COMPLETE'
    steps = phase['steps']
    assert len(steps) == 5
    assert steps[0]['status'] == 'COMPLETE'
    assert steps[1]['status'] == 'COMPLETE'
    assert steps[2]['status'] == 'COMPLETE'
    assert steps[3]['status'] == 'COMPLETE'
    assert steps[4]['status'] == 'COMPLETE'

    phase = pl['phases'][1]
    assert phase['status'] == 'COMPLETE'
    steps = phase['steps']
    assert len(steps) == 4
    assert steps[0]['status'] == 'COMPLETE'
    assert steps[1]['status'] == 'COMPLETE'
    assert steps[2]['status'] == 'COMPLETE'
    assert steps[3]['status'] == 'COMPLETE'
def test_config_update_then_zk_killed():
    hello_ids = sdk_tasks.get_task_ids(config.SERVICE_NAME, 'hello')
    config.bump_hello_cpus()
    sdk_cmd.kill_task_with_pattern('zookeeper')
    sdk_tasks.check_tasks_updated(config.SERVICE_NAME, 'hello', hello_ids)
    config.check_running()
def test_increase_cpu():
    hello_0_ids = sdk_tasks.get_task_ids(config.SERVICE_NAME, "hello-0-server")
    config.bump_hello_cpus()

    pl = sdk_plan.wait_for_plan_status(config.SERVICE_NAME, "deploy", "WAITING")
    log.info(pl)

    assert pl["status"] == "WAITING"

    assert len(pl["phases"]) == 2

    phase = pl["phases"][0]
    assert phase["status"] == "WAITING"
    steps = phase["steps"]
    assert len(steps) == 5
    assert steps[0]["status"] == "WAITING"
    assert steps[1]["status"] == "WAITING"
    assert steps[2]["status"] == "PENDING"
    assert steps[3]["status"] == "PENDING"
    assert steps[4]["status"] == "PENDING"

    phase = pl["phases"][1]
    assert phase["status"] == "COMPLETE"
    steps = phase["steps"]
    assert len(steps) == 4
    assert steps[0]["status"] == "COMPLETE"
    assert steps[1]["status"] == "COMPLETE"
    assert steps[2]["status"] == "COMPLETE"
    assert steps[3]["status"] == "COMPLETE"

    # check that all prior tasks are still running, no changes yet
    expected_tasks = [
        "hello-0",
        "hello-1",
        "hello-2",
        "hello-3",
        "hello-4",
        "world-0",
        "world-1",
        "world-2",
        "world-3",
    ]
    sdk_tasks.check_running(config.SERVICE_NAME, len(expected_tasks))
    rc, stdout, _ = sdk_cmd.svc_cli(config.PACKAGE_NAME, config.SERVICE_NAME, "pod list")
    assert rc == 0, "Pod list failed"
    assert json.loads(stdout) == expected_tasks

    assert hello_0_ids == sdk_tasks.get_task_ids(config.SERVICE_NAME, "hello-0-server")

    sdk_cmd.svc_cli(config.PACKAGE_NAME, config.SERVICE_NAME, "plan continue deploy hello-deploy")

    sdk_tasks.check_tasks_updated(config.SERVICE_NAME, "hello-0-server", hello_0_ids)
    sdk_tasks.check_running(config.SERVICE_NAME, len(expected_tasks))

    pl = sdk_plan.wait_for_step_status(
        config.SERVICE_NAME, "deploy", "hello-deploy", "hello-0:[server]", "COMPLETE"
    )
    log.info(pl)

    assert pl["status"] == "WAITING"

    assert len(pl["phases"]) == 2

    phase = pl["phases"][0]
    assert phase["status"] == "WAITING"
    steps = phase["steps"]
    assert len(steps) == 5
    assert steps[0]["status"] == "COMPLETE"
    assert steps[1]["status"] == "WAITING"
    assert steps[2]["status"] == "PENDING"
    assert steps[3]["status"] == "PENDING"
    assert steps[4]["status"] == "PENDING"

    phase = pl["phases"][1]
    assert phase["status"] == "COMPLETE"
    steps = phase["steps"]
    assert len(steps) == 4
    assert steps[0]["status"] == "COMPLETE"
    assert steps[1]["status"] == "COMPLETE"
    assert steps[2]["status"] == "COMPLETE"
    assert steps[3]["status"] == "COMPLETE"

    hello_1_ids = sdk_tasks.get_task_ids(config.SERVICE_NAME, "hello-1-server")
    sdk_cmd.svc_cli(config.PACKAGE_NAME, config.SERVICE_NAME, "plan continue deploy hello-deploy")
    sdk_tasks.check_tasks_updated(config.SERVICE_NAME, "hello-1-server", hello_1_ids)

    pl = sdk_plan.wait_for_completed_deployment(config.SERVICE_NAME)
    log.info(pl)

    assert pl["status"] == "COMPLETE"

    assert len(pl["phases"]) == 2

    phase = pl["phases"][0]
    assert phase["status"] == "COMPLETE"
    steps = phase["steps"]
    assert len(steps) == 5
    assert steps[0]["status"] == "COMPLETE"
    assert steps[1]["status"] == "COMPLETE"
    assert steps[2]["status"] == "COMPLETE"
    assert steps[3]["status"] == "COMPLETE"
    assert steps[4]["status"] == "COMPLETE"

    phase = pl["phases"][1]
    assert phase["status"] == "COMPLETE"
    steps = phase["steps"]
    assert len(steps) == 4
    assert steps[0]["status"] == "COMPLETE"
    assert steps[1]["status"] == "COMPLETE"
    assert steps[2]["status"] == "COMPLETE"
    assert steps[3]["status"] == "COMPLETE"
def test_config_update_then_zk_killed():
    hello_ids = tasks.get_task_ids(PACKAGE_NAME, 'hello')
    bump_hello_cpus()
    tasks.kill_task_with_pattern('zookeeper')
    tasks.check_tasks_updated(PACKAGE_NAME, 'hello', hello_ids)
    check_running()