2011-09-06 15:51:30 -04:00
|
|
|
Shindo.tests('AWS::Elasticache | cache cluster requests', ['aws', 'elasticache']) do
|
|
|
|
|
|
|
|
tests('success') do
|
|
|
|
pending if Fog.mocking?
|
|
|
|
|
2011-09-08 12:04:46 -04:00
|
|
|
# Randomize the cluster ID so tests can be fequently re-run
|
|
|
|
cluster_id = "fog-test-cluster-#{rand(999).to_s}" # 20 chars max!
|
2011-09-13 05:00:45 -04:00
|
|
|
num_nodes = 2
|
2011-09-06 15:51:30 -04:00
|
|
|
|
|
|
|
tests(
|
|
|
|
'#create_cache_cluster'
|
|
|
|
).formats(AWS::Elasticache::Formats::SINGLE_CACHE_CLUSTER) do
|
2011-09-13 05:00:45 -04:00
|
|
|
body = AWS[:elasticache].create_cache_cluster(cluster_id,
|
|
|
|
:num_nodes => num_nodes
|
|
|
|
).body
|
2011-09-06 15:51:30 -04:00
|
|
|
cluster = body['CacheCluster']
|
|
|
|
returns(cluster_id) { cluster['CacheClusterId'] }
|
2011-09-09 10:52:40 -04:00
|
|
|
returns('creating') { cluster['CacheClusterStatus'] }
|
2011-09-06 15:51:30 -04:00
|
|
|
body
|
|
|
|
end
|
|
|
|
|
|
|
|
tests(
|
|
|
|
'#describe_cache_clusters without options'
|
|
|
|
).formats(AWS::Elasticache::Formats::DESCRIBE_CACHE_CLUSTERS) do
|
|
|
|
body = AWS[:elasticache].describe_cache_clusters.body
|
|
|
|
returns(true, "has #{cluster_id}") do
|
|
|
|
body['CacheClusters'].any? do |cluster|
|
|
|
|
cluster['CacheClusterId'] == cluster_id
|
|
|
|
end
|
|
|
|
end
|
2011-09-07 16:22:31 -04:00
|
|
|
# The DESCRIBE_CACHE_CLUSTERS format must include only one cluster
|
|
|
|
# So remove all but the relevant cluster from the response body
|
|
|
|
test_cluster = body['CacheClusters'].delete_if do |cluster|
|
|
|
|
cluster['CacheClusterId'] != cluster_id
|
|
|
|
end
|
2011-09-06 15:51:30 -04:00
|
|
|
body
|
|
|
|
end
|
|
|
|
|
|
|
|
tests(
|
|
|
|
'#describe_cache_clusters with cluster ID'
|
|
|
|
).formats(AWS::Elasticache::Formats::DESCRIBE_CACHE_CLUSTERS) do
|
2011-09-09 10:52:40 -04:00
|
|
|
body = AWS[:elasticache].describe_cache_clusters(cluster_id).body
|
2011-09-06 15:51:30 -04:00
|
|
|
returns(1, "size of 1") { body['CacheClusters'].size }
|
|
|
|
returns(cluster_id, "has #{cluster_id}") do
|
|
|
|
body['CacheClusters'].first['CacheClusterId']
|
|
|
|
end
|
|
|
|
body
|
|
|
|
end
|
|
|
|
|
2011-09-08 13:04:46 -04:00
|
|
|
Formatador.display_line "Waiting for cluster #{cluster_id}..."
|
|
|
|
AWS[:elasticache].clusters.get(cluster_id).wait_for {ready?}
|
2011-09-06 16:46:12 -04:00
|
|
|
|
2011-09-13 05:00:45 -04:00
|
|
|
tests(
|
|
|
|
'#describe_cache_clusters with node info'
|
|
|
|
).formats(AWS::Elasticache::Formats::CACHE_CLUSTER_RUNNING) do
|
|
|
|
cluster = AWS[:elasticache].describe_cache_clusters(cluster_id,
|
|
|
|
:show_node_info => true
|
|
|
|
).body['CacheClusters'].first
|
|
|
|
returns(num_nodes, "has #{num_nodes} nodes") do
|
|
|
|
cluster['CacheNodes'].count
|
|
|
|
end
|
|
|
|
cluster
|
|
|
|
end
|
|
|
|
|
2011-09-09 15:33:48 -04:00
|
|
|
tests(
|
|
|
|
'#modify_cache_cluster - change a non-pending cluster attribute'
|
|
|
|
).formats(AWS::Elasticache::Formats::CACHE_CLUSTER_RUNNING) do
|
|
|
|
body = AWS[:elasticache].modify_cache_cluster(cluster_id,
|
|
|
|
:auto_minor_version_upgrade => false
|
|
|
|
).body
|
|
|
|
# now check that parameter change is in place
|
|
|
|
returns('false') { body['CacheCluster']['AutoMinorVersionUpgrade'] }
|
|
|
|
body['CacheCluster']
|
|
|
|
end
|
|
|
|
|
2011-09-06 16:46:12 -04:00
|
|
|
tests(
|
2011-09-08 13:04:46 -04:00
|
|
|
'#delete_cache_clusters'
|
2011-09-06 16:46:12 -04:00
|
|
|
).formats(AWS::Elasticache::Formats::CACHE_CLUSTER_RUNNING) do
|
|
|
|
body = AWS[:elasticache].delete_cache_cluster(cluster_id).body
|
|
|
|
# make sure this particular cluster is in the returned list
|
|
|
|
returns(true, "has #{cluster_id}") do
|
|
|
|
body['CacheClusters'].any? do |cluster|
|
|
|
|
cluster['CacheClusterId'] == cluster_id
|
|
|
|
end
|
|
|
|
end
|
|
|
|
# now check that it reports itself as 'deleting'
|
|
|
|
cluster = body['CacheClusters'].find do |cluster|
|
|
|
|
cluster['CacheClusterId'] == cluster_id
|
|
|
|
end
|
|
|
|
returns('deleting') { cluster['CacheClusterStatus'] }
|
|
|
|
cluster
|
|
|
|
end
|
2011-09-06 15:51:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
tests('failure') do
|
|
|
|
# TODO:
|
|
|
|
# Create a duplicate cluster ID
|
|
|
|
# List a missing cache cluster
|
|
|
|
# Delete a missing cache cluster
|
|
|
|
end
|
|
|
|
end
|