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" =>
|
resp_data = { "volumeAttachment" =>
|
||||||
{
|
{
|
||||||
"volumeId" => volume_id,
|
"volumeId" => volume_id,
|
||||||
"device" => device
|
"id" => volume_id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
response.body = resp_data
|
response.body = resp_data
|
||||||
response.status = 200
|
response.status = 200
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
"device" => device,
|
"device" => device,
|
||||||
"serverId" => server_id,
|
"serverId" => server_id,
|
||||||
"id" => volume_id,
|
"id" => volume_id,
|
||||||
"volumeId" => volume_id,
|
"volumeId" => volume_id,
|
||||||
}
|
}
|
||||||
if server['volumeAttachments']
|
if server['volumeAttachments']
|
||||||
|
|
|
@ -16,7 +16,7 @@ Shindo.tests('Fog::BlockStorage[:hp] | volume requests', ['hp', 'block_storage']
|
||||||
|
|
||||||
@volume_attach_format = {
|
@volume_attach_format = {
|
||||||
"volumeId" => Integer,
|
"volumeId" => Integer,
|
||||||
"device" => String
|
"id" => Integer
|
||||||
}
|
}
|
||||||
|
|
||||||
tests('success') do
|
tests('success') do
|
||||||
|
@ -26,10 +26,8 @@ Shindo.tests('Fog::BlockStorage[:hp] | volume requests', ['hp', 'block_storage']
|
||||||
@volume_desc = @volume_name + " desc"
|
@volume_desc = @volume_name + " desc"
|
||||||
@base_image_id = ENV["BASE_IMAGE_ID"] || 1242
|
@base_image_id = ENV["BASE_IMAGE_ID"] || 1242
|
||||||
|
|
||||||
#before do
|
@server = Fog::BlockStorage[:hp].compute.servers.create(:name => 'fogvoltests', :flavor_id => 100, :image_id => @base_image_id)
|
||||||
# @server = Fog::Compute[:hp].servers.create(:name => 'fogvoltests', :flavor_id => 100, :image_id => @base_image_id)
|
@server.wait_for { ready? }
|
||||||
# @server.wait_for { ready? }
|
|
||||||
#end
|
|
||||||
|
|
||||||
tests("#create_volume(#{@volume_name}, #{@volume_desc}, 1)").formats(@volume_format) do
|
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']
|
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
|
Fog::BlockStorage[:hp].list_volumes.body
|
||||||
end
|
end
|
||||||
|
|
||||||
@server = Fog::Compute[:hp].servers.create(:name => 'fogvoltests', :flavor_id => 100, :image_id => @base_image_id)
|
Fog::BlockStorage[:hp].volumes.get(@volume_id).wait_for { ready? }
|
||||||
@server.wait_for { ready? }
|
|
||||||
tests("#attach_volume(#{@server.id}, #{@volume_id}, '/dev/sdg')").formats(@volume_attach_format) do
|
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']
|
Fog::BlockStorage[:hp].compute.attach_volume(@server.id, @volume_id, "/dev/sdg").body['volumeAttachment']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Fog::BlockStorage[:hp].volumes.get(@volume_id).wait_for { in_use? } unless Fog.mocking?
|
||||||
tests("#detach_volume(#{@server.id}, #{@volume_id})").succeeds do
|
tests("#detach_volume(#{@server.id}, #{@volume_id})").succeeds do
|
||||||
Fog::BlockStorage[:hp].compute.detach_volume(@server.id, @volume_id)
|
Fog::BlockStorage[:hp].compute.detach_volume(@server.id, @volume_id)
|
||||||
end
|
end
|
||||||
@server.destroy
|
|
||||||
|
|
||||||
Fog::BlockStorage[:hp].volumes.get(@volume_id).wait_for { ready? }
|
Fog::BlockStorage[:hp].volumes.get(@volume_id).wait_for { ready? }
|
||||||
tests("#delete_volume(#{@volume_id})").succeeds do
|
tests("#delete_volume(#{@volume_id})").succeeds do
|
||||||
Fog::BlockStorage[:hp].delete_volume(@volume_id)
|
Fog::BlockStorage[:hp].delete_volume(@volume_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
#after do
|
|
||||||
# @server.destroy
|
|
||||||
#end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
tests('failure') do
|
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
|
tests("#attach_volume(0, 0, '/dev/sdg')").raises(Fog::Compute::HP::NotFound) do
|
||||||
Fog::BlockStorage[:hp].compute.attach_volume(0, 0, "/dev/sdg")
|
Fog::BlockStorage[:hp].compute.attach_volume(0, 0, "/dev/sdg")
|
||||||
end
|
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?
|
pending if Fog.mocking?
|
||||||
Fog::BlockStorage[:hp].compute.attach_volume(@server.id, 0, "/dev/sdg")
|
Fog::BlockStorage[:hp].compute.attach_volume(@server.id, 0, "/dev/sdg")
|
||||||
end
|
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
|
tests("#detach_volume(0, 0)").raises(Fog::Compute::HP::NotFound) do
|
||||||
Fog::BlockStorage[:hp].compute.detach_volume(0, 0)
|
Fog::BlockStorage[:hp].compute.detach_volume(0, 0)
|
||||||
end
|
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?
|
pending if Fog.mocking?
|
||||||
Fog::BlockStorage[:hp].compute.detach_volume(@server.id, 0)
|
Fog::BlockStorage[:hp].compute.detach_volume(@server.id, 0)
|
||||||
end
|
end
|
||||||
|
@ -95,4 +89,6 @@ Shindo.tests('Fog::BlockStorage[:hp] | volume requests', ['hp', 'block_storage']
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@server.destroy
|
||||||
|
|
||||||
end
|
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 = {
|
@list_volume_attachments_format = {
|
||||||
'volumeAttachments' => [{
|
'volumeAttachments' => [{
|
||||||
|
@ -11,45 +11,47 @@ Shindo.tests('Fog::Compute[:hp] | volume requests', ['hp', 'block_storage']) do
|
||||||
|
|
||||||
@volume_attachment_format = {
|
@volume_attachment_format = {
|
||||||
'volumeAttachment' => {
|
'volumeAttachment' => {
|
||||||
'device' => String,
|
"volumeId" => Integer,
|
||||||
'volumeId' => Integer
|
"id" => Integer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@base_image_id = ENV["BASE_IMAGE_ID"] || 1242
|
@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
|
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)
|
response = Fog::BlockStorage[:hp].create_volume('fogvoltest', 'fogvoltest desc', 1)
|
||||||
@volume_id = response.body['volume']['id']
|
@volume_id = response.body['volume']['id']
|
||||||
@device = "\/dev\/sdf"
|
@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
|
tests("#attach_volume(#{@server.id}, #{@volume_id}, #{@device}").formats(@volume_attachment_format) do
|
||||||
Fog::Compute[:hp].attach_volume(@server.id, @volume_id, @device).body
|
Fog::Compute[:hp].attach_volume(@server.id, @volume_id, @device).body
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Fog::BlockStorage[:hp].volumes.get(@volume_id).wait_for { in_use? } unless Fog.mocking?
|
||||||
tests("#detach_volume(#{@server.id}, #{@volume_id}").succeeds do
|
tests("#detach_volume(#{@server.id}, #{@volume_id}").succeeds do
|
||||||
Fog::Compute[:hp].detach_volume(@server.id, @volume_id)
|
Fog::Compute[:hp].detach_volume(@server.id, @volume_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Fog::BlockStorage[:hp].volumes.get(@volume_id).wait_for { ready? }
|
||||||
tests("#list_server_volumes(#{@server.id})").formats(@list_volume_attachments_format) do
|
tests("#list_server_volumes(#{@server.id})").formats(@list_volume_attachments_format) do
|
||||||
Fog::Compute[:hp].list_server_volumes(@server.id).body
|
Fog::Compute[:hp].list_server_volumes(@server.id).body
|
||||||
end
|
end
|
||||||
|
|
||||||
Fog::BlockStorage[:hp].delete_volume(@volume_id)
|
|
||||||
@server.destroy
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
tests('failure') do
|
tests('failure') do
|
||||||
|
|
||||||
tests("#list_server_volumes(#{@server.id})").raises(Fog::Compute::HP::NotFound) do
|
tests("#list_server_volumes(0)").raises(Fog::Compute::HP::NotFound) do
|
||||||
Fog::Compute[:hp].list_server_volumes(@server.id)
|
Fog::Compute[:hp].list_server_volumes(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
tests("#attach_volume(#{@server.id}, 0, #{@device})").raises(Fog::Compute::HP::NotFound) do
|
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)
|
Fog::Compute[:hp].attach_volume(@server.id, 0, @device)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -58,6 +60,7 @@ Shindo.tests('Fog::Compute[:hp] | volume requests', ['hp', 'block_storage']) do
|
||||||
end
|
end
|
||||||
|
|
||||||
tests("#detach_volume(#{@server.id}, 0)").raises(Fog::Compute::HP::NotFound) do
|
tests("#detach_volume(#{@server.id}, 0)").raises(Fog::Compute::HP::NotFound) do
|
||||||
|
pending if Fog.mocking?
|
||||||
Fog::Compute[:hp].detach_volume(@server.id, 0)
|
Fog::Compute[:hp].detach_volume(@server.id, 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -67,4 +70,7 @@ Shindo.tests('Fog::Compute[:hp] | volume requests', ['hp', 'block_storage']) do
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Fog::BlockStorage[:hp].delete_volume(@volume_id)
|
||||||
|
Fog::Compute[:hp].delete_server(@server.id)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue