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

Better mocks for invalid Provisioned IOPS values

This commit is contained in:
Thom Mahoney 2012-08-17 15:56:26 -07:00
parent fc62664417
commit 4810343c13
2 changed files with 21 additions and 2 deletions

View file

@ -66,7 +66,8 @@ module Fog
end
if options['VolumeType'] == 'io1'
if !options['Iops']
iops = options['Iops']
if !iops
raise Fog::Compute::AWS::Error.new("InvalidParameterCombination => The parameter iops must be specified for io1 volumes.")
end
@ -74,9 +75,17 @@ module Fog
raise Fog::Compute::AWS::Error.new("InvalidParameterValue => Volume of #{size}GiB is too small; minimum is 10GiB.")
end
if (iops_to_size_ratio = options['Iops'].to_f / size.to_f) > 10.0
if (iops_to_size_ratio = iops.to_f / size.to_f) > 10.0
raise Fog::Compute::AWS::Error.new("InvalidParameterValue => Iops to volume size ratio of #{"%.1f" % iops_to_size_ratio} is too high; maximum is 10.0")
end
if iops < 100
raise Fog::Compute::AWS::Error.new("VolumeIOPSLimit => Volume iops of #{iops} is too low; minimum is 100.")
end
if iops > 1000
raise Fog::Compute::AWS::Error.new("VolumeIOPSLimit => Volume iops of #{iops} is too high; maximum is 1000.")
end
end
response.status = 200

View file

@ -179,6 +179,16 @@ Shindo.tests('Fog::Compute[:aws] | volume requests', ['aws']) do
Fog::Compute[:aws].create_volume(@server.availability_zone, 10, 'VolumeType' => 'io1', 'Iops' => 101)
end
# iops invalid value (lower than 100)
tests("#create_volume('#{@server.availability_zone}', 10, 'VolumeType' => 'io1', 'Iops' => 99)").raises(Fog::Compute::AWS::Error) do
Fog::Compute[:aws].create_volume(@server.availability_zone, 10, 'VolumeType' => 'io1', 'Iops' => 99)
end
# iops invalid value (greater than 1000)
tests("#create_volume('#{@server.availability_zone}', 10, 'VolumeType' => 'io1', 'Iops' => 1001)").raises(Fog::Compute::AWS::Error) do
Fog::Compute[:aws].create_volume(@server.availability_zone, 1000, 'VolumeType' => 'io1', 'Iops' => 1001)
end
@volume.destroy
end