2013-01-14 17:52:16 -05:00
|
|
|
Shindo.tests("HP::BlockStorage | volume requests", ['hp', 'block_storage', 'volumes']) do
|
2012-07-09 16:01:16 -04:00
|
|
|
|
|
|
|
@volume_format = {
|
|
|
|
'status' => String,
|
2012-07-11 17:00:32 -04:00
|
|
|
'displayDescription' => Fog::Nullable::String,
|
2012-07-09 16:01:16 -04:00
|
|
|
'availabilityZone' => String,
|
2012-07-11 17:00:32 -04:00
|
|
|
'displayName' => Fog::Nullable::String,
|
2012-07-09 16:01:16 -04:00
|
|
|
'attachments' => [Fog::Nullable::Hash],
|
|
|
|
'volumeType' => Fog::Nullable::String,
|
2012-07-11 17:00:32 -04:00
|
|
|
'snapshotId' => Fog::Nullable::String,
|
2012-07-09 16:01:16 -04:00
|
|
|
'size' => Integer,
|
|
|
|
'id' => Integer,
|
|
|
|
'createdAt' => String,
|
|
|
|
'metadata' => Fog::Nullable::Hash
|
|
|
|
}
|
|
|
|
|
2012-07-11 19:22:01 -04:00
|
|
|
@volume_attach_format = {
|
|
|
|
"volumeId" => Integer,
|
2012-07-12 01:03:41 -04:00
|
|
|
"id" => Integer
|
2012-07-11 19:22:01 -04:00
|
|
|
}
|
|
|
|
|
2012-07-09 16:01:16 -04:00
|
|
|
tests('success') do
|
|
|
|
|
|
|
|
@volume_id = nil
|
|
|
|
@volume_name = "fogvolumetests"
|
|
|
|
@volume_desc = @volume_name + " desc"
|
2012-07-11 19:22:01 -04:00
|
|
|
@base_image_id = ENV["BASE_IMAGE_ID"] || 1242
|
|
|
|
|
2013-01-18 15:08:27 -05:00
|
|
|
@server = Fog::Compute[:hp].servers.create(:name => 'fogvoltests', :flavor_id => 100, :image_id => @base_image_id)
|
2012-07-12 01:03:41 -04:00
|
|
|
@server.wait_for { ready? }
|
2012-07-09 16:01:16 -04:00
|
|
|
|
|
|
|
tests("#create_volume(#{@volume_name}, #{@volume_desc}, 1)").formats(@volume_format) do
|
2013-01-14 17:52:16 -05:00
|
|
|
data = HP[:block_storage].create_volume(@volume_name, @volume_desc, 1).body['volume']
|
2012-07-09 16:01:16 -04:00
|
|
|
@volume_id = data['id']
|
|
|
|
data
|
|
|
|
end
|
|
|
|
|
2013-01-14 17:52:16 -05:00
|
|
|
HP[:block_storage].volumes.get(@volume_id).wait_for { ready? }
|
2012-07-09 16:01:16 -04:00
|
|
|
tests("#get_volume_details(#{@volume_id})").formats(@volume_format) do
|
2013-01-14 17:52:16 -05:00
|
|
|
HP[:block_storage].get_volume_details(@volume_id).body['volume']
|
2012-07-09 16:01:16 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
tests('#list_volumes').formats({'volumes' => [@volume_format]}) do
|
2013-01-14 17:52:16 -05:00
|
|
|
HP[:block_storage].list_volumes.body
|
2012-07-09 16:01:16 -04:00
|
|
|
end
|
|
|
|
|
2013-01-14 17:52:16 -05:00
|
|
|
HP[:block_storage].volumes.get(@volume_id).wait_for { ready? }
|
2012-07-11 19:22:01 -04:00
|
|
|
tests("#attach_volume(#{@server.id}, #{@volume_id}, '/dev/sdg')").formats(@volume_attach_format) do
|
2013-01-18 15:08:27 -05:00
|
|
|
Fog::Compute[:hp].attach_volume(@server.id, @volume_id, "/dev/sdg").body['volumeAttachment']
|
2012-07-11 19:22:01 -04:00
|
|
|
end
|
|
|
|
|
2013-01-14 17:52:16 -05:00
|
|
|
HP[:block_storage].volumes.get(@volume_id).wait_for { in_use? } unless Fog.mocking?
|
2012-07-11 19:22:01 -04:00
|
|
|
tests("#detach_volume(#{@server.id}, #{@volume_id})").succeeds do
|
2013-01-18 15:08:27 -05:00
|
|
|
Fog::Compute[:hp].detach_volume(@server.id, @volume_id)
|
2012-07-11 19:22:01 -04:00
|
|
|
end
|
|
|
|
|
2013-01-14 17:52:16 -05:00
|
|
|
HP[:block_storage].volumes.get(@volume_id).wait_for { ready? }
|
2012-07-09 16:01:16 -04:00
|
|
|
tests("#delete_volume(#{@volume_id})").succeeds do
|
2013-01-14 17:52:16 -05:00
|
|
|
HP[:block_storage].delete_volume(@volume_id)
|
2012-07-09 16:01:16 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
tests('failure') do
|
|
|
|
|
2013-01-14 17:52:16 -05:00
|
|
|
tests('#get_volume_details(0)').raises(Fog::HP::BlockStorage::NotFound) do
|
|
|
|
HP[:block_storage].get_volume_details(0)
|
2012-07-09 16:01:16 -04:00
|
|
|
end
|
|
|
|
|
2012-07-11 19:22:01 -04:00
|
|
|
tests("#attach_volume(0, 0, '/dev/sdg')").raises(Fog::Compute::HP::NotFound) do
|
2013-01-18 15:08:27 -05:00
|
|
|
Fog::Compute[:hp].attach_volume(0, 0, "/dev/sdg")
|
2012-07-11 19:22:01 -04:00
|
|
|
end
|
2013-01-18 15:08:27 -05:00
|
|
|
tests("#attach_volume(#{@server.id}, 0, '/dev/sdg')").raises(Fog::HP::BlockStorage::NotFound) do
|
2012-07-11 19:22:01 -04:00
|
|
|
pending if Fog.mocking?
|
2013-01-18 15:08:27 -05:00
|
|
|
Fog::Compute[:hp].attach_volume(@server.id, 0, "/dev/sdg")
|
2012-07-11 19:22:01 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
tests("#detach_volume(0, 0)").raises(Fog::Compute::HP::NotFound) do
|
2013-01-18 15:08:27 -05:00
|
|
|
Fog::Compute[:hp].detach_volume(0, 0)
|
2012-07-11 19:22:01 -04:00
|
|
|
end
|
2013-01-18 15:08:27 -05:00
|
|
|
tests("#detach_volume(#{@server.id}, 0)").raises(Fog::HP::BlockStorage::NotFound) do
|
2012-07-11 19:22:01 -04:00
|
|
|
pending if Fog.mocking?
|
2013-01-18 15:08:27 -05:00
|
|
|
Fog::Compute[:hp].detach_volume(@server.id, 0)
|
2012-07-11 19:22:01 -04:00
|
|
|
end
|
|
|
|
|
2013-01-14 17:52:16 -05:00
|
|
|
tests("#delete_volume(0)").raises(Fog::HP::BlockStorage::NotFound) do
|
|
|
|
HP[:block_storage].delete_volume(0)
|
2012-07-11 19:22:01 -04:00
|
|
|
end
|
|
|
|
|
2012-07-09 16:01:16 -04:00
|
|
|
end
|
|
|
|
|
2012-07-12 01:03:41 -04:00
|
|
|
@server.destroy
|
|
|
|
|
2012-07-09 16:01:16 -04:00
|
|
|
end
|