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

0.4.8 Release #54

Merged
merged 4 commits into from
Apr 1, 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
2 changes: 1 addition & 1 deletion deployer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from celery.signals import setup_logging


__version__ = '0.4.7'
__version__ = '0.4.8'
__author__ = 'sukrit'

deployer.logger.init_logging()
Expand Down
15 changes: 10 additions & 5 deletions deployer/tasks/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@ def create_search_parameters(deployment, defaults=None):
"""

deployment = dict_merge(deployment or {}, defaults or {}, {
'meta-info': {}
'meta-info': {},
'deployment': {
'name': '',
'version': ''
},
'id': ''
})
return {
'meta-info': dict_merge(
Expand Down Expand Up @@ -232,12 +237,12 @@ def delete(name, version=None):
versions are undeployed.
:return:
"""
search_params = {
search_params = create_search_parameters({
'deployment': {
'name': name,
'version': version or 'all'
}
}
})
return _using_lock.si(
search_params, name,
do_task=(
Expand All @@ -247,7 +252,7 @@ def delete(name, version=None):
_fleet_undeploy.si(name, version) |
_wait_for_undeploy.si(name, version, search_params=search_params)
)
)()
).apply_async()


@app.task
Expand Down Expand Up @@ -280,7 +285,7 @@ def _using_lock(self, search_params, name, do_task, cleanup_tasks=None,
try:
lock = LockService().apply_lock(name)
except ResourceLockedException as lock_error:
self.retry(exc=lock_error)
raise self.retry(exc=lock_error)

_release_lock_s = _release_lock.si(lock)
cleanup_tasks = cleanup_tasks or []
Expand Down
30 changes: 28 additions & 2 deletions tests/unit/tasks/test_deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from paramiko import SSHException

from conf.appconfig import DEPLOYMENT_MODE_BLUEGREEN, \
DEPLOYMENT_MODE_REDGREEN, DEPLOYMENT_STATE_STARTED
DEPLOYMENT_MODE_REDGREEN, DEPLOYMENT_STATE_STARTED, CLUSTER_NAME
from deployer.celery import app
from deployer.tasks.exceptions import NodeNotUndeployed, MinNodesNotRunning, \
NodeCheckFailed, MinNodesNotDiscovered, MaxStartConcurrencyReached
Expand All @@ -17,7 +17,7 @@

from deployer.tasks.deployment import _pre_create_undeploy, \
_wait_for_undeploy, _fleet_check_deploy, _check_node, _check_deployment, \
_check_discover, _start_deployment
_check_discover, _start_deployment, create_search_parameters

__author__ = 'sukrit'

Expand Down Expand Up @@ -484,3 +484,29 @@ def side_effect(**kwargs):
# Then: Deployment state gets updated as expected
m_store.update_state.assert_called_once_with(MOCK_DEPLOYMENT_ID,
DEPLOYMENT_STATE_STARTED)


def test_create_search_parameters():
# Given: Minimal deployment for which search parameters needs to be created
dep = {
'deployment': {
'name': 'dummy-deployment'
}
}

# When: I create search parameters for the given deployment
search_params = create_search_parameters(dep)

# Then: Expected Search parameters are returned
dict_compare(search_params, {
'deployment': {
'name': 'dummy-deployment',
'version': '',
'id': ''
},
'meta-info': {
'deployer': {
'cluster': CLUSTER_NAME
}
}
})