def test_config_update_while_partitioned(): world_tasks = sdk_tasks.get_service_tasks(config.SERVICE_NAME, "world") partition_host = world_tasks[0].host sdk_agents.partition_agent(partition_host) service_config = sdk_marathon.get_config(config.SERVICE_NAME) updated_cpus = float(service_config["env"]["WORLD_CPUS"]) + 0.1 service_config["env"]["WORLD_CPUS"] = str(updated_cpus) sdk_marathon.update_app(service_config, wait_for_completed_deployment=False) sdk_agents.reconnect_agent(partition_host) # check that ALL the world tasks are updated after the agent reconnects: sdk_tasks.check_tasks_updated(config.SERVICE_NAME, "world", [t.id for t in world_tasks]) check_healthy() all_tasks = sdk_tasks.get_service_tasks(config.SERVICE_NAME) running_tasks = [ t for t in all_tasks if t.name.startswith("world") and t.state == "TASK_RUNNING" ] assert len(running_tasks) == config.world_task_count(config.SERVICE_NAME) for t in running_tasks: assert config.close_enough(t.resources["cpus"], updated_cpus)
def test_bump_world_cpus(): original_world_ids = sdk_tasks.get_task_ids(foldered_name, "world") log.info("world ids: " + str(original_world_ids)) updated_cpus = config.bump_world_cpus(foldered_name) sdk_tasks.check_tasks_updated(foldered_name, "world", original_world_ids) sdk_plan.wait_for_completed_deployment(foldered_name) all_tasks = sdk_tasks.get_service_tasks(foldered_name, task_prefix="world") running_tasks = [t for t in all_tasks if t.state == "TASK_RUNNING"] assert len(running_tasks) == config.world_task_count(foldered_name) for t in running_tasks: assert config.close_enough(t.resources["cpus"], updated_cpus)
def test_bump_world_cpus(): original_world_ids = sdk_tasks.get_task_ids(foldered_name, "world") log.info("world ids: " + str(original_world_ids)) updated_cpus = config.bump_world_cpus(foldered_name) sdk_tasks.check_tasks_updated(foldered_name, "world", original_world_ids) sdk_plan.wait_for_completed_deployment(foldered_name) all_tasks = sdk_tasks.get_service_tasks(foldered_name, task_prefix="world") running_tasks = [t for t in all_tasks if t.state == "TASK_RUNNING"] assert len(running_tasks) == config.world_task_count(foldered_name) for t in running_tasks: assert config.close_enough(t.resources["cpus"], updated_cpus)
def test_bump_world_cpus(): config.check_running(FOLDERED_SERVICE_NAME) world_ids = sdk_tasks.get_task_ids(FOLDERED_SERVICE_NAME, 'world') log.info('world ids: ' + str(world_ids)) updated_cpus = config.bump_world_cpus(FOLDERED_SERVICE_NAME) sdk_tasks.check_tasks_updated(FOLDERED_SERVICE_NAME, 'world', world_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('world') and t['state'] == "TASK_RUNNING"] assert len(running_tasks) == config.world_task_count(FOLDERED_SERVICE_NAME) for t in running_tasks: assert close_enough(t['resources']['cpus'], updated_cpus)
def test_bump_world_cpus(): check_running() world_ids = tasks.get_task_ids(PACKAGE_NAME, 'world') sdk_utils.out('world ids: ' + str(world_ids)) updated_cpus = bump_world_cpus() tasks.check_tasks_updated(PACKAGE_NAME, 'world', world_ids) check_running() all_tasks = shakedown.get_service_tasks(PACKAGE_NAME) running_tasks = [t for t in all_tasks if t['name'].startswith('world') and t['state'] == "TASK_RUNNING"] assert len(running_tasks) == world_task_count() for t in running_tasks: assert close_enough(t['resources']['cpus'], updated_cpus)
def test_bump_world_cpus(): config.check_running(FOLDERED_SERVICE_NAME) world_ids = sdk_tasks.get_task_ids(FOLDERED_SERVICE_NAME, 'world') log.info('world ids: ' + str(world_ids)) updated_cpus = config.bump_world_cpus(FOLDERED_SERVICE_NAME) sdk_tasks.check_tasks_updated(FOLDERED_SERVICE_NAME, 'world', world_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('world') and t['state'] == "TASK_RUNNING"] assert len(running_tasks) == config.world_task_count(FOLDERED_SERVICE_NAME) for t in running_tasks: assert close_enough(t['resources']['cpus'], updated_cpus)
def test_bump_world_cpus(): foldered_name = sdk_utils.get_foldered_name(config.SERVICE_NAME) config.check_running(foldered_name) original_world_ids = sdk_tasks.get_task_ids(foldered_name, 'world') log.info('world ids: ' + str(original_world_ids)) updated_cpus = config.bump_world_cpus(foldered_name) sdk_tasks.check_tasks_updated(foldered_name, 'world', original_world_ids) config.check_running(foldered_name) all_tasks = shakedown.get_service_tasks(foldered_name) running_tasks = [t for t in all_tasks if t['name'].startswith('world') and t['state'] == "TASK_RUNNING"] assert len(running_tasks) == config.world_task_count(foldered_name) for t in running_tasks: assert config.close_enough(t['resources']['cpus'], updated_cpus)
def test_bump_world_cpus(): foldered_name = sdk_utils.get_foldered_name(config.SERVICE_NAME) config.check_running(foldered_name) original_world_ids = sdk_tasks.get_task_ids(foldered_name, 'world') log.info('world ids: ' + str(original_world_ids)) updated_cpus = config.bump_world_cpus(foldered_name) sdk_tasks.check_tasks_updated(foldered_name, 'world', original_world_ids) config.check_running(foldered_name) all_tasks = shakedown.get_service_tasks(foldered_name) running_tasks = [t for t in all_tasks if t['name'].startswith('world') and t['state'] == "TASK_RUNNING"] assert len(running_tasks) == config.world_task_count(foldered_name) for t in running_tasks: assert config.close_enough(t['resources']['cpus'], updated_cpus)
def test_config_update_while_partitioned(): world_ids = sdk_tasks.get_task_ids(config.SERVICE_NAME, 'world') host = sdk_hosts.system_host(config.SERVICE_NAME, "world-0-server") shakedown.partition_agent(host) service_config = sdk_marathon.get_config(config.SERVICE_NAME) updated_cpus = float(service_config['env']['WORLD_CPUS']) + 0.1 service_config['env']['WORLD_CPUS'] = str(updated_cpus) sdk_marathon.update_app(config.SERVICE_NAME, service_config, wait_for_completed_deployment=False) shakedown.reconnect_agent(host) sdk_tasks.check_tasks_updated(config.SERVICE_NAME, 'world', world_ids) config.check_running() all_tasks = shakedown.get_service_tasks(config.SERVICE_NAME) running_tasks = [t for t in all_tasks if t['name'].startswith('world') and t['state'] == "TASK_RUNNING"] assert len(running_tasks) == config.world_task_count(config.SERVICE_NAME) for t in running_tasks: assert config.close_enough(t['resources']['cpus'], updated_cpus)
def test_config_update_while_partitioned(): world_ids = sdk_tasks.get_task_ids(config.SERVICE_NAME, 'world') host = sdk_hosts.system_host(config.SERVICE_NAME, "world-0-server") shakedown.partition_agent(host) service_config = sdk_marathon.get_config(config.SERVICE_NAME) updated_cpus = float(service_config['env']['WORLD_CPUS']) + 0.1 service_config['env']['WORLD_CPUS'] = str(updated_cpus) sdk_marathon.update_app(config.SERVICE_NAME, service_config, wait_for_completed_deployment=False) shakedown.reconnect_agent(host) sdk_tasks.check_tasks_updated(config.SERVICE_NAME, 'world', world_ids) config.check_running() all_tasks = shakedown.get_service_tasks(config.SERVICE_NAME) running_tasks = [t for t in all_tasks if t['name'].startswith('world') and t['state'] == "TASK_RUNNING"] assert len(running_tasks) == config.world_task_count(config.SERVICE_NAME) for t in running_tasks: assert config.close_enough(t['resources']['cpus'], updated_cpus)
def test_bump_world_cpus(): check_running() world_ids = tasks.get_task_ids(PACKAGE_NAME, 'world') print('world ids: ' + str(world_ids)) config = marathon.get_config(PACKAGE_NAME) cpus = float(config['env']['WORLD_CPUS']) updated_cpus = cpus + 0.1 config['env']['WORLD_CPUS'] = str(updated_cpus) marathon.update_app(PACKAGE_NAME, config) tasks.check_tasks_updated(PACKAGE_NAME, 'world', world_ids) check_running() all_tasks = shakedown.get_service_tasks(PACKAGE_NAME) running_tasks = [t for t in all_tasks if t['name'].startswith('world') and t['state'] == "TASK_RUNNING"] assert len(running_tasks) == world_task_count() for t in running_tasks: assert close_enough(t['resources']['cpus'], updated_cpus)
def test_bump_world_cpus(): check_running() world_ids = tasks.get_task_ids(PACKAGE_NAME, 'world') print('world ids: ' + str(world_ids)) config = marathon.get_config(PACKAGE_NAME) cpus = float(config['env']['WORLD_CPUS']) updated_cpus = cpus + 0.1 config['env']['WORLD_CPUS'] = str(updated_cpus) marathon.update_app(PACKAGE_NAME, config) tasks.check_tasks_updated(PACKAGE_NAME, 'world', world_ids) check_running() all_tasks = shakedown.get_service_tasks(PACKAGE_NAME) running_tasks = [ t for t in all_tasks if t['name'].startswith('world') and t['state'] == "TASK_RUNNING" ] assert len(running_tasks) == world_task_count() for t in running_tasks: assert close_enough(t['resources']['cpus'], updated_cpus)
def test_config_update_while_partitioned(): world_tasks = sdk_tasks.get_service_tasks(config.SERVICE_NAME, "world") partition_host = world_tasks[0].host sdk_agents.partition_agent(partition_host) service_config = sdk_marathon.get_config(config.SERVICE_NAME) updated_cpus = float(service_config["env"]["WORLD_CPUS"]) + 0.1 service_config["env"]["WORLD_CPUS"] = str(updated_cpus) sdk_marathon.update_app(service_config, wait_for_completed_deployment=False) sdk_agents.reconnect_agent(partition_host) # check that ALL the world tasks are updated after the agent reconnects: sdk_tasks.check_tasks_updated(config.SERVICE_NAME, "world", [t.id for t in world_tasks]) check_healthy() all_tasks = sdk_tasks.get_service_tasks(config.SERVICE_NAME) running_tasks = [ t for t in all_tasks if t.name.startswith("world") and t.state == "TASK_RUNNING" ] assert len(running_tasks) == config.world_task_count(config.SERVICE_NAME) for t in running_tasks: assert config.close_enough(t.resources["cpus"], updated_cpus)