mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Add shindo tests for attach and detach.
This commit is contained in:
parent
fc146770f6
commit
2a997ff659
1 changed files with 47 additions and 11 deletions
|
@ -14,11 +14,22 @@ Shindo.tests('Fog::BlockStorage[:hp] | volume requests', ['hp', 'block_storage']
|
|||
'metadata' => Fog::Nullable::Hash
|
||||
}
|
||||
|
||||
@volume_attach_format = {
|
||||
"volumeId" => Integer,
|
||||
"device" => String
|
||||
}
|
||||
|
||||
tests('success') do
|
||||
|
||||
@volume_id = nil
|
||||
@volume_name = "fogvolumetests"
|
||||
@volume_desc = @volume_name + " desc"
|
||||
@base_image_id = ENV["BASE_IMAGE_ID"] || 1242
|
||||
|
||||
#before do
|
||||
# @server = Fog::Compute[:hp].servers.create(:name => 'fogvoltests', :flavor_id => 100, :image_id => @base_image_id)
|
||||
# @server.wait_for { ready? }
|
||||
#end
|
||||
|
||||
tests("#create_volume(#{@volume_name}, #{@volume_desc}, 1)").formats(@volume_format) do
|
||||
data = Fog::BlockStorage[:hp].create_volume(@volume_name, @volume_desc, 1).body['volume']
|
||||
|
@ -26,8 +37,7 @@ Shindo.tests('Fog::BlockStorage[:hp] | volume requests', ['hp', 'block_storage']
|
|||
data
|
||||
end
|
||||
|
||||
#Fog::BlockStorage[:hp].volumes.get(@volume_id).wait_for { ready? }
|
||||
#
|
||||
Fog::BlockStorage[:hp].volumes.get(@volume_id).wait_for { ready? }
|
||||
tests("#get_volume_details(#{@volume_id})").formats(@volume_format) do
|
||||
Fog::BlockStorage[:hp].get_volume_details(@volume_id).body['volume']
|
||||
end
|
||||
|
@ -36,27 +46,53 @@ Shindo.tests('Fog::BlockStorage[:hp] | volume requests', ['hp', 'block_storage']
|
|||
Fog::BlockStorage[:hp].list_volumes.body
|
||||
end
|
||||
|
||||
#Fog::BlockStorage[:hp].volumes.get(@volume_id).wait_for { ready? }
|
||||
#
|
||||
@server = Fog::Compute[:hp].servers.create(:name => 'fogvoltests', :flavor_id => 100, :image_id => @base_image_id)
|
||||
@server.wait_for { ready? }
|
||||
tests("#attach_volume(#{@server.id}, #{@volume_id}, '/dev/sdg')").formats(@volume_attach_format) do
|
||||
Fog::BlockStorage[:hp].compute.attach_volume(@server.id, @volume_id, "/dev/sdg").body['volumeAttachment']
|
||||
end
|
||||
|
||||
tests("#detach_volume(#{@server.id}, #{@volume_id})").succeeds do
|
||||
Fog::BlockStorage[:hp].compute.detach_volume(@server.id, @volume_id)
|
||||
end
|
||||
@server.destroy
|
||||
|
||||
Fog::BlockStorage[:hp].volumes.get(@volume_id).wait_for { ready? }
|
||||
tests("#delete_volume(#{@volume_id})").succeeds do
|
||||
Fog::BlockStorage[:hp].delete_volume(@volume_id)
|
||||
end
|
||||
|
||||
# Add attach_volume and detach_volume tests
|
||||
|
||||
#after do
|
||||
# @server.destroy
|
||||
#end
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
|
||||
tests('#delete_volume(0)').raises(Fog::BlockStorage::HP::NotFound) do
|
||||
Fog::BlockStorage[:hp].delete_volume(0)
|
||||
end
|
||||
|
||||
tests('#get_volume_details(0)').raises(Fog::BlockStorage::HP::NotFound) do
|
||||
Fog::BlockStorage[:hp].get_volume_details(0)
|
||||
end
|
||||
|
||||
# Add attach_volume and detach_volume tests
|
||||
tests("#attach_volume(0, 0, '/dev/sdg')").raises(Fog::Compute::HP::NotFound) do
|
||||
Fog::BlockStorage[:hp].compute.attach_volume(0, 0, "/dev/sdg")
|
||||
end
|
||||
tests("#attach_volume(#{@server.id}, 0, '/dev/sdg')").raises(Fog::BlockStorage::HP::NotFound) do
|
||||
pending if Fog.mocking?
|
||||
Fog::BlockStorage[:hp].compute.attach_volume(@server.id, 0, "/dev/sdg")
|
||||
end
|
||||
|
||||
tests("#detach_volume(0, 0)").raises(Fog::Compute::HP::NotFound) do
|
||||
Fog::BlockStorage[:hp].compute.detach_volume(0, 0)
|
||||
end
|
||||
tests("#detach_volume(#{@server.id}, 0)").raises(Fog::BlockStorage::HP::NotFound) do
|
||||
pending if Fog.mocking?
|
||||
Fog::BlockStorage[:hp].compute.detach_volume(@server.id, 0)
|
||||
end
|
||||
|
||||
tests("#delete_volume(0)").raises(Fog::BlockStorage::HP::NotFound) do
|
||||
Fog::BlockStorage[:hp].delete_volume(0)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue