Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new itest to assert new services have a desired_state of start #227

Merged
merged 2 commits into from
Feb 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions general_itests/deployments_json.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work with the existing git-repo in place? In the previous scenario we run paasta "stop", so I guess we .. somehow clear out the git repo between scenarios?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that the context is cleared between the scenarios (and the tests appear to confirm that). This is also why I removed the shutil.rmtree call in the corresponding step (it would cause issues if you try and chain multiple 'then' steps).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool.

When we generate deployments.json for that service
Then that deployments.json has a desired_state of "start"
14 changes: 10 additions & 4 deletions general_itests/steps/deployments_json_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.
import contextlib
import os
import shutil
import tempfile
from datetime import datetime
from time import time
Expand All @@ -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')
Expand Down Expand Up @@ -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,
Expand All @@ -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 "{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 == expected_state