Skip to content

Commit

Permalink
Merge pull request #2034 from pasc/describe_cluster_bugfix
Browse files Browse the repository at this point in the history
Fixed EMR's describe_cluster_command. Fixes #2034.
  • Loading branch information
danielgtaylor committed Feb 4, 2014
2 parents 4d780bd + bec8ca8 commit 1c5621e
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 3 deletions.
3 changes: 2 additions & 1 deletion boto/emr/emrobject.py
Expand Up @@ -262,11 +262,12 @@ def startElement(self, name, attrs, connection):
if name == 'Status':
self.status = ClusterStatus()
return self.status
elif name == 'EC2InstanceAttributes':
elif name == 'Ec2InstanceAttributes':
self.ec2instanceattributes = Ec2InstanceAttributes()
return self.ec2instanceattributes
elif name == 'Applications':
self.applications = ResultSet([('member', Application)])
return self.applications
elif name == 'Tags':
self.tags = ResultSet([('member', KeyValue)])
return self.tags
Expand Down
58 changes: 56 additions & 2 deletions tests/unit/emr/test_connection.py
Expand Up @@ -27,7 +27,7 @@
from tests.unit import AWSMockServiceTestCase

from boto.emr.connection import EmrConnection
from boto.emr.emrobject import JobFlowStepList, StepSummaryList
from boto.emr.emrobject import Cluster, JobFlowStepList, StepSummaryList

# These tests are just checking the basic structure of
# the Elastic MapReduce code, by picking a few calls
Expand Down Expand Up @@ -223,7 +223,47 @@ class TestDescribeCluster(AWSMockServiceTestCase):
connection_class = EmrConnection

def default_body(self):
return """<DescribeClusterOutput></DescribeClusterOutput>"""
return """
<DescribeClusterResponse xmlns="http://elasticmapreduce.amazonaws.com/doc/2009-03-31">
<DescribeClusterResult>
<Cluster>
<Id>j-aaaaaaaaa</Id>
<Tags/>
<Ec2InstanceAttributes>
<Ec2AvailabilityZone>us-west-1c</Ec2AvailabilityZone>
<Ec2KeyName>my_secret_key</Ec2KeyName>
</Ec2InstanceAttributes>
<RunningAmiVersion>2.4.2</RunningAmiVersion>
<VisibleToAllUsers>true</VisibleToAllUsers>
<Status>
<StateChangeReason>
<Message>Terminated by user request</Message>
<Code>USER_REQUEST</Code>
</StateChangeReason>
<State>TERMINATED</State>
<Timeline>
<CreationDateTime>2014-01-24T01:21:21Z</CreationDateTime>
<ReadyDateTime>2014-01-24T01:25:26Z</ReadyDateTime>
<EndDateTime>2014-01-24T02:19:46Z</EndDateTime>
</Timeline>
</Status>
<AutoTerminate>false</AutoTerminate>
<Name>test analytics</Name>
<RequestedAmiVersion>2.4.2</RequestedAmiVersion>
<Applications>
<member>
<Name>hadoop</Name>
<Version>1.0.3</Version>
</member>
</Applications>
<TerminationProtected>false</TerminationProtected>
</Cluster>
</DescribeClusterResult>
<ResponseMetadata>
<RequestId>aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee</RequestId>
</ResponseMetadata>
</DescribeClusterResponse>
"""

def test_describe_cluster(self):
self.set_http_response(200)
Expand All @@ -233,6 +273,20 @@ def test_describe_cluster(self):

response = self.service_connection.describe_cluster(cluster_id='j-123')

self.assertTrue(isinstance(response, Cluster))
self.assertEqual(response.id, 'j-aaaaaaaaa')
self.assertEqual(response.runningamiversion, '2.4.2')
self.assertEqual(response.visibletoallusers, 'true')
self.assertEqual(response.autoterminate, 'false')
self.assertEqual(response.name, 'test analytics')
self.assertEqual(response.requestedamiversion, '2.4.2')
self.assertEqual(response.terminationprotected, 'false')
self.assertEqual(response.ec2instanceattributes.ec2availabilityzone, "us-west-1c")
self.assertEqual(response.ec2instanceattributes.ec2keyname, 'my_secret_key')
self.assertEqual(response.status.state, 'TERMINATED')
self.assertEqual(response.applications[0].name, 'hadoop')
self.assertEqual(response.applications[0].version, '1.0.3')

self.assert_request_parameters({
'Action': 'DescribeCluster',
'ClusterId': 'j-123',
Expand Down

0 comments on commit 1c5621e

Please sign in to comment.