2011-06-16 19:28:54 -04:00
|
|
|
Shindo.tests('Fog::Compute[:aws] | volume requests', ['aws']) do
|
2010-05-08 17:51:41 -04:00
|
|
|
|
2010-05-26 18:22:23 -04:00
|
|
|
@volume_format = {
|
|
|
|
'availabilityZone' => String,
|
|
|
|
'createTime' => Time,
|
|
|
|
'requestId' => String,
|
|
|
|
'size' => Integer,
|
2011-04-27 16:19:19 -04:00
|
|
|
'snapshotId' => Fog::Nullable::String,
|
2010-05-26 18:22:23 -04:00
|
|
|
'status' => String,
|
|
|
|
'volumeId' => String
|
|
|
|
}
|
|
|
|
|
|
|
|
@volume_attachment_format = {
|
|
|
|
'attachTime' => Time,
|
|
|
|
'device' => String,
|
|
|
|
'instanceId' => String,
|
|
|
|
'requestId' => String,
|
|
|
|
'status' => String,
|
|
|
|
'volumeId' => String
|
|
|
|
}
|
|
|
|
|
|
|
|
@volumes_format = {
|
|
|
|
'volumeSet' => [{
|
2010-11-02 15:21:17 -04:00
|
|
|
'availabilityZone' => String,
|
2011-05-18 16:18:14 -04:00
|
|
|
'attachmentSet' => Array,
|
2010-11-02 15:21:17 -04:00
|
|
|
'createTime' => Time,
|
|
|
|
'size' => Integer,
|
2011-04-27 16:19:19 -04:00
|
|
|
'snapshotId' => Fog::Nullable::String,
|
2010-11-02 15:21:17 -04:00
|
|
|
'status' => String,
|
2011-05-18 16:18:14 -04:00
|
|
|
'tagSet' => Hash,
|
2010-11-02 15:21:17 -04:00
|
|
|
'volumeId' => String
|
2010-05-26 18:22:23 -04:00
|
|
|
}],
|
|
|
|
'requestId' => String
|
|
|
|
}
|
|
|
|
|
2011-06-16 19:28:54 -04:00
|
|
|
@server = Fog::Compute[:aws].servers.create
|
2010-05-08 17:51:41 -04:00
|
|
|
@server.wait_for { ready? }
|
|
|
|
|
|
|
|
tests('success') do
|
|
|
|
|
|
|
|
@volume_id = nil
|
|
|
|
|
2010-05-26 18:22:23 -04:00
|
|
|
tests('#create_volume').formats(@volume_format) do
|
2011-06-16 19:28:54 -04:00
|
|
|
data = Fog::Compute[:aws].create_volume(@server.availability_zone, 1).body
|
2010-05-21 17:43:29 -04:00
|
|
|
@volume_id = data['volumeId']
|
|
|
|
data
|
2010-05-08 17:51:41 -04:00
|
|
|
end
|
|
|
|
|
2011-06-20 18:22:57 -04:00
|
|
|
tests('#create_volume from snapshot').formats(@volume_format) do
|
|
|
|
volume = Fog::Compute[:aws].volumes.create(:availability_zone => 'us-east-1d', :size => 1)
|
|
|
|
snapshot = Fog::Compute[:aws].create_snapshot(volume.identity).body
|
|
|
|
data = Fog::Compute[:aws].create_volume(@server.availability_zone, nil, snapshot['snapshotId']).body
|
|
|
|
@volume_id = data['volumeId']
|
|
|
|
data
|
|
|
|
end
|
|
|
|
|
|
|
|
tests('#create_volume from snapshot with size').formats(@volume_format) do
|
|
|
|
volume = Fog::Compute[:aws].volumes.create(:availability_zone => 'us-east-1d', :size => 1)
|
|
|
|
snapshot = Fog::Compute[:aws].create_snapshot(volume.identity).body
|
|
|
|
data = Fog::Compute[:aws].create_volume(@server.availability_zone, 1, snapshot['snapshotId']).body
|
|
|
|
@volume_id = data['volumeId']
|
|
|
|
data
|
|
|
|
end
|
|
|
|
|
2011-06-16 19:28:54 -04:00
|
|
|
Fog::Compute[:aws].volumes.get(@volume_id).wait_for { ready? }
|
2010-06-10 14:43:59 -04:00
|
|
|
|
2010-05-26 18:22:23 -04:00
|
|
|
tests('#describe_volumes').formats(@volumes_format) do
|
2011-06-16 19:28:54 -04:00
|
|
|
Fog::Compute[:aws].describe_volumes.body
|
2010-05-08 17:51:41 -04:00
|
|
|
end
|
|
|
|
|
2010-10-04 18:46:12 -04:00
|
|
|
tests("#describe_volumes('volume-id' => #{@volume_id})").formats(@volumes_format) do
|
2011-06-16 19:28:54 -04:00
|
|
|
Fog::Compute[:aws].describe_volumes('volume-id' => @volume_id).body
|
2010-05-08 17:51:41 -04:00
|
|
|
end
|
|
|
|
|
2010-05-26 18:22:23 -04:00
|
|
|
tests("#attach_volume(#{@server.identity}, #{@volume_id}, '/dev/sdh')").formats(@volume_attachment_format) do
|
2011-06-16 19:28:54 -04:00
|
|
|
Fog::Compute[:aws].attach_volume(@server.identity, @volume_id, '/dev/sdh').body
|
2010-05-08 17:51:41 -04:00
|
|
|
end
|
|
|
|
|
2011-06-16 19:28:54 -04:00
|
|
|
Fog::Compute[:aws].volumes.get(@volume_id).wait_for { state == 'in-use' }
|
2010-05-26 18:24:44 -04:00
|
|
|
|
2010-05-26 18:22:23 -04:00
|
|
|
tests("#detach_volume('#{@volume_id}')").formats(@volume_attachment_format) do
|
2011-06-16 19:28:54 -04:00
|
|
|
Fog::Compute[:aws].detach_volume(@volume_id).body
|
2010-05-08 17:51:41 -04:00
|
|
|
end
|
|
|
|
|
2011-06-16 19:28:54 -04:00
|
|
|
Fog::Compute[:aws].volumes.get(@volume_id).wait_for { ready? }
|
2010-05-26 18:24:44 -04:00
|
|
|
|
2010-09-09 20:50:38 -04:00
|
|
|
tests("#delete_volume('#{@volume_id}')").formats(AWS::Compute::Formats::BASIC) do
|
2011-06-16 19:28:54 -04:00
|
|
|
Fog::Compute[:aws].delete_volume(@volume_id).body
|
2010-05-08 17:51:41 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2011-06-16 19:28:54 -04:00
|
|
|
tests('failure') do
|
2010-05-08 17:51:41 -04:00
|
|
|
|
2011-06-16 19:28:54 -04:00
|
|
|
@volume = Fog::Compute[:aws].volumes.create(:availability_zone => @server.availability_zone, :size => 1)
|
2010-05-08 17:51:41 -04:00
|
|
|
|
2011-06-16 19:28:54 -04:00
|
|
|
tests("#attach_volume('i-00000000', '#{@volume.identity}', '/dev/sdh')").raises(Fog::Compute::AWS::NotFound) do
|
|
|
|
Fog::Compute[:aws].attach_volume('i-00000000', @volume.identity, '/dev/sdh')
|
2010-05-08 17:51:41 -04:00
|
|
|
end
|
|
|
|
|
2011-06-16 19:28:54 -04:00
|
|
|
tests("#attach_volume('#{@server.identity}', 'vol-00000000', '/dev/sdh')").raises(Fog::Compute::AWS::NotFound) do
|
|
|
|
Fog::Compute[:aws].attach_volume(@server.identity, 'vol-00000000', '/dev/sdh')
|
2010-05-08 17:51:41 -04:00
|
|
|
end
|
|
|
|
|
2011-06-16 19:28:54 -04:00
|
|
|
tests("#detach_volume('vol-00000000')").raises(Fog::Compute::AWS::NotFound) do
|
|
|
|
Fog::Compute[:aws].detach_volume('vol-00000000')
|
2010-05-08 17:51:41 -04:00
|
|
|
end
|
|
|
|
|
2011-06-16 19:28:54 -04:00
|
|
|
tests("#delete_volume('vol-00000000')").raises(Fog::Compute::AWS::NotFound) do
|
|
|
|
Fog::Compute[:aws].delete_volume('vol-00000000')
|
2010-05-08 17:51:41 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
@volume.destroy
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
@server.destroy
|
|
|
|
|
|
|
|
end
|