Skip to content

Instantly share code, notes, and snippets.

@loren
Created April 3, 2017 20:33
Show Gist options
  • Save loren/59792a6238e084b810613a6d7df167be to your computer and use it in GitHub Desktop.
Save loren/59792a6238e084b810613a6d7df167be to your computer and use it in GitHub Desktop.
@pytest.mark.sanity
@pytest.mark.recovery
def test_change_constraint():
install.uninstall(PACKAGE_NAME)
options = {
"service": {
"spec_file": "examples/marathon_constraint.yml"
},
"hello": {
"count": num_private_agents,
"placement": "hostname:UNIQUE"
},
"world": {
"count": 0
}
}
install.install(PACKAGE_NAME, num_private_agents, additional_options=options)
plan.get_deployment_plan(PACKAGE_NAME)
# change placement constraint, but tasks should not update
hello_ids = tasks.get_task_ids(PACKAGE_NAME, 'hello')
config = marathon.get_config(PACKAGE_NAME)
some_agent = shakedown.get_private_agents().pop()
config['env']['HELLO_PLACEMENT'] = "hostname:CLUSTER:{}".format(some_agent)
marathon.update_app(PACKAGE_NAME, config)
time.sleep(30)
check_running()
tasks.check_tasks_not_updated(PACKAGE_NAME, 'hello', hello_ids)
# all tasks should end up on `some_agent`, even the one that started there
for pod_index in range(num_private_agents):
cmd.run_cli('hello-world pods replace hello-{}'.format(pod_index))
check_running()
ensure_multiple_per_agent(hello=num_private_agents, world=0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment