parent
b065a20d88
commit
8b0a6f3d27
@ -295,7 +295,7 @@ class JobDefinition(CloudFormationModel):
|
||||
if vcpus < 1:
|
||||
raise ClientException("container vcpus limit must be greater than 0")
|
||||
|
||||
def update(self, parameters, _type, container_properties, retry_strategy):
|
||||
def update(self, parameters, _type, container_properties, retry_strategy, tags):
|
||||
if parameters is None:
|
||||
parameters = self.parameters
|
||||
|
||||
@ -316,6 +316,7 @@ class JobDefinition(CloudFormationModel):
|
||||
region_name=self._region,
|
||||
revision=self.revision,
|
||||
retry_strategy=retry_strategy,
|
||||
tags=tags,
|
||||
)
|
||||
|
||||
def describe(self):
|
||||
@ -1276,9 +1277,9 @@ class BatchBackend(BaseBackend):
|
||||
retry_strategy = retry_strategy["attempts"]
|
||||
except Exception:
|
||||
raise ClientException("retryStrategy is malformed")
|
||||
if not tags:
|
||||
tags = {}
|
||||
if job_def is None:
|
||||
if not tags:
|
||||
tags = {}
|
||||
job_def = JobDefinition(
|
||||
def_name,
|
||||
parameters,
|
||||
@ -1291,7 +1292,7 @@ class BatchBackend(BaseBackend):
|
||||
else:
|
||||
# Make new jobdef
|
||||
job_def = job_def.update(
|
||||
parameters, _type, container_properties, retry_strategy
|
||||
parameters, _type, container_properties, retry_strategy, tags
|
||||
)
|
||||
|
||||
self._job_definitions[job_def.arn] = job_def
|
||||
|
@ -667,3 +667,47 @@ def prepare_job(batch_client, commands, iam_arn, job_def_name):
|
||||
)
|
||||
job_def_arn = resp["jobDefinitionArn"]
|
||||
return job_def_arn, queue_arn
|
||||
|
||||
|
||||
@mock_batch
|
||||
def test_update_job_definition():
|
||||
_, _, _, _, batch_client = _get_clients()
|
||||
|
||||
tags = [
|
||||
{"Foo1": "bar1", "Baz1": "buzz1"},
|
||||
{"Foo2": "bar2", "Baz2": "buzz2"},
|
||||
]
|
||||
|
||||
container_props = {
|
||||
"image": "amazonlinux",
|
||||
"memory": 1024,
|
||||
"vcpus": 2,
|
||||
}
|
||||
|
||||
batch_client.register_job_definition(
|
||||
jobDefinitionName="test-job",
|
||||
type="container",
|
||||
tags=tags[0],
|
||||
parameters={},
|
||||
containerProperties=container_props,
|
||||
)
|
||||
|
||||
container_props["memory"] = 2048
|
||||
batch_client.register_job_definition(
|
||||
jobDefinitionName="test-job",
|
||||
type="container",
|
||||
tags=tags[1],
|
||||
parameters={},
|
||||
containerProperties=container_props,
|
||||
)
|
||||
|
||||
job_defs = batch_client.describe_job_definitions(jobDefinitionName="test-job")[
|
||||
"jobDefinitions"
|
||||
]
|
||||
job_defs.should.have.length_of(2)
|
||||
|
||||
job_defs[0]["containerProperties"]["memory"].should.equal(1024)
|
||||
job_defs[0]["tags"].should.equal(tags[0])
|
||||
|
||||
job_defs[1]["containerProperties"]["memory"].should.equal(2048)
|
||||
job_defs[1]["tags"].should.equal(tags[1])
|
||||
|
Loading…
Reference in New Issue
Block a user