mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
refactoring common parser code. cluster requests tests
This commit is contained in:
parent
f83629550b
commit
fad43b8694
11 changed files with 213 additions and 268 deletions
29
lib/fog/aws/parsers/redshift/cluster.rb
Normal file
29
lib/fog/aws/parsers/redshift/cluster.rb
Normal file
|
@ -0,0 +1,29 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module Redshift
|
||||
module AWS
|
||||
require 'fog/aws/parsers/redshift/cluster_parser'
|
||||
|
||||
class Cluster < ClusterParser
|
||||
def reset
|
||||
super
|
||||
@response = {}
|
||||
end
|
||||
|
||||
def start_element(name, attrs = [])
|
||||
super
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
super
|
||||
case name
|
||||
when 'Cluster'
|
||||
@response = @cluster
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -4,53 +4,57 @@ module Fog
|
|||
module AWS
|
||||
|
||||
class ClusterParser < Fog::Parsers::Base
|
||||
# :allow_version_upgrade` - (Boolean) z
|
||||
# :automated_snapshot_retention_period` - (Integer) w
|
||||
# :availability_zone` - (String) x
|
||||
# :cluster_create_time` - (Time) y
|
||||
# :cluster_identifier` - (String) x
|
||||
# :cluster_parameter_groups` - (Array<Hash>)
|
||||
# :parameter_group_name` - (String)
|
||||
# :parameter_apply_status` - (String)
|
||||
# :cluster_security_groups` - (Array<Hash>)
|
||||
# :cluster_security_group_name` - (String)
|
||||
# :status` - (String)
|
||||
# :cluster_status` - (String) x
|
||||
# :cluster_subnet_group_name` - (String) x
|
||||
# :cluster_version` - (String) x
|
||||
# :db_name` - (String) x
|
||||
# :encrypted` - (Boolean) z
|
||||
# :endpoint` - (Hash)
|
||||
# :address` - (String)
|
||||
# :port` - (Integer)
|
||||
# :master_username` - (String) x
|
||||
# :modify_status` - (String) x
|
||||
# :node_type` - (String) x
|
||||
# :number_of_nodes` - (Integer) w
|
||||
# :pending_modified_values` - (Hash)
|
||||
# :master_user_password` - (String)
|
||||
# :node_type` - (String)
|
||||
# :number_of_nodes` - (Integer)
|
||||
# :cluster_type` - (String)
|
||||
# :cluster_version` - (String)
|
||||
# :automated_snapshot_retention_period` - (Integer)
|
||||
# :preferred_maintenance_window` - (String) x
|
||||
# :publicly_accessible` - (Boolean) z
|
||||
# :restore_status` - (Hash)
|
||||
# :status` - (String)
|
||||
# :current_restore_rate_in_mega_bytes_per_second` - (Numeric)
|
||||
# :snapshot_size_in_mega_bytes` - (Integer)
|
||||
# :progress_in_mega_bytes` - (Integer)
|
||||
# :elapsed_time_in_seconds` - (Integer)
|
||||
# :estimated_time_to_completion_in_seconds` - (Integer)
|
||||
# :vpc_id` - (String) x
|
||||
# :vpc_security_groups` - (Array<Hash>)
|
||||
# :vpc_security_group_id` - (String)
|
||||
# :status` - (String)
|
||||
# :cluster_identifier - (String)
|
||||
# :node_type - (String)
|
||||
# :cluster_status - (String)
|
||||
# :modify_status - (String)
|
||||
# :master_username - (String)
|
||||
# :db_name - (String)
|
||||
# :endpoint - (Hash)
|
||||
# :address - (String)
|
||||
# :port - (Integer)
|
||||
# :cluster_create_time - (Time)
|
||||
# :automated_snapshot_retention_period - (Integer)
|
||||
# :cluster_security_groups - (Array)
|
||||
# :cluster_security_group_name - (String)
|
||||
# :status - (String)
|
||||
# :vpc_security_groups - (Array)
|
||||
# :vpc_security_group_id - (String)
|
||||
# :status - (String)
|
||||
# :cluster_parameter_groups - (Array)
|
||||
# :parameter_group_name - (String)
|
||||
# :parameter_apply_status - (String)
|
||||
# :cluster_subnet_group_name - (String)
|
||||
# :vpc_id - (String)
|
||||
# :availability_zone - (String)
|
||||
# :preferred_maintenance_window - (String)
|
||||
# :pending_modified_values - (Hash)
|
||||
# :master_user_password - (String)
|
||||
# :node_type - (String)
|
||||
# :number_of_nodes - (Integer)
|
||||
# :cluster_type - (String)
|
||||
# :cluster_version - (String)
|
||||
# :automated_snapshot_retention_period - (Integer)
|
||||
# :cluster_version - (String)
|
||||
# :allow_version_upgrade - (Boolean)
|
||||
# :number_of_nodes - (Integer)
|
||||
# :publicly_accessible - (Boolean)
|
||||
# :encrypted - (Boolean)
|
||||
# :restore_status - (Hash)
|
||||
# :status - (String)
|
||||
# :current_restore_rate_in_mega_bytes_per_second - (Numeric)
|
||||
# :snapshot_size_in_mega_bytes - (Integer)
|
||||
# :progress_in_mega_bytes - (Integer)
|
||||
# :elapsed_time_in_seconds - (Integer)
|
||||
# :estimated_time_to_completion_in_seconds - (Integer)
|
||||
|
||||
def reset
|
||||
@response = { 'ClusterParameterGroups' => [], 'ClusterSecurityGroups' => [], 'VpcSecurityGroups' => [],
|
||||
'EndPoint' => {}, 'PendingModifiedValues'=> {}, 'RestoreStatus' => {}}
|
||||
@cluster = fresh_cluster
|
||||
end
|
||||
|
||||
def fresh_cluster
|
||||
{ 'ClusterParameterGroups' => [], 'ClusterSecurityGroups' => [], 'VpcSecurityGroups' => [],
|
||||
'EndPoint' => {}, 'PendingModifiedValues'=> {}, 'RestoreStatus' => {}}
|
||||
end
|
||||
|
||||
def start_element(name, attrs = [])
|
||||
|
@ -73,36 +77,36 @@ module Fog
|
|||
case name
|
||||
when 'AvailabilityZone', 'ClusterIdentifier', 'ClusterStatus', 'ClusterSubnetGroupName', 'DBName',
|
||||
'MasterUsername', 'ModifyStatus', 'PreferredMaintenanceWindow', 'VpcId'
|
||||
@response[name] = value
|
||||
@cluster[name] = value
|
||||
when 'ClusterCreateTime'
|
||||
@response[name] = Time.parse(value)
|
||||
@cluster[name] = Time.parse(value)
|
||||
when 'AllowVersionUpgrade', 'Encrypted', 'PubliclyAccessible'
|
||||
@response[name] = (value == true)
|
||||
@cluster[name] = (value == true)
|
||||
when 'Address'
|
||||
@response['EndPoint'][name] = value
|
||||
@cluster['EndPoint'][name] = value
|
||||
when 'Port'
|
||||
@response['EndPoint'][name] = value.to_i
|
||||
@cluster['EndPoint'][name] = value.to_i
|
||||
when 'NodeType', 'ClusterVersion'
|
||||
if @in_pending_modified_values
|
||||
@response['PendingModifiedValues'][name] = value
|
||||
@cluster['PendingModifiedValues'][name] = value
|
||||
else
|
||||
@response[name] = value
|
||||
@cluster[name] = value
|
||||
end
|
||||
when 'NumberOfNodes', 'AutomatedSnapshotRetentionPeriod'
|
||||
if @in_pending_modified_values
|
||||
@response['PendingModifiedValues'][name] = value.to_i
|
||||
@cluster['PendingModifiedValues'][name] = value.to_i
|
||||
else
|
||||
@response[name] = value.to_i
|
||||
@cluster[name] = value.to_i
|
||||
end
|
||||
when 'MasterUserPassword', 'ClusterType'
|
||||
@response['PendingModifiedValues'][name] = value
|
||||
@cluster['PendingModifiedValues'][name] = value
|
||||
when 'Status'
|
||||
if @in_vpc_security_groups
|
||||
@vpc_security_group[name] = value
|
||||
elsif @in_cluster_security_groups
|
||||
@cluster_security_group[name] = value
|
||||
else
|
||||
@response['RestoreStatus'][name] = value
|
||||
@cluster['RestoreStatus'][name] = value
|
||||
end
|
||||
when 'ParameterGroupName', 'ParameterApplyStatus'
|
||||
@cluster_parameter_group[name] = value
|
||||
|
@ -111,9 +115,9 @@ module Fog
|
|||
when 'VpcSecurityGroupId'
|
||||
@vpc_security_group[name] = value
|
||||
when 'SnapshotSizeInMegaBytes', 'ProgressInMegaBytes', 'ElapsedTimeInSeconds', 'EstimatedTimeToCompletionInSeconds'
|
||||
@response['RestoreStatus'][name] = value.to_i
|
||||
@cluster['RestoreStatus'][name] = value.to_i
|
||||
when 'CurrentRestoreRateInMegaBytesPerSecond'
|
||||
@response['RestoreStatus'][name] = value.to_f
|
||||
@cluster['RestoreStatus'][name] = value.to_f
|
||||
|
||||
when 'ClusterSecurityGroups'
|
||||
@in_cluster_security_groups = false
|
||||
|
@ -123,15 +127,14 @@ module Fog
|
|||
@in_pending_modified_values = false
|
||||
|
||||
when 'ClusterParameterGroup'
|
||||
@response['ClusterParameterGroups'] << @cluster_parameter_group
|
||||
@cluster['ClusterParameterGroups'] << @cluster_parameter_group
|
||||
@cluster_parameter_group = {}
|
||||
when 'ClusterSecurityGroup'
|
||||
@response['ClusterSecurityGroups'] << @cluster_security_group
|
||||
@cluster['ClusterSecurityGroups'] << @cluster_security_group
|
||||
@cluster_security_group = {}
|
||||
when 'VpcSecurityGroup'
|
||||
@response['VpcSecurityGroups'] << @vpc_security_group
|
||||
@cluster['VpcSecurityGroups'] << @vpc_security_group
|
||||
@vpc_security_group = {}
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module Redshift
|
||||
module AWS
|
||||
|
||||
class ClusterSubnetGroupParser < Fog::Parsers::Base
|
||||
# :cluster_subnet_group_name - (String)
|
||||
# :description - (String)
|
||||
# :vpc_id - (String)
|
||||
# :subnet_group_status - (String)
|
||||
# :subnets - (Array)
|
||||
# :subnet_identifier - (String)
|
||||
# :subnet_availability_zone - (Hash)
|
||||
# :name - (String)
|
||||
# :subnet_status - (String)
|
||||
|
||||
def reset
|
||||
@response = { 'Subnets' => [] }
|
||||
end
|
||||
|
||||
def fresh_subnet
|
||||
{'SubnetAvailabilityZone'=>{}}
|
||||
end
|
||||
|
||||
def start_element(name, attrs = [])
|
||||
super
|
||||
case name
|
||||
when 'Subnets'
|
||||
@subnet = fresh_subnet
|
||||
end
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
super
|
||||
case name
|
||||
when 'ClusterSubnetGroupName', 'Desciption', 'VpcId', 'SubnetGroupStatus'
|
||||
@response[name] = value
|
||||
when 'SubnetIdentifier', 'SubnetStatus'
|
||||
@subnet[name] = value
|
||||
when 'Name'
|
||||
@subnet['SubnetAvailabilityZone'][name] = value
|
||||
when 'Subnet'
|
||||
@response['Subnets'] << @subnet
|
||||
@subnet = fresh_subnet
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -2,114 +2,25 @@ module Fog
|
|||
module Parsers
|
||||
module Redshift
|
||||
module AWS
|
||||
require 'fog/aws/parsers/redshift/cluster_parser'
|
||||
|
||||
class DescribeClusters < Fog::Parsers::Base
|
||||
|
||||
class DescribeClusters < ClusterParser
|
||||
def reset
|
||||
@response = { 'ClusterSet' => [] }
|
||||
@cluster = fresh_cluster
|
||||
@context = []
|
||||
@contexts = ['EndPoint', 'ClusterSecurityGroups', 'VpcSecurityGroups', 'ClusterParameterGroups', 'PendingModifiedValues', 'RestoreStatus']
|
||||
end
|
||||
|
||||
def fresh_cluster
|
||||
{
|
||||
'EndPoint' => {},
|
||||
'ClusterSecurityGroups' => [],
|
||||
'VpcSecurityGroups' => [],
|
||||
'ClusterParameterGroups' => [],
|
||||
'PendingModifiedValues' => {},
|
||||
'RestoreStatus' => {}
|
||||
}
|
||||
super
|
||||
@response = {"ClusterSet" => []}
|
||||
end
|
||||
|
||||
def start_element(name, attrs = [])
|
||||
super
|
||||
@context.push(name) if @contexts.include?(name)
|
||||
case name
|
||||
when 'ClusterSecurityGroups'
|
||||
@in_cluster_security_groups = true
|
||||
@cluster_security_groups = []
|
||||
when 'ClusterSecurityGroup'
|
||||
@cluster_security_group = {}
|
||||
when 'VpcSecurityGroups'
|
||||
@in_vpc_security_groups = true
|
||||
@vpc_security_groups = []
|
||||
when 'VpcSecurityGroup'
|
||||
@vpc_security_group = {}
|
||||
when 'ClusterParameterGroups'
|
||||
@cluster_parameter_groups = []
|
||||
when 'ClusterParameterGroup'
|
||||
@cluster_parameter_group = {}
|
||||
end
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
super
|
||||
case name
|
||||
when 'Marker'
|
||||
@response[name] = value
|
||||
when 'ClusterIdentifier', 'NodeType', 'ClusterStatus', 'ModifyStatus', 'MasterUsername', 'DBName',
|
||||
'ClusterSubnetGroupName', 'VpcId', 'AvailabilityZone', 'PreferredMaintenanceWindow', 'ClusterVersion'
|
||||
@cluster[name] = value
|
||||
when 'Address'
|
||||
@cluster['EndPoint'][name] = value
|
||||
when 'Port','AutomatedSnapshotRetentionPeriod'
|
||||
@cluster['EndPoint'][name] = value.to_i
|
||||
when 'ClusterCreateTime'
|
||||
@cluster['EndPoint'][name] = Time.parse(value)
|
||||
when 'VpcSecurityGroups'
|
||||
@in_vpc_security_groups = false
|
||||
@cluster['VpcSecurityGroups'] = @vpc_security_groups
|
||||
when 'VpcSecurityGroup'
|
||||
@vpc_security_groups << @vpc_security_group
|
||||
@vpc_security_group = {}
|
||||
when 'VpcSecurityGroupId'
|
||||
@vpc_security_group[name]=value
|
||||
when 'ClusterSecurityGroups'
|
||||
@in_cluster_security_groups = false
|
||||
@cluster['ClusterSecurityGroups'] = @cluster_security_groups
|
||||
when 'ClusterSecurityGroup'
|
||||
@cluster_security_groups << @cluster_security_group
|
||||
@cluster_security_group = {}
|
||||
when 'ClusterSecurityGroupName'
|
||||
@cluster_security_group[name] = value
|
||||
when 'ClusterParameterGroups'
|
||||
@cluster['ClusterParameterGroups'] = @cluster_parameter_groups
|
||||
when 'ClusterParameterGroup'
|
||||
@cluster_parameter_groups << @cluster_parameter_group
|
||||
@cluster_parameter_group = {}
|
||||
when 'ParameterGroupName', 'ParameterApplyStatus'
|
||||
@cluster_parameter_group[name] = value
|
||||
when 'Status'
|
||||
if @in_vpc_security_groups
|
||||
@vpc_security_group[name] = value
|
||||
elsif @in_cluster_security_groups
|
||||
@cluster_security_group[name] = value
|
||||
else
|
||||
@cluster['RestoreStatus'][name] = value
|
||||
end
|
||||
when 'MasterUserPassword', 'NodeType', 'ClusterType', 'ClusterVersion'
|
||||
@cluster['PendingModifiedValues'][name] = value
|
||||
when 'AutomatedSnapshotRetentionPeriod'
|
||||
@cluster['PendingModifiedValues'][name] = value
|
||||
when 'NumberOfNodes'
|
||||
if @context.last == 'PendingModifiedValues'
|
||||
@cluster['PendingModifiedValues'][name] = value.to_i
|
||||
else
|
||||
@cluster[name] = value.to_i
|
||||
end
|
||||
when 'AllowVersionUpgrade', 'PubliclyAccessible', 'Encrypted'
|
||||
@cluster[name] = (value == true)
|
||||
when 'SnapshotSizeInMegaBytes', 'ProgressInMegaBytes', 'ElapsedTimeInSeconds', 'EstimatedTimeToCompletionInSeconds'
|
||||
@cluster['RestoreStatus'] = value.to_i
|
||||
when 'CurrentRestoreRateInMegaBytesPerSecond'
|
||||
@cluster['RestoreStatus'] = value.to_f
|
||||
when 'Cluster'
|
||||
@response['ClusterSet'] << @cluster
|
||||
@response["ClusterSet"] << @cluster
|
||||
@cluster = fresh_cluster
|
||||
end
|
||||
@context.pop if @contexts.include?(name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -117,4 +28,3 @@ module Fog
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ module Fog
|
|||
# request :authorize_snapshot_access
|
||||
# request :copy_cluster_snapshot
|
||||
# request :purchase_reserved_node_offering
|
||||
# request :reboot_cluster
|
||||
request :reboot_cluster
|
||||
# request :reset_cluster_parameter_group
|
||||
# request :restore_from_cluster_snapshot
|
||||
# request :revoke_cluster_security_group_ingress
|
||||
|
|
|
@ -2,7 +2,7 @@ module Fog
|
|||
module AWS
|
||||
class Redshift
|
||||
class Real
|
||||
require 'fog/aws/parsers/redshift/cluster_parser'
|
||||
require 'fog/aws/parsers/redshift/cluster'
|
||||
|
||||
# ==== Parameters
|
||||
#
|
||||
|
@ -108,7 +108,7 @@ module Fog
|
|||
:path => path,
|
||||
:method => :put,
|
||||
:query => {},
|
||||
:parser => Fog::Parsers::Redshift::AWS::ClusterParser.new
|
||||
:parser => Fog::Parsers::Redshift::AWS::Cluster.new
|
||||
}
|
||||
|
||||
if cluster_security_groups = options.delete(:ClusterSecurityGroups)
|
||||
|
|
|
@ -2,7 +2,7 @@ module Fog
|
|||
module AWS
|
||||
class Redshift
|
||||
class Real
|
||||
require 'fog/aws/parsers/redshift/cluster_parser'
|
||||
require 'fog/aws/parsers/redshift/cluster'
|
||||
|
||||
# ==== Parameters
|
||||
#
|
||||
|
@ -35,7 +35,7 @@ module Fog
|
|||
:path => path,
|
||||
:method => :put,
|
||||
:query => {},
|
||||
:parser => Fog::Parsers::Redshift::AWS::ClusterParser.new
|
||||
:parser => Fog::Parsers::Redshift::AWS::Cluster.new
|
||||
}
|
||||
|
||||
params[:query]['Action'] = 'DeleteCluster'
|
||||
|
|
|
@ -2,7 +2,7 @@ module Fog
|
|||
module AWS
|
||||
class Redshift
|
||||
class Real
|
||||
require 'fog/aws/parsers/redshift/cluster_parser'
|
||||
require 'fog/aws/parsers/redshift/cluster'
|
||||
|
||||
# ==== Parameters
|
||||
#
|
||||
|
@ -76,7 +76,7 @@ module Fog
|
|||
:path => path,
|
||||
:method => :put,
|
||||
:query => {},
|
||||
:parser => Fog::Parsers::Redshift::AWS::ClusterParser.new
|
||||
:parser => Fog::Parsers::Redshift::AWS::Cluster.new
|
||||
}
|
||||
|
||||
if cluster_security_groups = options.delete(:ClusterSecurityGroups)
|
||||
|
|
|
@ -19,7 +19,7 @@ module Fog
|
|||
#
|
||||
# ==== See Also
|
||||
# http://docs.aws.amazon.com/redshift/latest/APIReference/API_ModifyClusterSubnetGroup.html
|
||||
def create_cluster_subnet_group(options = {})
|
||||
def modify_cluster_subnet_group(options = {})
|
||||
cluster_subnet_group_name = options[:cluster_subnet_group_name]
|
||||
description = options[:description]
|
||||
|
||||
|
|
36
lib/fog/aws/requests/redshift/reboot_cluster.rb
Normal file
36
lib/fog/aws/requests/redshift/reboot_cluster.rb
Normal file
|
@ -0,0 +1,36 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class Redshift
|
||||
class Real
|
||||
require 'fog/aws/parsers/redshift/cluster'
|
||||
|
||||
# ==== Parameters
|
||||
#
|
||||
# @param [Hash] options
|
||||
# * :cluster_identifier - required - (String)
|
||||
# A unique identifier for the cluster. You use this identifier to refer to the cluster
|
||||
# for any subsequent cluster operations such as deleting or modifying. Must be unique
|
||||
# for all clusters within an AWS account. Example: myexamplecluster
|
||||
#
|
||||
# ==== See Also
|
||||
# http://docs.aws.amazon.com/redshift/latest/APIReference/API_DeleteCluster.html
|
||||
def reboot_cluster(options = {})
|
||||
cluster_identifier = options[:cluster_identifier]
|
||||
|
||||
path = "/"
|
||||
params = {
|
||||
:headers => {},
|
||||
:path => path,
|
||||
:method => :put,
|
||||
:query => {},
|
||||
:parser => Fog::Parsers::Redshift::AWS::Cluster.new
|
||||
}
|
||||
|
||||
params[:query]['Action'] = 'RebootCluster'
|
||||
params[:query]['ClusterIdentifier'] = cluster_identifier if cluster_identifier
|
||||
request(params)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,64 +1,82 @@
|
|||
Shindo.tests('Fog::Redshift[:aws] | cluster requests', ['aws']) do
|
||||
|
||||
@describe_clusters_format = {
|
||||
"ClusterSet" => [{
|
||||
"EndPoint" => {
|
||||
"Port" => Integer,
|
||||
"Address" => String,
|
||||
"AutomatedSnapshotRetentionPeriod" => Integer,
|
||||
"ClusterCreateTime" => Time
|
||||
},
|
||||
"ClusterSecurityGroups" => [{
|
||||
"Status" => String,
|
||||
"ClusterSecurityGroupName" => String
|
||||
}],
|
||||
"VpcSecurityGroups" => Fog::Nullable::Array,
|
||||
"ClusterParameterGroups" => [{
|
||||
"ParameterApplyStatus" => String,
|
||||
"ParameterGroupName" => String
|
||||
}],
|
||||
"PendingModifiedValues" => Fog::Nullable::Hash,
|
||||
"RestoreStatus" => Fog::Nullable::Hash,
|
||||
"ClusterVersion" => String,
|
||||
"ClusterStatus" => String,
|
||||
"Encrypted" => Fog::Boolean,
|
||||
"NumberOfNodes" => Integer,
|
||||
"PubliclyAccessible" => Fog::Boolean,
|
||||
"DBName" => String,
|
||||
"PreferredMaintenanceWindow" => String,
|
||||
"AvailabilityZone" => String,
|
||||
"NodeType" => String,
|
||||
"ClusterIdentifier" => String,
|
||||
"AllowVersionUpgrade" => Fog::Boolean,
|
||||
"MasterUsername" => String
|
||||
}]
|
||||
identifier = "test-cluster-#{rand(65536).to_s(16)}"
|
||||
|
||||
@cluster_format = {
|
||||
"ClusterParameterGroups" => [{
|
||||
"ParameterApplyStatus" => String,
|
||||
"ParameterGroupName" => String
|
||||
}],
|
||||
"ClusterSecurityGroups" => [{
|
||||
"Status" => String,
|
||||
"ClusterSecurityGroupName" => String
|
||||
}],
|
||||
"VpcSecurityGroups" => Fog::Nullable::Array,
|
||||
"EndPoint" => Fog::Nullable::Hash,
|
||||
"PendingModifiedValues" => Fog::Nullable::Hash, #{"MasterUserPassword" => String},
|
||||
"RestoreStatus" => Fog::Nullable::Hash,
|
||||
"ClusterVersion" => String,
|
||||
"ClusterStatus" => String,
|
||||
"Encrypted" => Fog::Boolean,
|
||||
"NumberOfNodes" => Integer,
|
||||
"PubliclyAccessible" => Fog::Boolean,
|
||||
"AutomatedSnapshotRetentionPeriod" => Integer,
|
||||
"DBName" => String,
|
||||
"PreferredMaintenanceWindow" => String,
|
||||
"NodeType" => String,
|
||||
"ClusterIdentifier" => String,
|
||||
"AllowVersionUpgrade" => Fog::Boolean,
|
||||
"MasterUsername" => String
|
||||
}
|
||||
|
||||
|
||||
@describe_clusters_format = {
|
||||
"ClusterSet" => [
|
||||
@cluster_format.merge({"ClusterCreateTime"=>Time, "AvailabilityZone"=>String, "EndPoint"=>{"Port"=>Integer, "Address"=>String}})
|
||||
]
|
||||
}
|
||||
|
||||
tests('success') do
|
||||
tests("#describe_clusters").formats(@describe_clusters_format) do
|
||||
body = Fog::AWS[:redshift].describe_clusters.body
|
||||
tests("create_cluster").formats(@cluster_format) do
|
||||
body = Fog::AWS[:redshift].create_cluster(:cluster_identifier => identifier,
|
||||
:master_user_password => 'Password1234',
|
||||
:master_username => 'testuser',
|
||||
:node_type => 'dw.hs1.xlarge',
|
||||
:cluster_type => 'single-node').body
|
||||
Fog.wait_for do
|
||||
"available" == Fog::AWS[:redshift].describe_clusters(:cluster_identifier=>identifier).body['ClusterSet'].first['ClusterStatus']
|
||||
end
|
||||
body
|
||||
end
|
||||
|
||||
|
||||
tests("#describe_clusters").formats(@describe_clusters_format["ClusterSet"]) do
|
||||
body = Fog::AWS[:redshift].describe_clusters(:cluster_identifier=>identifier).body["ClusterSet"]
|
||||
body
|
||||
end
|
||||
|
||||
|
||||
tests("#reboot_cluster") do
|
||||
sleep 30
|
||||
body = Fog::AWS[:redshift].reboot_cluster(:cluster_identifier=>identifier).body
|
||||
tests("verify reboot").returns("rebooting") { body['ClusterStatus']}
|
||||
Fog.wait_for do
|
||||
"available" == Fog::AWS[:redshift].describe_clusters(:cluster_identifier=>identifier).body['ClusterSet'].first['ClusterStatus']
|
||||
end
|
||||
body
|
||||
end
|
||||
|
||||
|
||||
tests("#delete_cluster") do
|
||||
sleep 30
|
||||
body = Fog::AWS[:redshift].delete_cluster(:cluster_identifier=>identifier, :skip_final_cluster_snapshot=>true).body
|
||||
tests("verify delete").returns("deleting") { body['ClusterStatus']}
|
||||
body
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
# tests('failure') do
|
||||
|
||||
# tests("#get_console_output('i-00000000')").raises(Fog::Compute::AWS::NotFound) do
|
||||
# Fog::Compute[:aws].get_console_output('i-00000000')
|
||||
# end
|
||||
|
||||
# tests("#get_password_data('i-00000000')").raises(Fog::Compute::AWS::NotFound) do
|
||||
# Fog::Compute[:aws].get_password_data('i-00000000')
|
||||
# end
|
||||
|
||||
# tests("#reboot_instances('i-00000000')").raises(Fog::Compute::AWS::NotFound) do
|
||||
# Fog::Compute[:aws].reboot_instances('i-00000000')
|
||||
# end
|
||||
|
||||
# tests("#terminate_instances('i-00000000')").raises(Fog::Compute::AWS::NotFound) do
|
||||
# Fog::Compute[:aws].terminate_instances('i-00000000')
|
||||
# end
|
||||
|
||||
# end
|
||||
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue