mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[aws|rds] Mocking support for read replicas.
Tests pass. Still some rough edges (like error handling), but better than nothing.
This commit is contained in:
parent
3fc47d4b66
commit
229934744b
5 changed files with 51 additions and 10 deletions
|
@ -83,7 +83,7 @@ module Fog
|
|||
"ReadReplicaDBInstanceIdentifiers"=>[],
|
||||
"PreferredMaintenanceWindow"=>"mon:04:30-mon:05:00",
|
||||
"Engine"=> options["Engine"],
|
||||
"EngineVersion"=> options["EngineVersion"] || "5.1.57",
|
||||
"EngineVersion"=> options["EngineVersion"] || "5.5.12",
|
||||
"PendingModifiedValues"=>{"MasterUserPassword"=>"****"}, # This clears when is available
|
||||
"MultiAZ"=>false,
|
||||
"MasterUsername"=> options["MasterUsername"],
|
||||
|
@ -92,7 +92,7 @@ module Fog
|
|||
"BackupRetentionPeriod"=> options["BackupRetentionPeriod"] || 1,
|
||||
"AllocatedStorage"=> options["AllocatedStorage"],
|
||||
"DBParameterGroups"=> # I think groups should be in the self.data method
|
||||
[{"DBParameterGroupName"=>"default.mysql5.1",
|
||||
[{"DBParameterGroupName"=>"default.mysql5.5",
|
||||
"ParameterApplyStatus"=>"in-sync"}],
|
||||
"DBSecurityGroups"=>
|
||||
[{"Status"=>"active",
|
||||
|
|
|
@ -33,7 +33,47 @@ module Fog
|
|||
class Mock
|
||||
|
||||
def create_db_instance_read_replica(instance_identifier, source_identifier, options={})
|
||||
Fog::Mock.not_implemented
|
||||
# TODO: throw error when instance_identifier already exists,
|
||||
# or source_identifier doesn't exist
|
||||
|
||||
source = self.data[:servers][source_identifier]
|
||||
data = {
|
||||
'AllocatedStorage' => source['AllocatedStorage'],
|
||||
'AutoMinorVersionUpgrade' => options.key?('AutoMinorVersionUpgrade') ? options['AutoMinorVersionUpgrade'] : true,
|
||||
'AvailabilityZone' => options['AvailabilityZone'],
|
||||
'DBInstanceClass' => options['DBInstanceClass'] || 'db.m1.small',
|
||||
'DBInstanceIdentifier' => instance_identifier,
|
||||
'DBInstanceStatus' => 'creating',
|
||||
'DBName' => source['DBName'],
|
||||
'DBParameterGroups' => source['DBParameterGroups'],
|
||||
'DBSecurityGroups' => source['DBSecurityGroups'],
|
||||
'Endpoint' => {},
|
||||
'Engine' => source['Engine'],
|
||||
'EngineVersion' => options['EngineVersion'] || '5.5.12',
|
||||
'InstanceCreateTime' => nil,
|
||||
'LatestRestorableTime' => nil,
|
||||
'LicenseModel' => 'general-public-license',
|
||||
'MasterUsername' => source['MasterUsername'],
|
||||
'MultiAZ' => false,
|
||||
'PendingModifiedValues' => {},
|
||||
'PreferredBackupWindow'=> '08:00-08:30',
|
||||
'PreferredMaintenanceWindow'=> "mon:04:30-mon:05:00",
|
||||
'ReadReplicaDBInstanceIdentifiers'=> [],
|
||||
'ReadReplicaSourceDBInstanceIdentifier'=> source_identifier
|
||||
}
|
||||
self.data[:servers][instance_identifier] = data
|
||||
self.data[:servers][source_identifier]['ReadReplicaDBInstanceIdentifiers'] << instance_identifier
|
||||
|
||||
response = Excon::Response.new
|
||||
response.body = {
|
||||
"ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id },
|
||||
"CreateDBInstanceReadReplicaResult"=> {"DBInstance"=> data}
|
||||
}
|
||||
response.status = 200
|
||||
# This values aren't showed at creating time but at available time
|
||||
self.data[:servers][instance_identifier]["InstanceCreateTime"] = Time.now
|
||||
|
||||
response
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -81,7 +81,6 @@ Shindo.tests("AWS::RDS | server", ['aws', 'rds']) do
|
|||
@instance.reload.wait_for { ready? }
|
||||
|
||||
tests('#create_read_replica').succeeds do
|
||||
pending if Fog.mocking?
|
||||
|
||||
replica = @instance_with_final_snapshot.create_read_replica(uniq_id('fog-replica'))
|
||||
@instance_with_final_snapshot.reload
|
||||
|
|
|
@ -137,11 +137,15 @@ class AWS
|
|||
},
|
||||
'PreferredBackupWindow'=> String,
|
||||
'PreferredMaintenanceWindow'=> String,
|
||||
'ReadReplicaDBInstanceIdentifiers'=> [String],
|
||||
'ReadReplicaDBInstanceIdentifiers'=> [Fog::Nullable::String],
|
||||
'ReadReplicaSourceDBInstanceIdentifier'=> Fog::Nullable::String
|
||||
'ReadReplicaDBInstanceIdentifiers'=> [Fog::Nullable::String]
|
||||
}
|
||||
|
||||
REPLICA_INSTANCE = INSTANCE.merge({
|
||||
'BackupRetentionPeriod' => Fog::Nullable::String,
|
||||
'PreferredBackupWindow' => Fog::Nullable::String,
|
||||
'ReadReplicaSourceDBInstanceIdentifier'=> String
|
||||
})
|
||||
|
||||
CREATE_DB_INSTANCE = BASIC.merge({
|
||||
'CreateDBInstanceResult' => {
|
||||
'DBInstance' => INSTANCE
|
||||
|
@ -175,7 +179,7 @@ class AWS
|
|||
|
||||
CREATE_READ_REPLICA = BASIC.merge({
|
||||
'CreateDBInstanceReadReplicaResult' => {
|
||||
'DBInstance' => INSTANCE
|
||||
'DBInstance' => REPLICA_INSTANCE
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
@ -70,8 +70,6 @@ Shindo.tests('AWS::RDS | instance requests', ['aws', 'rds']) do
|
|||
|
||||
server.reload.wait_for { state == 'available' }
|
||||
|
||||
pending if Fog.mocking?
|
||||
|
||||
tests( "#create read replica").formats(AWS::RDS::Formats::CREATE_READ_REPLICA) do
|
||||
Fog::AWS[:rds].create_db_instance_read_replica(@db_replica_id, @db_instance_id).body
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue