mirror of
				https://github.com/fog/fog-aws.git
				synced 2022-11-09 13:50:52 -05:00 
			
		
		
		
	initial import
* take the liberty of correcting Aws naming
This commit is contained in:
		
							parent
							
								
									095fa8763f
								
							
						
					
					
						commit
						d48d376e9c
					
				
					 1261 changed files with 72105 additions and 5 deletions
				
			
		
							
								
								
									
										9
									
								
								tests/models/rds/event_subscription_tests.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								tests/models/rds/event_subscription_tests.rb
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,9 @@
 | 
			
		|||
Shindo.tests("Aws::RDS | event_subscription", ['aws', 'rds']) do
 | 
			
		||||
  pending unless Fog.mocking?
 | 
			
		||||
 | 
			
		||||
  name = 'fog'
 | 
			
		||||
  params = {:id => name, :sns_topic_arn => 'arn:aws:sns:us-east-1:12345678910:fog'}
 | 
			
		||||
 | 
			
		||||
  model_tests(Fog::AWS[:rds].event_subscriptions, params) do
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
							
								
								
									
										6
									
								
								tests/models/rds/event_subscriptions_tests.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								tests/models/rds/event_subscriptions_tests.rb
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,6 @@
 | 
			
		|||
Shindo.tests("Aws::RDS | event subscriptions", ['aws', 'rds']) do
 | 
			
		||||
  pending unless Fog.mocking?
 | 
			
		||||
  params = {:id => "fog", :sns_topic_arn => 'arn:aws:sns:us-east-1:12345678910:fog'}
 | 
			
		||||
 | 
			
		||||
  collection_tests(Fog::AWS[:rds].event_subscriptions, params)
 | 
			
		||||
end
 | 
			
		||||
							
								
								
									
										5
									
								
								tests/models/rds/helper.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								tests/models/rds/helper.rb
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,5 @@
 | 
			
		|||
def rds_default_server_params
 | 
			
		||||
  { :id => uniq_id, :allocated_storage => 5, :engine => 'mysql',
 | 
			
		||||
    :master_username => 'foguser', :password => 'fogpassword',
 | 
			
		||||
    :backup_retention_period => 0 }
 | 
			
		||||
end
 | 
			
		||||
							
								
								
									
										14
									
								
								tests/models/rds/instance_option_tests.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								tests/models/rds/instance_option_tests.rb
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,14 @@
 | 
			
		|||
Shindo.tests("Aws::RDS | db instance options", ['aws', 'rds']) do
 | 
			
		||||
 | 
			
		||||
  params = {:engine => 'mysql'}
 | 
			
		||||
 | 
			
		||||
  pending if Fog.mocking?
 | 
			
		||||
 | 
			
		||||
  tests('#options') do
 | 
			
		||||
    tests 'contains options' do
 | 
			
		||||
      @instance = Fog::AWS[:rds].instance_options.new(params)
 | 
			
		||||
      returns(true) { @instance.engine == 'mysql' }
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
end
 | 
			
		||||
							
								
								
									
										24
									
								
								tests/models/rds/parameter_group_tests.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								tests/models/rds/parameter_group_tests.rb
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,24 @@
 | 
			
		|||
Shindo.tests("Aws::RDS | parameter_group", ['aws', 'rds']) do
 | 
			
		||||
 | 
			
		||||
  group_name = 'fog-test'
 | 
			
		||||
  params = {:id => group_name, :family => 'mysql5.1', :description => group_name}
 | 
			
		||||
 | 
			
		||||
  pending if Fog.mocking?
 | 
			
		||||
  model_tests(Fog::AWS[:rds].parameter_groups, params, false) do
 | 
			
		||||
    tests('#parameters') do
 | 
			
		||||
      #search for a sample parameter
 | 
			
		||||
      tests 'contains parameters' do
 | 
			
		||||
        returns(true){ @instance.parameters.any? {|p| p.name == 'query_cache_size'}}
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    tests('#modify') do
 | 
			
		||||
      @instance.modify([{:name => 'query_cache_size', :value => '6553600', :apply_method => 'immediate'}])
 | 
			
		||||
 | 
			
		||||
      tests 'parameter has changed' do
 | 
			
		||||
        returns('6553600'){@instance.parameters.find {|p| p.name == 'query_cache_size'}.value}
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
							
								
								
									
										8
									
								
								tests/models/rds/parameter_groups_tests.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								tests/models/rds/parameter_groups_tests.rb
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,8 @@
 | 
			
		|||
Shindo.tests("Aws::RDS | parameter_groups", ['aws', 'rds']) do
 | 
			
		||||
 | 
			
		||||
  group_name = 'fog-test'
 | 
			
		||||
  params = {:id => group_name, :family => 'mysql5.1', :description => group_name}
 | 
			
		||||
 | 
			
		||||
  pending if Fog.mocking?
 | 
			
		||||
  collection_tests(Fog::AWS[:rds].parameter_groups, params, false)
 | 
			
		||||
end
 | 
			
		||||
							
								
								
									
										53
									
								
								tests/models/rds/security_group_tests.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								tests/models/rds/security_group_tests.rb
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,53 @@
 | 
			
		|||
Shindo.tests("Aws::RDS | security_group", ['aws', 'rds']) do
 | 
			
		||||
  group_name = 'fog-test'
 | 
			
		||||
  params = {:id => group_name, :description => 'fog test'}
 | 
			
		||||
 | 
			
		||||
  model_tests(Fog::AWS[:rds].security_groups, params) do
 | 
			
		||||
 | 
			
		||||
    tests("#description").returns('fog test') { @instance.description }
 | 
			
		||||
 | 
			
		||||
    tests("#authorize_ec2_security_group").succeeds do
 | 
			
		||||
      @ec2_sec_group = Fog::Compute[:aws].security_groups.create(:name => 'fog-test', :description => 'fog test')
 | 
			
		||||
 | 
			
		||||
      @instance.authorize_ec2_security_group(@ec2_sec_group.name)
 | 
			
		||||
      returns('authorizing') do
 | 
			
		||||
        @instance.ec2_security_groups.find{|h| h['EC2SecurityGroupName'] == @ec2_sec_group.name}['Status']
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    @instance.wait_for { ready? }
 | 
			
		||||
 | 
			
		||||
    tests("#revoke_ec2_security_group").succeeds do
 | 
			
		||||
      pending if Fog.mocking?
 | 
			
		||||
 | 
			
		||||
      @instance.revoke_ec2_security_group(@ec2_sec_group.name)
 | 
			
		||||
 | 
			
		||||
      returns('revoking') do
 | 
			
		||||
        @instance.ec2_security_groups.find{|h| h['EC2SecurityGroupName'] == @ec2_sec_group.name}['Status']
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      @instance.wait_for { ready? }
 | 
			
		||||
 | 
			
		||||
      returns(false) { @instance.ec2_security_groups.any?{|h| h['EC2SecurityGroupName'] == @ec2_sec_group.name} }
 | 
			
		||||
      @ec2_sec_group.destroy
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    tests("#authorize_cidrip").succeeds do
 | 
			
		||||
      @cidr = '127.0.0.1/32'
 | 
			
		||||
      @instance.authorize_cidrip(@cidr)
 | 
			
		||||
      returns('authorizing') { @instance.ip_ranges.find{|h| h['CIDRIP'] == @cidr}['Status'] }
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    tests("#revoke_cidrip").succeeds do
 | 
			
		||||
      pending if Fog.mocking?
 | 
			
		||||
 | 
			
		||||
      @instance.wait_for { ready? }
 | 
			
		||||
      @instance.revoke_cidrip(@cidr)
 | 
			
		||||
      returns('revoking') { @instance.ip_ranges.find{|h| h['CIDRIP'] == @cidr}['Status'] }
 | 
			
		||||
      @instance.wait_for { ready? }
 | 
			
		||||
      returns(false) { @instance.ip_ranges.any?{|h| h['CIDRIP'] == @cidr} }
 | 
			
		||||
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
							
								
								
									
										5
									
								
								tests/models/rds/security_groups_tests.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								tests/models/rds/security_groups_tests.rb
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,5 @@
 | 
			
		|||
Shindo.tests("Aws::RDS | security groups", ['aws', 'rds']) do
 | 
			
		||||
  params = {:id => 'fog-test', :description => 'fog test'}
 | 
			
		||||
 | 
			
		||||
  collection_tests(Fog::AWS[:rds].security_groups, params)
 | 
			
		||||
end
 | 
			
		||||
							
								
								
									
										110
									
								
								tests/models/rds/server_tests.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										110
									
								
								tests/models/rds/server_tests.rb
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,110 @@
 | 
			
		|||
Shindo.tests("Aws::RDS | server", ['aws', 'rds']) do
 | 
			
		||||
  # Disabled due to https://github.com/fog/fog/1546
 | 
			
		||||
  pending
 | 
			
		||||
 | 
			
		||||
  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))
 | 
			
		||||
 | 
			
		||||
    @instance.wait_for(20*60) { ready? }
 | 
			
		||||
 | 
			
		||||
    test('#read_replica_identifiers is []') do
 | 
			
		||||
      returns([]) { @instance.read_replica_identifiers }
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    tests('#snapshots') do
 | 
			
		||||
      snapshot = nil
 | 
			
		||||
 | 
			
		||||
      tests('#create').succeeds do
 | 
			
		||||
        snapshot = @instance.snapshots.create(:id => 'fog-test-snapshot')
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      snapshot.wait_for { ready?}
 | 
			
		||||
 | 
			
		||||
      @instance.wait_for { ready? }
 | 
			
		||||
 | 
			
		||||
      returns(true) { @instance.snapshots.map{|s| s.id}.include?(snapshot.id) }
 | 
			
		||||
      snapshot.destroy
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    tests("#modify").succeeds do
 | 
			
		||||
      pending if Fog.mocking?
 | 
			
		||||
 | 
			
		||||
      orig_parameter_group = @instance.db_parameter_groups.first['DBParameterGroupName']
 | 
			
		||||
      parameter_group = Fog::AWS[:rds].parameter_groups.create(:id => uniq_id, :family => 'mysql5.5', :description => 'fog-test')
 | 
			
		||||
 | 
			
		||||
      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? }
 | 
			
		||||
 | 
			
		||||
    tests('#create_read_replica').succeeds do
 | 
			
		||||
 | 
			
		||||
      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? }
 | 
			
		||||
      replica.destroy
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    test("Destroying with a final snapshot") do
 | 
			
		||||
      final_snapshot_id = 'fog-test-snapshot'
 | 
			
		||||
 | 
			
		||||
      @instance_with_final_snapshot.wait_for { ready? }
 | 
			
		||||
      @instance_with_final_snapshot.destroy(final_snapshot_id)
 | 
			
		||||
      returns(true, "Final snapshot created") do
 | 
			
		||||
        @final_snapshot = Fog::AWS[:rds].snapshots.get(final_snapshot_id)
 | 
			
		||||
        !@final_snapshot.nil?
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      @final_snapshot.wait_for { ready? }
 | 
			
		||||
      @final_snapshot.destroy
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
							
								
								
									
										6
									
								
								tests/models/rds/servers_tests.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								tests/models/rds/servers_tests.rb
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,6 @@
 | 
			
		|||
Shindo.tests("Aws::RDS | servers", ['aws', 'rds']) do
 | 
			
		||||
 | 
			
		||||
  collection_tests(Fog::AWS[:rds].servers, rds_default_server_params) do
 | 
			
		||||
    @instance.wait_for { ready? }
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
							
								
								
									
										12
									
								
								tests/models/rds/snapshot_tests.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								tests/models/rds/snapshot_tests.rb
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,12 @@
 | 
			
		|||
Shindo.tests("Aws::RDS | snapshot", ['aws', 'rds']) do
 | 
			
		||||
 | 
			
		||||
  @server = Fog::AWS[:rds].servers.create(rds_default_server_params)
 | 
			
		||||
  @server.wait_for { ready? }
 | 
			
		||||
 | 
			
		||||
  params = {:id => uniq_id, :instance_id => @server.id}
 | 
			
		||||
  model_tests(Fog::AWS[:rds].snapshots, params) do
 | 
			
		||||
    @instance.wait_for { ready? }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  @server.destroy
 | 
			
		||||
end
 | 
			
		||||
							
								
								
									
										12
									
								
								tests/models/rds/snapshots_tests.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								tests/models/rds/snapshots_tests.rb
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,12 @@
 | 
			
		|||
Shindo.tests("Aws::RDS | snapshots", ['aws', 'rds']) do
 | 
			
		||||
 | 
			
		||||
  @server = Fog::AWS[:rds].servers.create(rds_default_server_params)
 | 
			
		||||
  @server.wait_for { ready? }
 | 
			
		||||
 | 
			
		||||
  params = {:id => uniq_id, :instance_id => @server.id}
 | 
			
		||||
  collection_tests(Fog::AWS[:rds].snapshots, params) do
 | 
			
		||||
    @instance.wait_for { ready? }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  @server.destroy
 | 
			
		||||
end
 | 
			
		||||
							
								
								
									
										20
									
								
								tests/models/rds/tagging_tests.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								tests/models/rds/tagging_tests.rb
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,20 @@
 | 
			
		|||
Shindo.tests("Aws::RDS | tagging", ['aws', 'rds']) do
 | 
			
		||||
 | 
			
		||||
  @server = Fog::AWS[:rds].servers.create(rds_default_server_params)
 | 
			
		||||
  Formatador.display_line "Creating RDS instance #{@server.id}"
 | 
			
		||||
  Formatador.display_line "Waiting for instance #{@server.id} to be ready"
 | 
			
		||||
  @server.wait_for { ready? }
 | 
			
		||||
 | 
			
		||||
  tags1 = {'key1' => 'val1'}
 | 
			
		||||
  tags2 = {'key2' => 'val2'}
 | 
			
		||||
 | 
			
		||||
  tests "add and remove tags from a running RDS model" do
 | 
			
		||||
    returns({})                 { @server.tags }
 | 
			
		||||
    returns(tags1)              { @server.add_tags tags1 }
 | 
			
		||||
    returns(tags1.merge tags2)  { @server.add_tags tags2 }
 | 
			
		||||
    returns(tags2)              { @server.remove_tags tags1.keys  }
 | 
			
		||||
    returns(tags2)              { @server.tags }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  @server.destroy
 | 
			
		||||
end
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue