Skip to content

Commit

Permalink
Merge branch 'release/1.5.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
fabfuel committed Nov 10, 2018
2 parents 0c4a34b + e6ded73 commit 2b30878
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
2 changes: 1 addition & 1 deletion ecs_deploy/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = '1.4.4'
VERSION = '1.5.0'
16 changes: 9 additions & 7 deletions ecs_deploy/ecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ def deregister_task_definition(self, task_definition_arn):
)

def update_service(self, cluster, service, desired_count, task_definition):
if desired_count is None:
return self.boto.update_service(
cluster=cluster,
service=service,
taskDefinition=task_definition
)
return self.boto.update_service(
cluster=cluster,
service=service,
Expand All @@ -77,9 +83,6 @@ def __init__(self, cluster, service_definition=None, **kwargs):
self._cluster = cluster
super(EcsService, self).__init__(service_definition, **kwargs)

def set_desired_count(self, desired_count):
self[u'desiredCount'] = desired_count

def set_task_definition(self, task_definition):
self[u'taskDefinition'] = task_definition.arn

Expand Down Expand Up @@ -385,11 +388,11 @@ def update_task_definition(self, task_definition):
def deregister_task_definition(self, task_definition):
self._client.deregister_task_definition(task_definition.arn)

def update_service(self, service):
def update_service(self, service, desired_count=None):
response = self._client.update_service(
cluster=service.cluster,
service=service.name,
desired_count=service.desired_count,
desired_count=desired_count,
task_definition=service.task_definition
)
return EcsService(self._cluster_name, response[u'service'])
Expand Down Expand Up @@ -451,8 +454,7 @@ def deploy(self, task_definition):
class ScaleAction(EcsAction):
def scale(self, desired_count):
try:
self._service.set_desired_count(desired_count)
return self.update_service(self._service)
return self.update_service(self._service, desired_count)
except ClientError as e:
raise EcsError(str(e))

Expand Down
11 changes: 2 additions & 9 deletions tests/test_ecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,6 @@ def test_service_init(service):
assert service[u'taskDefinition'] == TASK_DEFINITION_ARN_1


def test_service_set_desired_count(service):
assert service.desired_count == DESIRED_COUNT
service.set_desired_count(5)
assert service.desired_count == 5


def test_service_set_task_definition(service, task_definition):
assert service.task_definition == TASK_DEFINITION_ARN_1
service.set_task_definition(task_definition)
Expand Down Expand Up @@ -610,7 +604,7 @@ def test_update_service(client, service):
client.update_service.assert_called_once_with(
cluster=service.cluster,
service=service.name,
desired_count=service.desired_count,
desired_count=None,
task_definition=service.task_definition
)

Expand Down Expand Up @@ -647,7 +641,7 @@ def test_is_not_deployed_with_more_than_one_deployment(client, service):
def test_is_deployed_if_no_tasks_should_be_running(client, service):
client.list_tasks.return_value = RESPONSE_LIST_TASKS_0
action = EcsAction(client, CLUSTER_NAME, SERVICE_NAME)
service.set_desired_count(0)
service[u'desiredCount'] = 0
is_deployed = action.is_deployed(service)
assert is_deployed is True

Expand Down Expand Up @@ -702,7 +696,6 @@ def test_scale_action(client):
action = ScaleAction(client, CLUSTER_NAME, SERVICE_NAME)
updated_service = action.scale(5)

assert action.service.desired_count == 5
assert isinstance(updated_service, EcsService)

client.describe_services.assert_called_once_with(
Expand Down

0 comments on commit 2b30878

Please sign in to comment.