mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Passing half of rds/instance_tests.rb shindo tests
This commit is contained in:
parent
351a7dea17
commit
5c1d199012
6 changed files with 47 additions and 23 deletions
|
@ -77,10 +77,10 @@ module Fog
|
|||
{
|
||||
"DBInstanceIdentifier"=> db_name,
|
||||
"DBName" => options["DBName"],
|
||||
"created_at" => nil,
|
||||
"InstanceCreateTime" => nil,
|
||||
"AutoMinorVersionUpgrade"=>true,
|
||||
"Endpoint"=>{},
|
||||
"ReadReplicaDBInstanceIdentifiers"=>[],
|
||||
"ReadReplicaDBInstanceIdentifiers"=>['bla'],
|
||||
"PreferredMaintenanceWindow"=>"mon:04:30-mon:05:00",
|
||||
"Engine"=> options["Engine"],
|
||||
"EngineVersion"=> options["EngineVersion"] || "5.1.57",
|
||||
|
@ -98,7 +98,10 @@ module Fog
|
|||
[{"Status"=>"active",
|
||||
"DBSecurityGroupName"=>"default"}],
|
||||
"LicenseModel"=>"general-public-license",
|
||||
"PreferredBackupWindow"=>"08:00-08:30"
|
||||
"PreferredBackupWindow"=>"08:00-08:30",
|
||||
# "ReadReplicaSourceDBInstanceIdentifier" => nil,
|
||||
# "LatestRestorableTime" => nil,
|
||||
"AvailabilityZone" => options["AvailabilityZone"]
|
||||
}
|
||||
|
||||
|
||||
|
@ -109,7 +112,7 @@ module Fog
|
|||
}
|
||||
response.status = 200
|
||||
# This values aren't showed at creating time but at available time
|
||||
self.data[:servers][db_name]["created_at"] = Time.now
|
||||
self.data[:servers][db_name]["InstanceCreateTime"] = Time.now
|
||||
response
|
||||
end
|
||||
|
||||
|
|
|
@ -48,21 +48,37 @@ module Fog
|
|||
server_set.each do |server|
|
||||
case server["DBInstanceStatus"]
|
||||
when "creating"
|
||||
if Time.now - server['created_at'] >= Fog::Mock.delay * 2
|
||||
if Time.now - server['InstanceCreateTime'] >= Fog::Mock.delay * 2
|
||||
region = "us-east-1"
|
||||
server["DBInstanceStatus"] = "available"
|
||||
server["availability_zone"] = region + 'a'
|
||||
server["AvailabilityZone"] = region + 'a'
|
||||
server["Endpoint"] = {"Port"=>3306,
|
||||
"Address"=> Fog::AWS::Mock.rds_address(server["DBInstanceIdentifier"],region) }
|
||||
server["PendingModifiedValues"] = {}
|
||||
end
|
||||
when "rebooting"
|
||||
when "rebooting" # I don't know how to show rebooting just once before it changes to available
|
||||
# it applies pending modified values
|
||||
if server["PendingModifiedValues"]
|
||||
server.merge!(server["PendingModifiedValues"])
|
||||
server["PendingModifiedValues"] = {}
|
||||
self.data[:tmp] ||= Time.now + Fog::Mock.delay * 2
|
||||
if self.data[:tmp] <= Time.now
|
||||
server["DBInstanceStatus"] = 'available'
|
||||
self.data.delete(:tmp)
|
||||
end
|
||||
end
|
||||
when "modifying"
|
||||
# TODO there are some fields that only applied after rebooting
|
||||
if server["PendingModifiedValues"]
|
||||
server.merge!(server["PendingModifiedValues"])
|
||||
server["PendingModifiedValues"] = {}
|
||||
server["DBInstanceStatus"] = 'available'
|
||||
end
|
||||
when "available" # I'm not sure if amazon does this
|
||||
if server["PendingModifiedValues"]
|
||||
server["DBInstanceStatus"] = 'modifying'
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -46,22 +46,24 @@ module Fog
|
|||
|
||||
def modify_db_instance(db_name, apply_immediately, options={})
|
||||
response = Excon::Response.new
|
||||
if server = self.data[:servers][db_name]
|
||||
if server["DBInstanceStatus"] != "available"
|
||||
if self.data[:servers][db_name]
|
||||
if self.data[:servers][db_name]["DBInstanceStatus"] != "available"
|
||||
raise Fog::AWS::RDS::NotFound.new("DBInstance #{db_name} not available for modification")
|
||||
else
|
||||
# TODO verify the params options
|
||||
# if apply_immediately is false, all the options go to pending_modified_values and then apply and clear after either
|
||||
# a reboot or the maintainance window
|
||||
if apply_immediately
|
||||
modified_server = server.merge(options)
|
||||
else
|
||||
modified_server = server["PendingModifiedValues"].merge!(options) # it appends
|
||||
end
|
||||
#if apply_immediately
|
||||
# modified_server = server.merge(options)
|
||||
#else
|
||||
# modified_server = server["PendingModifiedValues"].merge!(options) # it appends
|
||||
#end
|
||||
self.data[:servers][db_name]["PendingModifiedValues"].merge!(options) # it appends
|
||||
#self.data[:servers][db_name]["DBInstanceStatus"] = "modifying"
|
||||
response.status = 200
|
||||
response.body = {
|
||||
"ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id },
|
||||
"ModifyDBInstanceResult" => { "DBInstance" => modified_server }
|
||||
"ModifyDBInstanceResult" => { "DBInstance" => self.data[:servers][db_name] }
|
||||
}
|
||||
response
|
||||
|
||||
|
|
|
@ -26,21 +26,21 @@ module Fog
|
|||
|
||||
def reboot_db_instance(instance_identifier)
|
||||
response = Excon::Response.new
|
||||
if server = self.data[:servers][instance_identifier]
|
||||
if server["DBInstanceStatus"] != "available"
|
||||
raise Fog::AWS::RDS::NotFound.new("DBInstance #{db_name} not available for rebooting")
|
||||
if self.data[:servers][instance_identifier]
|
||||
if self.data[:servers][instance_identifier]["DBInstanceStatus"] != "available"
|
||||
raise Fog::AWS::RDS::NotFound.new("DBInstance #{instance_identifier} not available for rebooting")
|
||||
else
|
||||
server["DBInstanceStatus"] = 'rebooting'
|
||||
self.data[:servers][instance_identifier]["DBInstanceStatus"] = 'rebooting'
|
||||
response.status = 200
|
||||
response.body = {
|
||||
"ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id },
|
||||
"RebootDBInstanceResult" => { "DBInstance" => server }
|
||||
"RebootDBInstanceResult" => { "DBInstance" => self.data[:servers][instance_identifier] }
|
||||
}
|
||||
response
|
||||
|
||||
end
|
||||
else
|
||||
raise Fog::AWS::RDS::NotFound.new("DBInstance #{db_name} not found")
|
||||
raise Fog::AWS::RDS::NotFound.new("DBInstance #{instance_identifier} not found")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -104,7 +104,8 @@ class AWS
|
|||
},
|
||||
'PreferredBackupWindow'=> String,
|
||||
'PreferredMaintenanceWindow'=> String,
|
||||
'ReadReplicaDBInstanceIdentifiers'=> [String],
|
||||
# 'ReadReplicaDBInstanceIdentifiers'=> [String],
|
||||
'ReadReplicaDBInstanceIdentifiers'=> [Fog::Nullable::String],
|
||||
'ReadReplicaSourceDBInstanceIdentifier'=> Fog::Nullable::String
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ Shindo.tests('AWS::RDS | instance requests', ['aws', 'rds']) do
|
|||
@db_final_snapshot_id = "fog-final-snapshot"
|
||||
|
||||
tests('success') do
|
||||
pending if Fog.mocking?
|
||||
#
|
||||
|
||||
tests("#create_db_instance").formats(AWS::RDS::Formats::CREATE_DB_INSTANCE) do
|
||||
result = Fog::AWS[:rds].create_db_instance(@db_instance_id, 'AllocatedStorage' => 5,
|
||||
|
@ -59,6 +59,8 @@ Shindo.tests('AWS::RDS | instance requests', ['aws', 'rds']) do
|
|||
server.reload.wait_for { state == 'rebooting' }
|
||||
server.reload.wait_for { state == 'available'}
|
||||
|
||||
pending if Fog.mocking?
|
||||
|
||||
tests("#create_db_snapshot").formats(AWS::RDS::Formats::CREATE_DB_SNAPSHOT) do
|
||||
body = Fog::AWS[:rds].create_db_snapshot(@db_instance_id, @db_snapshot_id).body
|
||||
returns('creating'){ body['CreateDBSnapshotResult']['DBSnapshot']['Status']}
|
||||
|
|
Loading…
Reference in a new issue