2011-02-27 16:09:12 -05:00
|
|
|
Shindo.tests('AWS::RDS | instance requests', ['aws', 'rds']) do
|
2013-02-05 06:19:02 -05:00
|
|
|
# Disabled due to https://github.com/fog/fog/1546
|
|
|
|
pending
|
|
|
|
|
2011-05-07 15:59:42 -04:00
|
|
|
# random_differentiator
|
|
|
|
# Useful when rapidly re-running tests, so we don't have to wait
|
|
|
|
# serveral minutes for deleted servers to disappear
|
|
|
|
suffix = rand(65536).to_s(16)
|
|
|
|
|
|
|
|
@db_instance_id = "fog-test-#{suffix}"
|
|
|
|
@db_replica_id = "fog-replica-#{suffix}"
|
|
|
|
@db_snapshot_id = "fog-snapshot"
|
|
|
|
@db_final_snapshot_id = "fog-final-snapshot"
|
|
|
|
|
2011-02-27 16:09:12 -05:00
|
|
|
tests('success') do
|
2011-05-07 15:59:42 -04:00
|
|
|
|
2011-02-27 16:09:12 -05:00
|
|
|
tests("#create_db_instance").formats(AWS::RDS::Formats::CREATE_DB_INSTANCE) do
|
2011-09-15 09:01:03 -04:00
|
|
|
result = Fog::AWS[:rds].create_db_instance(@db_instance_id, 'AllocatedStorage' => 5,
|
2011-05-07 15:59:42 -04:00
|
|
|
'DBInstanceClass' => 'db.m1.small',
|
|
|
|
'Engine' => 'mysql',
|
|
|
|
'EngineVersion' => '5.1.50',
|
|
|
|
'MasterUsername' => 'foguser',
|
|
|
|
'BackupRetentionPeriod' => 1,
|
|
|
|
'MasterUserPassword' => 'fogpassword').body
|
|
|
|
|
2011-02-27 16:09:12 -05:00
|
|
|
instance = result['CreateDBInstanceResult']['DBInstance']
|
|
|
|
returns('creating'){ instance['DBInstanceStatus']}
|
|
|
|
result
|
|
|
|
end
|
2011-05-07 15:59:42 -04:00
|
|
|
|
2011-02-27 16:09:12 -05:00
|
|
|
tests("#describe_db_instances").formats(AWS::RDS::Formats::DESCRIBE_DB_INSTANCES) do
|
2011-09-15 09:01:03 -04:00
|
|
|
Fog::AWS[:rds].describe_db_instances.body
|
2011-02-27 16:09:12 -05:00
|
|
|
end
|
2011-05-07 15:59:42 -04:00
|
|
|
|
2011-09-15 09:01:03 -04:00
|
|
|
server = Fog::AWS[:rds].servers.get(@db_instance_id)
|
2011-02-27 16:09:12 -05:00
|
|
|
server.wait_for {ready?}
|
2011-05-07 15:59:42 -04:00
|
|
|
|
|
|
|
new_storage = 6
|
2011-02-27 16:09:12 -05:00
|
|
|
tests("#modify_db_instance with immediate apply").formats(AWS::RDS::Formats::MODIFY_DB_INSTANCE) do
|
2011-09-15 09:01:03 -04:00
|
|
|
body = Fog::AWS[:rds].modify_db_instance(@db_instance_id, true, 'AllocatedStorage'=> new_storage).body
|
2011-02-27 16:09:12 -05:00
|
|
|
tests 'pending storage' do
|
|
|
|
instance = body['ModifyDBInstanceResult']['DBInstance']
|
2011-05-07 15:59:42 -04:00
|
|
|
returns(new_storage){instance['PendingModifiedValues']['AllocatedStorage']}
|
2011-02-27 16:09:12 -05:00
|
|
|
end
|
2011-05-07 15:59:42 -04:00
|
|
|
body
|
2011-02-27 16:09:12 -05:00
|
|
|
end
|
2011-05-07 15:59:42 -04:00
|
|
|
|
2013-01-28 15:10:39 -05:00
|
|
|
server.wait_for { state == 'modifying' }
|
|
|
|
server.wait_for { state == 'available' }
|
2011-05-11 15:22:59 -04:00
|
|
|
|
2011-02-27 16:09:12 -05:00
|
|
|
tests 'new storage' do
|
2011-05-07 15:59:42 -04:00
|
|
|
returns(new_storage){ server.allocated_storage}
|
2011-02-27 16:09:12 -05:00
|
|
|
end
|
2011-04-04 19:57:39 -04:00
|
|
|
|
2011-02-27 16:09:12 -05:00
|
|
|
tests("reboot db instance") do
|
|
|
|
tests("#reboot").formats(AWS::RDS::Formats::REBOOT_DB_INSTANCE) do
|
2011-09-15 09:01:03 -04:00
|
|
|
Fog::AWS[:rds].reboot_db_instance(@db_instance_id).body
|
2011-02-27 16:09:12 -05:00
|
|
|
end
|
|
|
|
end
|
2011-05-07 15:59:42 -04:00
|
|
|
|
2013-01-28 15:10:39 -05:00
|
|
|
server.wait_for { state == 'rebooting' }
|
|
|
|
server.wait_for { state == 'available'}
|
2011-05-11 15:22:59 -04:00
|
|
|
|
2011-02-27 16:09:12 -05:00
|
|
|
tests("#create_db_snapshot").formats(AWS::RDS::Formats::CREATE_DB_SNAPSHOT) do
|
2011-09-15 09:01:03 -04:00
|
|
|
body = Fog::AWS[:rds].create_db_snapshot(@db_instance_id, @db_snapshot_id).body
|
2011-02-27 16:09:12 -05:00
|
|
|
returns('creating'){ body['CreateDBSnapshotResult']['DBSnapshot']['Status']}
|
|
|
|
body
|
|
|
|
end
|
2011-05-07 15:59:42 -04:00
|
|
|
|
2011-02-27 16:09:12 -05:00
|
|
|
tests("#describe_db_snapshots").formats(AWS::RDS::Formats::DESCRIBE_DB_SNAPSHOTS) do
|
2011-09-15 09:01:03 -04:00
|
|
|
body = Fog::AWS[:rds].describe_db_snapshots.body
|
2011-02-27 16:09:12 -05:00
|
|
|
end
|
2011-05-07 15:59:42 -04:00
|
|
|
|
2013-01-28 15:10:39 -05:00
|
|
|
server.wait_for { state == 'available' }
|
2011-05-11 15:22:59 -04:00
|
|
|
|
2011-02-27 16:09:12 -05:00
|
|
|
tests( "#create read replica").formats(AWS::RDS::Formats::CREATE_READ_REPLICA) do
|
2011-09-15 09:01:03 -04:00
|
|
|
Fog::AWS[:rds].create_db_instance_read_replica(@db_replica_id, @db_instance_id).body
|
2011-02-27 16:09:12 -05:00
|
|
|
end
|
2011-05-07 15:59:42 -04:00
|
|
|
|
2011-09-15 09:01:03 -04:00
|
|
|
replica = Fog::AWS[:rds].servers.get(@db_replica_id)
|
2011-02-27 16:09:12 -05:00
|
|
|
replica.wait_for {ready?}
|
2011-05-07 15:59:42 -04:00
|
|
|
|
2011-02-27 16:09:12 -05:00
|
|
|
tests("replica source") do
|
|
|
|
returns(@db_instance_id){replica.read_replica_source}
|
|
|
|
end
|
|
|
|
server.reload
|
2011-05-07 15:59:42 -04:00
|
|
|
|
2011-02-27 16:09:12 -05:00
|
|
|
tests("replica identifiers") do
|
|
|
|
returns([@db_replica_id]){server.read_replica_identifiers}
|
|
|
|
end
|
2011-04-04 20:22:15 -04:00
|
|
|
|
2011-02-27 16:09:12 -05:00
|
|
|
tests("#delete_db_instance").formats(AWS::RDS::Formats::DELETE_DB_INSTANCE) do
|
2011-05-07 15:59:42 -04:00
|
|
|
#server.wait_for { state == 'available'}
|
2011-09-15 09:01:03 -04:00
|
|
|
Fog::AWS[:rds].delete_db_instance(@db_replica_id, nil, true)
|
|
|
|
body = Fog::AWS[:rds].delete_db_instance(@db_instance_id, @db_final_snapshot_id).body
|
2011-05-07 15:59:42 -04:00
|
|
|
|
2011-02-27 16:09:12 -05:00
|
|
|
tests "final snapshot" do
|
2011-09-15 09:01:03 -04:00
|
|
|
returns('creating'){Fog::AWS[:rds].describe_db_snapshots(:snapshot_id => @db_final_snapshot_id).body['DescribeDBSnapshotsResult']['DBSnapshots'].first['Status']}
|
2011-02-27 16:09:12 -05:00
|
|
|
end
|
|
|
|
body
|
|
|
|
end
|
2011-05-07 15:59:42 -04:00
|
|
|
|
2011-02-27 16:09:12 -05:00
|
|
|
tests("#delete_db_snapshot").formats(AWS::RDS::Formats::DELETE_DB_SNAPSHOT) do
|
2011-09-15 09:01:03 -04:00
|
|
|
Fog::AWS[:rds].snapshots.get(@db_snapshot_id).wait_for { ready? }
|
|
|
|
Fog::AWS[:rds].delete_db_snapshot(@db_snapshot_id).body
|
2011-05-07 15:59:42 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
tests("snapshot.destroy") do
|
2011-09-15 09:01:03 -04:00
|
|
|
snapshot = Fog::AWS[:rds].snapshots.get(@db_final_snapshot_id)
|
2011-05-07 15:59:42 -04:00
|
|
|
snapshot.wait_for { ready? }
|
|
|
|
snapshot.destroy
|
2011-09-15 09:01:03 -04:00
|
|
|
returns(nil) { Fog::AWS[:rds].snapshots.get(@db_final_snapshot_id) }
|
2011-02-27 16:09:12 -05:00
|
|
|
end
|
2011-05-07 15:59:42 -04:00
|
|
|
|
2011-02-27 16:09:12 -05:00
|
|
|
end
|
2011-05-07 15:59:42 -04:00
|
|
|
|
2011-02-27 16:09:12 -05:00
|
|
|
tests('failure') do
|
|
|
|
tests "deleting nonexisting instance" do
|
2011-09-15 09:01:03 -04:00
|
|
|
raises(Fog::AWS::RDS::NotFound) {Fog::AWS[:rds].delete_db_instance('doesnexist', 'irrelevant')}
|
2011-02-27 16:09:12 -05:00
|
|
|
end
|
|
|
|
tests "deleting non existing snapshot" do
|
2011-09-15 09:01:03 -04:00
|
|
|
raises(Fog::AWS::RDS::NotFound) {Fog::AWS[:rds].delete_db_snapshot('doesntexist')}
|
2011-02-27 16:09:12 -05:00
|
|
|
end
|
|
|
|
tests "modifying non existing instance" do
|
2011-09-15 09:01:03 -04:00
|
|
|
raises(Fog::AWS::RDS::NotFound) { Fog::AWS[:rds].modify_db_instance 'doesntexit', true, 'AllocatedStorage'=> 10}
|
2011-02-27 16:09:12 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|