From 5df5fe70ee32d4c7d202b24c81bbca21a7d0c3da Mon Sep 17 00:00:00 2001 From: Nathan Handler Date: Wed, 3 Feb 2016 16:21:29 -0800 Subject: [PATCH 1/2] Add a new itest to assert new services have a desired_state of start --- general_itests/deployments_json.feature | 5 +++++ general_itests/steps/deployments_json_steps.py | 14 ++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/general_itests/deployments_json.feature b/general_itests/deployments_json.feature index bb359f5ba1..5884b5f71a 100644 --- a/general_itests/deployments_json.feature +++ b/general_itests/deployments_json.feature @@ -5,3 +5,8 @@ Feature: Per-Service Deployments.json can be written and read back When paasta stop is run against the repo And we generate deployments.json for that service Then that deployments.json can be read back correctly + + Scenario: New services have a desired_state of "start" + Given a test git repo is setup with commits + When we generate deployments.json for that service + Then that deployments.json has a desired_state of "start" diff --git a/general_itests/steps/deployments_json_steps.py b/general_itests/steps/deployments_json_steps.py index c533d611ce..9ef5051845 100644 --- a/general_itests/steps/deployments_json_steps.py +++ b/general_itests/steps/deployments_json_steps.py @@ -13,7 +13,6 @@ # limitations under the License. import contextlib import os -import shutil import tempfile from datetime import datetime from time import time @@ -29,9 +28,9 @@ from dulwich.repo import Repo from paasta_tools import generate_deployments_for_service -from paasta_tools import marathon_tools from paasta_tools.cli.cmds.start_stop_restart import format_timestamp from paasta_tools.cli.cmds.start_stop_restart import paasta_stop +from paasta_tools.utils import load_deployments_json @given(u'a test git repo is setup with commits') @@ -110,7 +109,7 @@ def step_impl_when(context): @then(u'that deployments.json can be read back correctly') def step_impl_then(context): - deployments = marathon_tools.load_deployments_json('fake_deployments_json_service', soa_dir='fake_soa_configs') + deployments = load_deployments_json('fake_deployments_json_service', soa_dir='fake_soa_configs') expected_deployments = { 'fake_deployments_json_service:paasta-test_cluster.test_instance': { 'force_bounce': context.force_bounce_timestamp, @@ -124,4 +123,11 @@ def step_impl_then(context): }, } assert expected_deployments == deployments, "actual: %s\nexpected:%s" % (deployments, expected_deployments) - shutil.rmtree(context.test_git_repo_dir) + + +@then(u'that deployments.json has a desired_state of "{state}"') +def step_impl_then_desired_state(context, state): + deployments = load_deployments_json('fake_deployments_json_service', soa_dir='fake_soa_configs') + latest = sorted(deployments.iteritems(), key=lambda(key, value): value['force_bounce'], reverse=True)[0][1] + desired_state = latest['desired_state'] + assert desired_state == state From 279e098b679b3c1a5b325bc346d91d4403259f47 Mon Sep 17 00:00:00 2001 From: Nathan Handler Date: Wed, 3 Feb 2016 16:42:02 -0800 Subject: [PATCH 2/2] s/state/expected_state/ --- general_itests/steps/deployments_json_steps.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/general_itests/steps/deployments_json_steps.py b/general_itests/steps/deployments_json_steps.py index 9ef5051845..21e8e7f71b 100644 --- a/general_itests/steps/deployments_json_steps.py +++ b/general_itests/steps/deployments_json_steps.py @@ -125,9 +125,9 @@ def step_impl_then(context): assert expected_deployments == deployments, "actual: %s\nexpected:%s" % (deployments, expected_deployments) -@then(u'that deployments.json has a desired_state of "{state}"') -def step_impl_then_desired_state(context, state): +@then(u'that deployments.json has a desired_state of "{expected_state}"') +def step_impl_then_desired_state(context, expected_state): deployments = load_deployments_json('fake_deployments_json_service', soa_dir='fake_soa_configs') latest = sorted(deployments.iteritems(), key=lambda(key, value): value['force_bounce'], reverse=True)[0][1] desired_state = latest['desired_state'] - assert desired_state == state + assert desired_state == expected_state