Add deployments to the ecs services (describe_services)
This commit is contained in:
parent
34c711189f
commit
0ae6e404d0
@ -1,7 +1,9 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import uuid
|
import uuid
|
||||||
from random import random
|
from datetime import datetime
|
||||||
|
from random import random, randint
|
||||||
|
|
||||||
|
import pytz
|
||||||
from moto.core import BaseBackend, BaseModel
|
from moto.core import BaseBackend, BaseModel
|
||||||
from moto.ec2 import ec2_backends
|
from moto.ec2 import ec2_backends
|
||||||
from copy import copy
|
from copy import copy
|
||||||
@ -174,6 +176,18 @@ class Service(BaseObject):
|
|||||||
self.task_definition = task_definition.arn
|
self.task_definition = task_definition.arn
|
||||||
self.desired_count = desired_count
|
self.desired_count = desired_count
|
||||||
self.events = []
|
self.events = []
|
||||||
|
self.deployments = [
|
||||||
|
{
|
||||||
|
'createdAt': datetime.now(pytz.utc),
|
||||||
|
'desiredCount': self.desired_count,
|
||||||
|
'id': 'ecs-svc/{}'.format(randint(0, 32**12)),
|
||||||
|
'pendingCount': self.desired_count,
|
||||||
|
'runningCount': 0,
|
||||||
|
'status': 'PRIMARY',
|
||||||
|
'taskDefinition': task_definition.arn,
|
||||||
|
'updatedAt': datetime.now(pytz.utc),
|
||||||
|
}
|
||||||
|
]
|
||||||
self.load_balancers = []
|
self.load_balancers = []
|
||||||
self.pending_count = 0
|
self.pending_count = 0
|
||||||
|
|
||||||
@ -187,6 +201,13 @@ class Service(BaseObject):
|
|||||||
del response_object['name'], response_object['arn']
|
del response_object['name'], response_object['arn']
|
||||||
response_object['serviceName'] = self.name
|
response_object['serviceName'] = self.name
|
||||||
response_object['serviceArn'] = self.arn
|
response_object['serviceArn'] = self.arn
|
||||||
|
|
||||||
|
for deployment in response_object['deployments']:
|
||||||
|
if isinstance(deployment['createdAt'], datetime):
|
||||||
|
deployment['createdAt'] = deployment['createdAt'].isoformat()
|
||||||
|
if isinstance(deployment['updatedAt'], datetime):
|
||||||
|
deployment['updatedAt'] = deployment['updatedAt'].isoformat()
|
||||||
|
|
||||||
return response_object
|
return response_object
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -402,6 +402,11 @@ def test_describe_services():
|
|||||||
'arn:aws:ecs:us-east-1:012345678910:service/test_ecs_service2')
|
'arn:aws:ecs:us-east-1:012345678910:service/test_ecs_service2')
|
||||||
response['services'][1]['serviceName'].should.equal('test_ecs_service2')
|
response['services'][1]['serviceName'].should.equal('test_ecs_service2')
|
||||||
|
|
||||||
|
response['services'][0]['deployments'][0]['desiredCount'].should.equal(2)
|
||||||
|
response['services'][0]['deployments'][0]['pendingCount'].should.equal(2)
|
||||||
|
response['services'][0]['deployments'][0]['runningCount'].should.equal(0)
|
||||||
|
response['services'][0]['deployments'][0]['status'].should.equal('PRIMARY')
|
||||||
|
|
||||||
|
|
||||||
@mock_ecs
|
@mock_ecs
|
||||||
def test_update_service():
|
def test_update_service():
|
||||||
|
Loading…
Reference in New Issue
Block a user