mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Fix mock. Fix tests for mocking and real modes.
This commit is contained in:
parent
2a997ff659
commit
31d1708329
3 changed files with 29 additions and 27 deletions
|
@ -48,16 +48,16 @@ module Fog
|
|||
resp_data = { "volumeAttachment" =>
|
||||
{
|
||||
"volumeId" => volume_id,
|
||||
"device" => device
|
||||
"id" => volume_id
|
||||
}
|
||||
}
|
||||
response.body = resp_data
|
||||
response.status = 200
|
||||
|
||||
data = {
|
||||
"device" => device,
|
||||
"device" => device,
|
||||
"serverId" => server_id,
|
||||
"id" => volume_id,
|
||||
"id" => volume_id,
|
||||
"volumeId" => volume_id,
|
||||
}
|
||||
if server['volumeAttachments']
|
||||
|
|
|
@ -16,7 +16,7 @@ Shindo.tests('Fog::BlockStorage[:hp] | volume requests', ['hp', 'block_storage']
|
|||
|
||||
@volume_attach_format = {
|
||||
"volumeId" => Integer,
|
||||
"device" => String
|
||||
"id" => Integer
|
||||
}
|
||||
|
||||
tests('success') do
|
||||
|
@ -26,10 +26,8 @@ Shindo.tests('Fog::BlockStorage[:hp] | volume requests', ['hp', 'block_storage']
|
|||
@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
|
||||
@server = Fog::BlockStorage[:hp].compute.servers.create(:name => 'fogvoltests', :flavor_id => 100, :image_id => @base_image_id)
|
||||
@server.wait_for { ready? }
|
||||
|
||||
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']
|
||||
|
@ -46,25 +44,21 @@ Shindo.tests('Fog::BlockStorage[:hp] | volume requests', ['hp', 'block_storage']
|
|||
Fog::BlockStorage[:hp].list_volumes.body
|
||||
end
|
||||
|
||||
@server = Fog::Compute[:hp].servers.create(:name => 'fogvoltests', :flavor_id => 100, :image_id => @base_image_id)
|
||||
@server.wait_for { ready? }
|
||||
Fog::BlockStorage[:hp].volumes.get(@volume_id).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
|
||||
|
||||
Fog::BlockStorage[:hp].volumes.get(@volume_id).wait_for { in_use? } unless Fog.mocking?
|
||||
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
|
||||
|
||||
#after do
|
||||
# @server.destroy
|
||||
#end
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
|
@ -76,7 +70,7 @@ Shindo.tests('Fog::BlockStorage[:hp] | volume requests', ['hp', 'block_storage']
|
|||
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
|
||||
tests("#attach_volume(#{@server.id}, 0, '/dev/sdg')").raises(Fog::Compute::HP::NotFound) do
|
||||
pending if Fog.mocking?
|
||||
Fog::BlockStorage[:hp].compute.attach_volume(@server.id, 0, "/dev/sdg")
|
||||
end
|
||||
|
@ -84,7 +78,7 @@ Shindo.tests('Fog::BlockStorage[:hp] | volume requests', ['hp', 'block_storage']
|
|||
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
|
||||
tests("#detach_volume(#{@server.id}, 0)").raises(Fog::Compute::HP::NotFound) do
|
||||
pending if Fog.mocking?
|
||||
Fog::BlockStorage[:hp].compute.detach_volume(@server.id, 0)
|
||||
end
|
||||
|
@ -95,4 +89,6 @@ Shindo.tests('Fog::BlockStorage[:hp] | volume requests', ['hp', 'block_storage']
|
|||
|
||||
end
|
||||
|
||||
@server.destroy
|
||||
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Shindo.tests('Fog::Compute[:hp] | volume requests', ['hp', 'block_storage']) do
|
||||
Shindo.tests('Fog::Compute[:hp] | volume requests', ['hp', 'compute', 'block_storage']) do
|
||||
|
||||
@list_volume_attachments_format = {
|
||||
'volumeAttachments' => [{
|
||||
|
@ -11,45 +11,47 @@ Shindo.tests('Fog::Compute[:hp] | volume requests', ['hp', 'block_storage']) do
|
|||
|
||||
@volume_attachment_format = {
|
||||
'volumeAttachment' => {
|
||||
'device' => String,
|
||||
'volumeId' => Integer
|
||||
"volumeId" => Integer,
|
||||
"id" => Integer
|
||||
}
|
||||
}
|
||||
|
||||
@base_image_id = ENV["BASE_IMAGE_ID"] || 1242
|
||||
|
||||
@server = Fog::Compute[:hp].servers.create(:name => 'fogservoltests', :flavor_id => 100, :image_id => @base_image_id)
|
||||
@server.wait_for { ready? }
|
||||
|
||||
tests('success') do
|
||||
@server = Fog::Compute[:hp].servers.create(:name => 'fogservoltests', :flavor_id => 100, :image_id => @base_image_id)
|
||||
@server.wait_for { ready? }
|
||||
response = Fog::BlockStorage[:hp].create_volume('fogvoltest', 'fogvoltest desc', 1)
|
||||
@volume_id = response.body['volume']['id']
|
||||
@device = "\/dev\/sdf"
|
||||
#Fog::BlockStorage[:hp].volumes.get(@volume_id).wait_for { ready? }
|
||||
|
||||
Fog::BlockStorage[:hp].volumes.get(@volume_id).wait_for { ready? }
|
||||
tests("#attach_volume(#{@server.id}, #{@volume_id}, #{@device}").formats(@volume_attachment_format) do
|
||||
Fog::Compute[:hp].attach_volume(@server.id, @volume_id, @device).body
|
||||
end
|
||||
|
||||
Fog::BlockStorage[:hp].volumes.get(@volume_id).wait_for { in_use? } unless Fog.mocking?
|
||||
tests("#detach_volume(#{@server.id}, #{@volume_id}").succeeds do
|
||||
Fog::Compute[:hp].detach_volume(@server.id, @volume_id)
|
||||
end
|
||||
|
||||
Fog::BlockStorage[:hp].volumes.get(@volume_id).wait_for { ready? }
|
||||
tests("#list_server_volumes(#{@server.id})").formats(@list_volume_attachments_format) do
|
||||
Fog::Compute[:hp].list_server_volumes(@server.id).body
|
||||
end
|
||||
|
||||
Fog::BlockStorage[:hp].delete_volume(@volume_id)
|
||||
@server.destroy
|
||||
|
||||
end
|
||||
|
||||
|
||||
tests('failure') do
|
||||
|
||||
tests("#list_server_volumes(#{@server.id})").raises(Fog::Compute::HP::NotFound) do
|
||||
Fog::Compute[:hp].list_server_volumes(@server.id)
|
||||
tests("#list_server_volumes(0)").raises(Fog::Compute::HP::NotFound) do
|
||||
Fog::Compute[:hp].list_server_volumes(0)
|
||||
end
|
||||
|
||||
tests("#attach_volume(#{@server.id}, 0, #{@device})").raises(Fog::Compute::HP::NotFound) do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:hp].attach_volume(@server.id, 0, @device)
|
||||
end
|
||||
|
||||
|
@ -58,6 +60,7 @@ Shindo.tests('Fog::Compute[:hp] | volume requests', ['hp', 'block_storage']) do
|
|||
end
|
||||
|
||||
tests("#detach_volume(#{@server.id}, 0)").raises(Fog::Compute::HP::NotFound) do
|
||||
pending if Fog.mocking?
|
||||
Fog::Compute[:hp].detach_volume(@server.id, 0)
|
||||
end
|
||||
|
||||
|
@ -67,4 +70,7 @@ Shindo.tests('Fog::Compute[:hp] | volume requests', ['hp', 'block_storage']) do
|
|||
|
||||
end
|
||||
|
||||
Fog::BlockStorage[:hp].delete_volume(@volume_id)
|
||||
Fog::Compute[:hp].delete_server(@server.id)
|
||||
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue