def test_bump_hello_nodes(): check_running() hello_ids = tasks.get_task_ids(PACKAGE_NAME, 'hello') print('hello ids: ' + str(hello_ids)) config = marathon.get_config(PACKAGE_NAME) node_count = int(config['env']['HELLO_COUNT']) + 1 config['env']['HELLO_COUNT'] = str(node_count) marathon.update_app(PACKAGE_NAME, config) check_running() tasks.check_tasks_not_updated(PACKAGE_NAME, 'hello', hello_ids)
def test_state_refresh_disable_cache(): '''Disables caching via a scheduler envvar''' check_running(FOLDERED_SERVICE_NAME) task_ids = tasks.get_task_ids(FOLDERED_SERVICE_NAME, '') # caching enabled by default: stdout = cmd.run_cli('hello-world --name={} state refresh_cache'.format( FOLDERED_SERVICE_NAME)) assert "Received cmd: refresh" in stdout config = marathon.get_config(FOLDERED_SERVICE_NAME) config['env']['DISABLE_STATE_CACHE'] = 'any-text-here' marathon.update_app(FOLDERED_SERVICE_NAME, config) tasks.check_tasks_not_updated(FOLDERED_SERVICE_NAME, '', task_ids) check_running(FOLDERED_SERVICE_NAME) # caching disabled, refresh_cache should fail with a 409 error (eventually, once scheduler is up): def check_cache_refresh_fails_409conflict(): try: cmd.run_cli('hello-world --name={} state refresh_cache'.format( FOLDERED_SERVICE_NAME)) except Exception as e: if "failed: 409 Conflict" in e.args[0]: return True return False shakedown.wait_for(lambda: check_cache_refresh_fails_409conflict(), timeout_seconds=120.) config = marathon.get_config(FOLDERED_SERVICE_NAME) del config['env']['DISABLE_STATE_CACHE'] marathon.update_app(FOLDERED_SERVICE_NAME, config) tasks.check_tasks_not_updated(FOLDERED_SERVICE_NAME, '', task_ids) check_running(FOLDERED_SERVICE_NAME) shakedown.deployment_wait( ) # ensure marathon thinks the deployment is complete too # caching reenabled, refresh_cache should succeed (eventually, once scheduler is up): def check_cache_refresh(): return cmd.run_cli('hello-world --name={} state refresh_cache'.format( FOLDERED_SERVICE_NAME)) stdout = shakedown.wait_for(lambda: check_cache_refresh(), timeout_seconds=120.) assert "Received cmd: refresh" in stdout
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)