1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[ec2] decentralize formats back into tests

This commit is contained in:
geemus 2010-05-26 15:22:23 -07:00
parent eff7978b64
commit 9d4bf86477
8 changed files with 123 additions and 108 deletions

View file

@ -33,100 +33,11 @@ module AWS
module Formats
ADDRESSES = {
'addressesSet' => [{
'instanceId' => NilClass,
'publicIp' => String
}],
'requestId' => String
}
AVAILABILITY_ZONES = {
'availabilityZoneInfo' => [{
'regionName' => String,
'zoneName' => String,
'zoneState' => String
}],
'requestId' => String
}
BASIC = {
'requestId' => String,
'return' => ::Fog::Boolean
}
REGIONS = {
'regionInfo' => [{
'regionEndpoint' => String,
'regionName' => String
}],
'requestId' => String
}
SECURITY_GROUPS = {
'requestId' => String,
'securityGroupInfo' => [{
'groupDescription' => String,
'groupName' => String,
'ipPermissions' => [{
'fromPort' => Integer,
'groups' => [{ 'groupName' => String, 'userId' => String }],
'ipProtocol' => String,
'ipRanges' => [],
'toPort' => Integer,
}],
'ownerId' => String
}]
}
SNAPSHOT = {
'description' => NilClass,
'ownerId' => String,
'progress' => String,
'snapshotId' => String,
'startTime' => Time,
'status' => String,
'volumeId' => String,
'volumeSize' => Integer
}
SNAPSHOTS = {
'requestId' => String,
'snapshotSet' => [SNAPSHOT]
}
VOLUME = {
'availabilityZone' => String,
'createTime' => Time,
'requestId' => String,
'size' => Integer,
'snapshotId' => NilClass,
'status' => String,
'volumeId' => String
}
VOLUME_ATTACHMENT = {
'attachTime' => Time,
'device' => String,
'instanceId' => String,
'requestId' => String,
'status' => String,
'volumeId' => String
}
VOLUMES = {
'volumeSet' => [{
'availabilityZone' => String,
'attachmentSet' => [],
'createTime' => Time,
'size' => Integer,
'snapshotId' => NilClass,
'status' => String,
'volumeId' => String
}],
'requestId' => String
}
end
end

View file

@ -1,5 +1,13 @@
Shindo.tests('AWS::EC2 | address requests', ['aws']) do
@addresses_format = {
'addressesSet' => [{
'instanceId' => NilClass,
'publicIp' => String
}],
'requestId' => String
}
@server = AWS[:ec2].servers.create(:image_id => GENTOO_AMI)
@server.wait_for { ready? }
@ip_address = @server.ip_address
@ -14,11 +22,11 @@ Shindo.tests('AWS::EC2 | address requests', ['aws']) do
data
end
tests('#describe_addresses').formats(AWS::EC2::Formats::ADDRESSES) do
tests('#describe_addresses').formats(@addresses_format) do
AWS[:ec2].describe_addresses.body
end
tests("#describe_addresses('#{@public_Ip}')").formats(AWS::EC2::Formats::ADDRESSES) do
tests("#describe_addresses('#{@public_Ip}')").formats(@addresses_format) do
AWS[:ec2].describe_addresses(@public_ip).body
end

View file

@ -1,12 +1,21 @@
Shindo.tests('AWS::EC2 | availability zone requests', ['aws']) do
@availability_zones_format = {
'availabilityZoneInfo' => [{
'regionName' => String,
'zoneName' => String,
'zoneState' => String
}],
'requestId' => String
}
tests('success') do
tests('#describe_availability_zones').formats(AWS::EC2::Formats::AVAILABILITY_ZONES) do
tests('#describe_availability_zones').formats(@availability_zones_format) do
AWS[:ec2].describe_availability_zones.body
end
tests("#describe_availability_zones('us-east-1a')").formats(AWS::EC2::Formats::AVAILABILITY_ZONES) do
tests("#describe_availability_zones('us-east-1a')").formats(@availability_zones_format) do
AWS[:ec2].describe_availability_zones('us-east-1a').body
end

View file

@ -2,17 +2,32 @@ Shindo.tests('AWS::EC2 | key pair requests', ['aws']) do
tests('success') do
@keypair_format = {
'keyFingerprint' => String,
'keyMaterial' => String,
'keyName' => String,
'requestId' => String
}
@keypairs_format = {
'keySet' => [{
'keyFingerprint' => String,
'keyName' => String
}],
'requestId' => String
}
@key_pair_name = 'fog_key_pair'
tests("#create_key_pair('#{@key_pair_name}')").formats({ 'keyFingerprint' => String, 'keyMaterial' => String, 'keyName' => String, 'requestId' => String }) do
tests("#create_key_pair('#{@key_pair_name}')").formats(@keypair_format) do
AWS[:ec2].create_key_pair(@key_pair_name).body
end
tests('#describe_key_pairs').formats({ 'keySet' => [{'keyFingerprint' => String, 'keyName' => String}], 'requestId' => String }) do
tests('#describe_key_pairs').formats(@keypairs_format) do
AWS[:ec2].describe_key_pairs.body
end
tests("#describe_key_pairs(#{@key_pair_name})").formats({ 'keySet' => [{'keyFingerprint' => String, 'keyName' => String}], 'requestId' => String }) do
tests("#describe_key_pairs(#{@key_pair_name})").formats(@keypairs_format) do
AWS[:ec2].describe_key_pairs(@key_pair_name).body
end

View file

@ -1,12 +1,20 @@
Shindo.tests('AWS::EC2 | region requests', ['aws']) do
@regions_format = {
'regionInfo' => [{
'regionEndpoint' => String,
'regionName' => String
}],
'requestId' => String
}
tests('success') do
tests("#describe_regions").formats(AWS::EC2::Formats::REGIONS) do
tests("#describe_regions").formats(@regions_format) do
AWS[:ec2].describe_regions.body
end
tests("#describe_regions('us-east-1')").formats(AWS::EC2::Formats::REGIONS) do
tests("#describe_regions('us-east-1')").formats(@regions_format) do
AWS[:ec2].describe_regions('us-east-1').body
end

View file

@ -1,5 +1,21 @@
Shindo.tests('AWS::EC2 | security group requests', ['aws']) do
@security_groups_format = {
'requestId' => String,
'securityGroupInfo' => [{
'groupDescription' => String,
'groupName' => String,
'ipPermissions' => [{
'fromPort' => Integer,
'groups' => [{ 'groupName' => String, 'userId' => String }],
'ipProtocol' => String,
'ipRanges' => [],
'toPort' => Integer,
}],
'ownerId' => String
}]
}
@owner_id = AWS[:ec2].describe_security_groups('default').body['securityGroupInfo'].first['ownerId']
tests('success') do
@ -25,11 +41,11 @@ Shindo.tests('AWS::EC2 | security group requests', ['aws']) do
}).body
end
tests("#describe_security_groups").formats(AWS::EC2::Formats::SECURITY_GROUPS) do
tests("#describe_security_groups").formats(@security_groups_format) do
AWS[:ec2].describe_security_groups.body
end
tests("#describe_security_groups('fog_security_group')").formats(AWS::EC2::Formats::SECURITY_GROUPS) do
tests("#describe_security_groups('fog_security_group')").formats(@security_groups_format) do
AWS[:ec2].describe_security_groups('fog_security_group').body
end

View file

@ -1,23 +1,39 @@
Shindo.tests('AWS::EC2 | snapshot requests', ['aws']) do
@snapshot_format = {
'description' => NilClass,
'ownerId' => String,
'progress' => String,
'snapshotId' => String,
'startTime' => Time,
'status' => String,
'volumeId' => String,
'volumeSize' => Integer
}
@snapshots_format = {
'requestId' => String,
'snapshotSet' => [@snapshot_format]
}
@volume = AWS[:ec2].volumes.create(:availability_zone => 'us-east-1a', :size => 1)
tests('success') do
@snapshot_id = nil
tests("#create_snapshot(#{@volume.identity})").formats(AWS::EC2::Formats::SNAPSHOT.merge('progress' => NilClass, 'requestId' => String)) do
tests("#create_snapshot(#{@volume.identity})").formats(@snapshot_format.merge('progress' => NilClass, 'requestId' => String)) do
data = AWS[:ec2].create_snapshot(@volume.identity).body
@snapshot_id = data['snapshotId']
data
end
tests("#describe_snapshots").formats(AWS::EC2::Formats::SNAPSHOTS) do
tests("#describe_snapshots").formats(@snapshots_format) do
AWS[:ec2].snapshots.get(@snapshot_id).wait_for { ready? }
AWS[:ec2].describe_snapshots.body
end
tests("#describe_snapshots('#{@snapshot_id}')").formats(AWS::EC2::Formats::SNAPSHOTS) do
tests("#describe_snapshots('#{@snapshot_id}')").formats(@snapshots_format) do
AWS[:ec2].describe_snapshots(@snapshot_id).body
end

View file

@ -1,5 +1,37 @@
Shindo.tests('AWS::EC2 | volume requests', ['aws']) do
@volume_format = {
'availabilityZone' => String,
'createTime' => Time,
'requestId' => String,
'size' => Integer,
'snapshotId' => NilClass,
'status' => String,
'volumeId' => String
}
@volume_attachment_format = {
'attachTime' => Time,
'device' => String,
'instanceId' => String,
'requestId' => String,
'status' => String,
'volumeId' => String
}
@volumes_format = {
'volumeSet' => [{
'availabilityZone' => String,
'attachmentSet' => [],
'createTime' => Time,
'size' => Integer,
'snapshotId' => NilClass,
'status' => String,
'volumeId' => String
}],
'requestId' => String
}
@server = AWS[:ec2].servers.create(:image_id => GENTOO_AMI)
@server.wait_for { ready? }
@ -7,26 +39,26 @@ Shindo.tests('AWS::EC2 | volume requests', ['aws']) do
@volume_id = nil
tests('#create_volume').formats(AWS::EC2::Formats::VOLUME) do
tests('#create_volume').formats(@volume_format) do
data = AWS[:ec2].create_volume(@server.availability_zone, 1).body
@volume_id = data['volumeId']
data
end
tests('#describe_volumes').formats(AWS::EC2::Formats::VOLUMES) do
tests('#describe_volumes').formats(@volumes_format) do
AWS[:ec2].describe_volumes.body
end
tests("#describe_volumes(#{@volume_id})").formats(AWS::EC2::Formats::VOLUMES) do
tests("#describe_volumes(#{@volume_id})").formats(@volumes_format) do
AWS[:ec2].describe_volumes.body
end
tests("#attach_volume(#{@server.identity}, #{@volume_id}, '/dev/sdh')").formats(AWS::EC2::Formats::VOLUME_ATTACHMENT) do
tests("#attach_volume(#{@server.identity}, #{@volume_id}, '/dev/sdh')").formats(@volume_attachment_format) do
AWS[:ec2].volumes.get(@volume_id).wait_for { ready? }
AWS[:ec2].attach_volume(@server.identity, @volume_id, '/dev/sdh').body
end
tests("#detach_volume('#{@volume_id}')").formats(AWS::EC2::Formats::VOLUME_ATTACHMENT) do
tests("#detach_volume('#{@volume_id}')").formats(@volume_attachment_format) do
AWS[:ec2].volumes.get(@volume_id).wait_for { state == 'in-use' }
AWS[:ec2].detach_volume(@volume_id).body
end