EMR and SWF - add arn to response (#3873)
* emr: add ClusterArn to describe_cluster response * emr: add ClusterArn to list_clusters response * emr: add ClusterArn to put_auto_scaling_policy response * emr: add ClusterArn to run_job_flow response * emr: rename property "cluster_arn" to simply "arn" * emr: generalize arn for account_id and region * swf: add arn to list_domains response * black reformat source code * fix double import * swf: require region on Domain object Co-authored-by: Kevin Neal <Kevin_Neal@intuit.com>
This commit is contained in:
parent
c31dffcc92
commit
8b523c3fe1
8 changed files with 73 additions and 21 deletions
|
|
@ -13,6 +13,7 @@ from botocore.exceptions import ClientError
|
|||
import pytest
|
||||
|
||||
from moto import mock_emr
|
||||
from moto.core import ACCOUNT_ID
|
||||
|
||||
|
||||
run_job_flow_args = dict(
|
||||
|
|
@ -76,7 +77,8 @@ input_instance_groups = [
|
|||
|
||||
@mock_emr
|
||||
def test_describe_cluster():
|
||||
client = boto3.client("emr", region_name="us-east-1")
|
||||
region_name = "us-east-1"
|
||||
client = boto3.client("emr", region_name=region_name)
|
||||
|
||||
args = deepcopy(run_job_flow_args)
|
||||
args["Applications"] = [{"Name": "Spark", "Version": "2.4.2"}]
|
||||
|
|
@ -178,6 +180,11 @@ def test_describe_cluster():
|
|||
|
||||
cl["TerminationProtected"].should.equal(False)
|
||||
cl["VisibleToAllUsers"].should.equal(True)
|
||||
cl["ClusterArn"].should.equal(
|
||||
"arn:aws:elasticmapreduce:{0}:{1}:cluster/{2}".format(
|
||||
region_name, ACCOUNT_ID, cluster_id
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@mock_emr
|
||||
|
|
@ -384,12 +391,17 @@ def test_list_clusters():
|
|||
|
||||
@mock_emr
|
||||
def test_run_job_flow():
|
||||
client = boto3.client("emr", region_name="us-east-1")
|
||||
region_name = "us-east-1"
|
||||
client = boto3.client("emr", region_name=region_name)
|
||||
args = deepcopy(run_job_flow_args)
|
||||
cluster_id = client.run_job_flow(**args)["JobFlowId"]
|
||||
resp = client.describe_job_flows(JobFlowIds=[cluster_id])["JobFlows"][0]
|
||||
resp = client.run_job_flow(**args)
|
||||
resp["ClusterArn"].startswith(
|
||||
"arn:aws:elasticmapreduce:{0}:{1}:cluster/".format(region_name, ACCOUNT_ID)
|
||||
)
|
||||
job_flow_id = resp["JobFlowId"]
|
||||
resp = client.describe_job_flows(JobFlowIds=[job_flow_id])["JobFlows"][0]
|
||||
resp["ExecutionStatusDetail"]["State"].should.equal("WAITING")
|
||||
resp["JobFlowId"].should.equal(cluster_id)
|
||||
resp["JobFlowId"].should.equal(job_flow_id)
|
||||
resp["Name"].should.equal(args["Name"])
|
||||
resp["Instances"]["MasterInstanceType"].should.equal(
|
||||
args["Instances"]["MasterInstanceType"]
|
||||
|
|
@ -544,8 +556,9 @@ def test_run_job_flow_with_instance_groups_with_autoscaling():
|
|||
|
||||
@mock_emr
|
||||
def test_put_remove_auto_scaling_policy():
|
||||
region_name = "us-east-1"
|
||||
input_groups = dict((g["Name"], g) for g in input_instance_groups)
|
||||
client = boto3.client("emr", region_name="us-east-1")
|
||||
client = boto3.client("emr", region_name=region_name)
|
||||
args = deepcopy(run_job_flow_args)
|
||||
args["Instances"] = {"InstanceGroups": input_instance_groups}
|
||||
cluster_id = client.run_job_flow(**args)["JobFlowId"]
|
||||
|
|
@ -567,6 +580,11 @@ def test_put_remove_auto_scaling_policy():
|
|||
)
|
||||
del resp["AutoScalingPolicy"]["Status"]
|
||||
resp["AutoScalingPolicy"].should.equal(auto_scaling_policy_with_cluster_id)
|
||||
resp["ClusterArn"].should.equal(
|
||||
"arn:aws:elasticmapreduce:{0}:{1}:cluster/{2}".format(
|
||||
region_name, ACCOUNT_ID, cluster_id
|
||||
)
|
||||
)
|
||||
|
||||
core_instance_group = [
|
||||
ig
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue