Skip to content

Commit 6f0cb4d

Browse files
Batch: Accept compute env name in computeEnvironmentOrder when creating job queue
1 parent ec3224f commit 6f0cb4d

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

moto/batch/models.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1549,11 +1549,13 @@ def create_job_queue(
15491549
for item in sorted(compute_env_order, key=lambda x: x["order"])
15501550
]
15511551
env_objects = []
1552-
# Check each ARN exists, then make a list of compute env's
1553-
for arn in ordered_compute_environments:
1554-
env = self.get_compute_environment_by_arn(arn)
1552+
# Check each compute env exists, then make a list of them
1553+
for identifier in ordered_compute_environments:
1554+
env = self.get_compute_environment(identifier)
15551555
if env is None:
1556-
raise ClientException(f"Compute environment {arn} does not exist")
1556+
raise ClientException(
1557+
f"Compute environment {identifier} does not exist"
1558+
)
15571559
env_objects.append(env)
15581560
except Exception:
15591561
raise ClientException("computeEnvironmentOrder is malformed")

tests/test_batch/test_batch_tags_job_queue.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
from uuid import uuid4
22

3+
import pytest
4+
35
from moto import mock_aws
46

57
from . import _get_clients, _setup
68

79

810
@mock_aws
9-
def test_create_job_queue_with_tags():
11+
@pytest.mark.parametrize("use_compute_env_arn", [True, False])
12+
def test_create_job_queue_with_tags(use_compute_env_arn):
1013
ec2_client, iam_client, _, _, batch_client = _get_clients()
1114
_, _, _, iam_arn = _setup(ec2_client, iam_client)
1215

@@ -17,14 +20,18 @@ def test_create_job_queue_with_tags():
1720
state="ENABLED",
1821
serviceRole=iam_arn,
1922
)
20-
arn = resp["computeEnvironmentArn"]
23+
compute_env_identifier = (
24+
resp["computeEnvironmentArn"] if use_compute_env_arn else compute_name
25+
)
2126

2227
jq_name = str(uuid4())[0:6]
2328
resp = batch_client.create_job_queue(
2429
jobQueueName=jq_name,
2530
state="ENABLED",
2631
priority=123,
27-
computeEnvironmentOrder=[{"order": 123, "computeEnvironment": arn}],
32+
computeEnvironmentOrder=[
33+
{"order": 123, "computeEnvironment": compute_env_identifier}
34+
],
2835
tags={"k1": "v1", "k2": "v2"},
2936
)
3037
assert "jobQueueArn" in resp

0 commit comments

Comments
 (0)