Updated delete_cluster() for redshift (#2186)
* Updated the deprecated decorator to allow the "SkipFinalClusterSnapshot" option that aws supports. * FIxed logical mistake on the delete_cluster * Removed an unused exception I put in
This commit is contained in:
parent
8cb4db1896
commit
1fd71fd45a
3 changed files with 50 additions and 11 deletions
|
|
@ -9,7 +9,7 @@ from boto.redshift.exceptions import (
|
|||
ClusterParameterGroupNotFound,
|
||||
ClusterSecurityGroupNotFound,
|
||||
ClusterSubnetGroupNotFound,
|
||||
InvalidSubnet,
|
||||
InvalidSubnet
|
||||
)
|
||||
from botocore.exceptions import (
|
||||
ClientError
|
||||
|
|
@ -339,7 +339,7 @@ def test_create_cluster_with_vpc_security_groups_boto3():
|
|||
|
||||
@mock_redshift
|
||||
def test_create_cluster_with_iam_roles():
|
||||
iam_roles_arn = ['arn:aws:iam:::role/my-iam-role',]
|
||||
iam_roles_arn = ['arn:aws:iam:::role/my-iam-role', ]
|
||||
client = boto3.client('redshift', region_name='us-east-1')
|
||||
cluster_id = 'my_cluster'
|
||||
client.create_cluster(
|
||||
|
|
@ -385,29 +385,41 @@ def test_describe_non_existent_cluster():
|
|||
conn.describe_clusters.when.called_with(
|
||||
"not-a-cluster").should.throw(ClusterNotFound)
|
||||
|
||||
|
||||
@mock_redshift_deprecated
|
||||
def test_delete_cluster():
|
||||
conn = boto.connect_redshift()
|
||||
cluster_identifier = 'my_cluster'
|
||||
cluster_identifier = "my_cluster"
|
||||
snapshot_identifier = "my_snapshot"
|
||||
|
||||
conn.create_cluster(
|
||||
cluster_identifier,
|
||||
node_type='single-node',
|
||||
node_type="single-node",
|
||||
master_username="username",
|
||||
master_user_password="password",
|
||||
)
|
||||
|
||||
conn.delete_cluster.when.called_with(cluster_identifier, False).should.throw(AttributeError)
|
||||
|
||||
clusters = conn.describe_clusters()['DescribeClustersResponse'][
|
||||
'DescribeClustersResult']['Clusters']
|
||||
list(clusters).should.have.length_of(1)
|
||||
|
||||
conn.delete_cluster(cluster_identifier)
|
||||
conn.delete_cluster(
|
||||
cluster_identifier=cluster_identifier,
|
||||
skip_final_cluster_snapshot=False,
|
||||
final_cluster_snapshot_identifier=snapshot_identifier
|
||||
)
|
||||
|
||||
clusters = conn.describe_clusters()['DescribeClustersResponse'][
|
||||
'DescribeClustersResult']['Clusters']
|
||||
list(clusters).should.have.length_of(0)
|
||||
|
||||
snapshots = conn.describe_cluster_snapshots()["DescribeClusterSnapshotsResponse"][
|
||||
"DescribeClusterSnapshotsResult"]["Snapshots"]
|
||||
list(snapshots).should.have.length_of(1)
|
||||
|
||||
assert snapshot_identifier in snapshots[0]["SnapshotIdentifier"]
|
||||
|
||||
# Delete invalid id
|
||||
conn.delete_cluster.when.called_with(
|
||||
"not-a-cluster").should.throw(ClusterNotFound)
|
||||
|
|
@ -643,7 +655,6 @@ def test_delete_cluster_parameter_group():
|
|||
"not-a-parameter-group").should.throw(ClusterParameterGroupNotFound)
|
||||
|
||||
|
||||
|
||||
@mock_redshift
|
||||
def test_create_cluster_snapshot_of_non_existent_cluster():
|
||||
client = boto3.client('redshift', region_name='us-east-1')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue