2015-01-02 12:34:40 -05:00
|
|
|
Shindo.tests("AWS::RDS | server", ['aws', 'rds']) do
|
2014-12-30 17:25:09 -05:00
|
|
|
model_tests(Fog::AWS[:rds].servers, rds_default_server_params) do
|
|
|
|
# We'll need this later; create it early to avoid waiting
|
|
|
|
@instance_with_final_snapshot = Fog::AWS[:rds].servers.create(rds_default_server_params.merge(:id => uniq_id("fog-snapshot-test"), :backup_retention_period => 1))
|
2015-07-10 11:56:16 -04:00
|
|
|
@instance_with_encrypted_storage = Fog::AWS[:rds].servers.create(rds_default_server_params.merge(:storage_encrypted => true))
|
2014-12-30 17:25:09 -05:00
|
|
|
|
|
|
|
@instance.wait_for(20*60) { ready? }
|
2015-07-10 11:56:16 -04:00
|
|
|
@instance_with_encrypted_storage.wait_for(20*60) { ready? }
|
2015-07-10 21:25:26 -04:00
|
|
|
@final_snapshot_id = uniq_id('fog-test-snapshot')
|
2015-07-10 11:56:16 -04:00
|
|
|
|
|
|
|
tests("#storage_encrypted") do
|
|
|
|
returns(true) { @instance_with_encrypted_storage.storage_encrypted }
|
|
|
|
end
|
2014-12-30 17:25:09 -05:00
|
|
|
|
|
|
|
test('#read_replica_identifiers is []') do
|
|
|
|
returns([]) { @instance.read_replica_identifiers }
|
|
|
|
end
|
|
|
|
|
|
|
|
tests('#snapshots') do
|
|
|
|
snapshot = nil
|
|
|
|
|
|
|
|
tests('#create').succeeds do
|
2015-05-07 18:20:10 -04:00
|
|
|
snapshot = @instance.snapshots.create(:id => uniq_id('fog-snapshot-test'))
|
2014-12-30 17:25:09 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
snapshot.wait_for { ready?}
|
|
|
|
|
|
|
|
@instance.wait_for { ready? }
|
|
|
|
|
2015-05-07 18:20:10 -04:00
|
|
|
returns(true) { @instance.snapshots.map{ |s| s.id }.include?(snapshot.id) }
|
2014-12-30 17:25:09 -05:00
|
|
|
snapshot.destroy
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("#modify").succeeds do
|
|
|
|
pending if Fog.mocking?
|
|
|
|
|
2015-05-08 17:12:12 -04:00
|
|
|
engine = rds_default_server_params.fetch(:engine)
|
2015-05-07 18:20:10 -04:00
|
|
|
version = rds_default_server_params.fetch(:version).match(/\d+\.\d+/).to_s
|
|
|
|
|
2014-12-30 17:25:09 -05:00
|
|
|
orig_parameter_group = @instance.db_parameter_groups.first['DBParameterGroupName']
|
2015-05-08 17:12:12 -04:00
|
|
|
parameter_group = Fog::AWS[:rds].parameter_groups.create(:id => uniq_id, :family => "#{engine}#{version}", :description => 'fog-test')
|
2014-12-30 17:25:09 -05:00
|
|
|
|
|
|
|
orig_security_groups = @instance.db_security_groups.map{|h| h['DBSecurityGroupName']}
|
|
|
|
security_group = Fog::AWS[:rds].security_groups.create(:id => uniq_id, :description => 'fog-test')
|
|
|
|
|
|
|
|
modify_options = {
|
|
|
|
'DBParameterGroupName' => parameter_group.id,
|
|
|
|
'DBSecurityGroups' => orig_security_groups + [security_group.id]
|
|
|
|
}
|
|
|
|
|
|
|
|
@instance.modify(true, modify_options)
|
|
|
|
@instance.wait_for { ready? }
|
|
|
|
|
|
|
|
returns(parameter_group.id, 'new parameter group') do
|
|
|
|
@instance.db_parameter_groups.first['DBParameterGroupName']
|
|
|
|
end
|
|
|
|
|
|
|
|
returns(true, "new security group") do
|
|
|
|
@instance.db_security_groups.any?{|hash| hash['DBSecurityGroupName'] == security_group.id}
|
|
|
|
end
|
|
|
|
|
|
|
|
@instance.reboot
|
|
|
|
@instance.wait_for { state == 'rebooting' }
|
|
|
|
@instance.wait_for { ready? }
|
|
|
|
|
|
|
|
# Restore back to original state using symbols
|
|
|
|
restore_options = {
|
|
|
|
:parameter_group_name => orig_parameter_group,
|
|
|
|
:security_group_names => orig_security_groups
|
|
|
|
}
|
|
|
|
@instance.modify(true, restore_options)
|
|
|
|
|
|
|
|
@instance.reboot
|
|
|
|
@instance.wait_for { state == 'rebooting' }
|
|
|
|
@instance.wait_for do
|
|
|
|
ready? &&
|
|
|
|
db_security_groups.all? {|hash| hash['Status'] == 'active'} &&
|
|
|
|
db_parameter_groups.all? {|hash| hash['ParameterApplyStatus'] == 'in-sync' }
|
|
|
|
end
|
|
|
|
|
|
|
|
parameter_group.destroy
|
|
|
|
security_group.destroy
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("#reboot").succeeds do
|
|
|
|
@instance.reboot
|
|
|
|
end
|
|
|
|
@instance.wait_for { state == 'rebooting' }
|
|
|
|
@instance.wait_for { ready? }
|
|
|
|
|
2015-07-28 14:17:21 -04:00
|
|
|
replica = nil
|
2014-12-30 17:25:09 -05:00
|
|
|
|
2015-07-28 14:17:21 -04:00
|
|
|
tests('#create_read_replica').succeeds do
|
2014-12-30 17:25:09 -05:00
|
|
|
replica = @instance_with_final_snapshot.create_read_replica(uniq_id('fog-replica'))
|
|
|
|
@instance_with_final_snapshot.reload
|
|
|
|
returns([replica.id]) { @instance_with_final_snapshot.read_replica_identifiers }
|
|
|
|
returns(@instance_with_final_snapshot.id) { replica.read_replica_source }
|
|
|
|
|
|
|
|
replica.wait_for { ready? }
|
2015-03-19 15:50:35 -04:00
|
|
|
|
|
|
|
# FinalDBSnapshotIdentifier can not be specified when deleting a replica instance
|
|
|
|
raises(Fog::AWS::RDS::Error) { replica.destroy("foobar") }
|
2015-07-28 14:17:21 -04:00
|
|
|
end
|
2015-03-19 15:50:35 -04:00
|
|
|
|
2015-07-28 14:17:21 -04:00
|
|
|
tests('#promote_read_replica').succeeds do
|
2015-07-28 16:52:31 -04:00
|
|
|
replica.promote.wait_for { state != "modifying" }
|
2015-07-28 14:17:21 -04:00
|
|
|
|
|
|
|
replica.read_replica_source == nil
|
2014-12-30 17:25:09 -05:00
|
|
|
end
|
|
|
|
|
2015-07-28 14:17:21 -04:00
|
|
|
tests('#promote_read_replica', 'master').raises(Fog::AWS::RDS::Error) {
|
|
|
|
@instance_with_final_snapshot.promote
|
|
|
|
}
|
|
|
|
|
|
|
|
replica && replica.destroy
|
|
|
|
|
2014-12-30 17:25:09 -05:00
|
|
|
test("Destroying with a final snapshot") do
|
|
|
|
|
|
|
|
@instance_with_final_snapshot.wait_for { ready? }
|
2015-07-10 21:25:26 -04:00
|
|
|
@instance_with_final_snapshot.destroy(@final_snapshot_id)
|
2014-12-30 17:25:09 -05:00
|
|
|
returns(true, "Final snapshot created") do
|
2015-07-10 21:25:26 -04:00
|
|
|
@final_snapshot = Fog::AWS[:rds].snapshots.get(@final_snapshot_id)
|
2014-12-30 17:25:09 -05:00
|
|
|
!@final_snapshot.nil?
|
|
|
|
end
|
|
|
|
|
|
|
|
@final_snapshot.wait_for { ready? }
|
|
|
|
@final_snapshot.destroy
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|