mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Starting adding tests, some cleanup
This commit is contained in:
parent
524798f067
commit
f83629550b
3 changed files with 116 additions and 21 deletions
51
lib/fog/aws/parsers/redshift/cluster_subnet_group_parser.rb
Normal file
51
lib/fog/aws/parsers/redshift/cluster_subnet_group_parser.rb
Normal file
|
@ -0,0 +1,51 @@
|
|||
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
|
|
@ -78,7 +78,7 @@ module Fog
|
|||
|
||||
def initialize(options={})
|
||||
|
||||
@use_redshift_profile = options[:use_redshift_profile]
|
||||
@use_iam_profile = options[:use_iam_profile]
|
||||
@region = options[:region] || 'us-east-1'
|
||||
setup_credentials(options)
|
||||
|
||||
|
@ -96,15 +96,9 @@ module Fog
|
|||
|
||||
private
|
||||
def setup_credentials(options)
|
||||
<<<<<<< HEAD
|
||||
@aws_access_key_id = options[:aws_access_key_id]
|
||||
@aws_secret_access_key = options[:aws_secret_access_key]
|
||||
@aws_session_token = options[:aws_session_token]
|
||||
=======
|
||||
@aws_access_key_id = options[:aws_access_key_id]
|
||||
@aws_secret_access_key = options[:aws_secret_access_key]
|
||||
@aws_session_token = options[:aws_session_token]
|
||||
>>>>>>> 6c5358b... Initial redshift setup, describe_clusters support
|
||||
@aws_credentials_expire_at = options[:aws_credentials_expire_at]
|
||||
|
||||
@signer = Fog::AWS::SignatureV4.new( @aws_access_key_id, @aws_secret_access_key,@region,'redshift')
|
||||
|
@ -115,11 +109,6 @@ module Fog
|
|||
|
||||
parser = params.delete(:parser)
|
||||
date = Fog::Time.now
|
||||
<<<<<<< HEAD
|
||||
|
||||
=======
|
||||
|
||||
>>>>>>> 6c5358b... Initial redshift setup, describe_clusters support
|
||||
params[:headers]['Date'] = date.to_date_header
|
||||
params[:headers]['x-amz-date'] = date.to_iso8601_basic
|
||||
|
||||
|
@ -128,16 +117,7 @@ module Fog
|
|||
params[:headers]['x-amz-security-token'] = @aws_session_token if @aws_session_token
|
||||
params[:headers]['Authorization'] = @signer.sign params, date
|
||||
|
||||
<<<<<<< HEAD
|
||||
begin
|
||||
response = @connection.request(params.merge(:parser => parser), &block)
|
||||
rescue Excon::Errors::HTTPStatusError => error
|
||||
match = Fog::AWS::Errors.match_error(error)
|
||||
end
|
||||
|
||||
=======
|
||||
response = @connection.request(params.merge(:parser => parser), &block)
|
||||
>>>>>>> 6c5358b... Initial redshift setup, describe_clusters support
|
||||
if response.headers['Content-Type'] == 'application/json' && response.body.size > 0 #body will be empty if the streaming form has been used
|
||||
response.body = Fog::JSON.decode(response.body)
|
||||
end
|
||||
|
|
64
tests/aws/requests/redshift/cluster_tests.rb
Normal file
64
tests/aws/requests/redshift/cluster_tests.rb
Normal file
|
@ -0,0 +1,64 @@
|
|||
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
|
||||
}]
|
||||
}
|
||||
|
||||
tests('success') do
|
||||
tests("#describe_clusters").formats(@describe_clusters_format) do
|
||||
body = Fog::AWS[:redshift].describe_clusters.body
|
||||
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…
Reference in a new issue