Skip to content

Commit

Permalink
made itests catch MarathonHttpError
Browse files Browse the repository at this point in the history
  • Loading branch information
mjksmith committed Feb 16, 2016
1 parent 5409dbb commit 17fb510
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
7 changes: 3 additions & 4 deletions paasta_itests/setup_marathon_job.feature
Expand Up @@ -2,22 +2,21 @@ Feature: setup_marathon_job can create a "complete" app

Scenario: complete apps can be deployed
Given a working paasta cluster
When we create a complete app
When we create a complete app with 1 instance(s)
Then we should see it in the list of apps
Then we can run get_app on it
Then we should see the number of instances become 1

Scenario: marathon apps can be scaled up
Given a working paasta cluster
When we create a complete app
When we create a complete app with 1 instance(s)
And we change the number of instances to 5
And we run setup_marathon_job until the instance count is 5
Then we should see the number of instances become 5

Scenario: marathon apps can be scaled down
Given a working paasta cluster
When we change the number of instances to 5
And we create a complete app
When we create a complete app with 5 instance(s)
And we change the number of instances to 1
And we run setup_marathon_job until the instance count is 1
Then we should see the number of instances become 1
15 changes: 13 additions & 2 deletions paasta_itests/steps/setup_marathon_job_steps.py
Expand Up @@ -17,6 +17,7 @@
import mock
from behave import then
from behave import when
from marathon.exceptions import MarathonHttpError

from paasta_tools import marathon_tools
from paasta_tools import setup_marathon_job
Expand Down Expand Up @@ -83,7 +84,6 @@ def create_complete_app(context):
):
mock_create_complete_config.return_value = fake_service_config
mock_load_system_paasta_config.return_value.get_cluster = mock.Mock(return_value=context.cluster)
print marathon_tools.load_marathon_config()
return_tuple = setup_marathon_job.setup_service(
service=fake_service_name,
instance=fake_instance_name,
Expand All @@ -96,14 +96,25 @@ def create_complete_app(context):
assert 'deployed' in return_tuple[1]


@when(u'we create a complete app with {number} instance(s)')
def create_complete_app_with_instances(context, number):
change_number_of_context_instances(context, number)
create_complete_app(context)


@when(u'we change the number of instances to {number}')
def change_number_of_context_instances(context, number):
fake_service_config['instances'] = int(number)


@when(u'we run setup_marathon_job until the instance count is {number}')
def run_setup_marathon_job(context, number):
while context.marathon_client.get_app(fake_appid).instances != int(number):
app_instances = -1
while app_instances != int(number):
try:
app_instances = context.marathon_client.get_app(fake_appid).instances
except MarathonHttpError:
pass
create_complete_app(context)
time.sleep(1)

Expand Down
1 change: 0 additions & 1 deletion paasta_tools/bounce_lib.py
Expand Up @@ -363,7 +363,6 @@ def crossover_bounce(
for app, tasks in old_app_live_unhappy_tasks.items():
for task in tasks:
old_tasks.append(task)

return {
"create_app": False,
"tasks_to_drain": set(set(old_tasks[needed_count:])),
Expand Down
2 changes: 1 addition & 1 deletion paasta_tools/setup_marathon_job.py
Expand Up @@ -413,7 +413,7 @@ def log_deploy_error(errormsg, level='event'):
if new_app.instances < config['instances']:
client.scale_app(app_id=new_app.id, instances=config['instances'], force=True)
elif new_app.instances > config['instances']:
num_tasks_to_scale = new_app.instances - config['instances']
num_tasks_to_scale = len(new_app.tasks) - config['instances']
task_dict = get_old_happy_unhappy_draining_tasks_for_app(
new_app,
drain_method,
Expand Down

0 comments on commit 17fb510

Please sign in to comment.