mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Add tests for addresses and floating ips.
This commit is contained in:
parent
4f9350af56
commit
241a74aa8c
2 changed files with 98 additions and 0 deletions
|
@ -0,0 +1,58 @@
|
|||
Shindo.tests('Fog::Compute[:hp] | address requests', ['hp']) do
|
||||
|
||||
@floating_ips_format = {
|
||||
'instance_id' => Fog::Nullable::Integer,
|
||||
'ip' => Fog::Nullable::String,
|
||||
'fixed_ip' => Fog::Nullable::String,
|
||||
'id' => Integer
|
||||
}
|
||||
|
||||
tests('success') do
|
||||
|
||||
tests("#list_addresses").formats({'floating_ips' => [@floating_ips_format]}) do
|
||||
Fog::Compute[:hp].list_addresses.body
|
||||
end
|
||||
|
||||
tests("#allocate_address").formats(@floating_ips_format) do
|
||||
data = Fog::Compute[:hp].allocate_address.body['floating_ip']
|
||||
@address_id = data['id']
|
||||
@ip_address = data['ip']
|
||||
data
|
||||
end
|
||||
|
||||
@server = Fog::Compute[:hp].servers.create(:name => 'fogaddresstests', :flavor_id => 100, :image_id => 1242)
|
||||
@server.wait_for { ready? }
|
||||
|
||||
tests("#associate_address('#{@server.id}', '#{@ip_address}')").succeeds do
|
||||
Fog::Compute[:hp].associate_address(@server.id, @ip_address)
|
||||
end
|
||||
|
||||
tests("#disassociate_address('#{@server.id}', '#{@ip_address}')").succeeds do
|
||||
Fog::Compute[:hp].disassociate_address(@server.id, @ip_address)
|
||||
end
|
||||
|
||||
@server.destroy
|
||||
|
||||
tests("#release_address('#{@address_id}')").succeeds do
|
||||
Fog::Compute[:hp].release_address(@address_id)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
|
||||
tests("#associate_address('invalidserver', 'invalidip')").raises(Fog::Compute::HP::NotFound) do
|
||||
Fog::Compute[:hp].associate_address('invalidserver', 'invalidip')
|
||||
end
|
||||
|
||||
tests("#disassociate_address('invalidserver', 'invalidip')").raises(Fog::Compute::HP::NotFound) do
|
||||
Fog::Compute[:hp].disassociate_address('invalidserver', 'invalidip')
|
||||
end
|
||||
|
||||
tests("#release_address('invalidip')").raises(Fog::Compute::HP::NotFound) do
|
||||
Fog::Compute[:hp].release_address('invalidip')
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
40
tests/hp/requests/compute/server_address_tests.rb
Normal file
40
tests/hp/requests/compute/server_address_tests.rb
Normal file
|
@ -0,0 +1,40 @@
|
|||
Shindo.tests('Fog::Compute[:hp] | address requests', ['hp']) do
|
||||
|
||||
tests('success') do
|
||||
@server = Fog::Compute[:hp].servers.create(:name => 'fogaddresstests', :flavor_id => 100, :image_id => 1242)
|
||||
|
||||
# the network name is currently named 'private'
|
||||
tests("#list_server_addresses(#{@server.id})").formats({'addresses' => {"private" => [Hash]}}) do
|
||||
Fog::Compute[:hp].list_server_addresses(@server.id).body
|
||||
end
|
||||
|
||||
tests("#list_server_private_addresses(#{@server.id}, 'private')").formats({'private' => [Hash]}) do
|
||||
Fog::Compute[:hp].list_server_private_addresses(@server.id, 'private').body
|
||||
end
|
||||
|
||||
tests("#list_server_public_addresses(#{@server.id}, 'private')").formats({'public' => [Hash]}) do
|
||||
Fog::Compute[:hp].list_server_public_addresses(@server.id, 'private').body
|
||||
end
|
||||
|
||||
@server.wait_for { ready? }
|
||||
@server.destroy
|
||||
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
|
||||
tests("#list_server_addresses(0)").raises(Fog::Compute::HP::NotFound) do
|
||||
Fog::Compute[:hp].list_server_addresses(0)
|
||||
end
|
||||
|
||||
tests("#list_server_private_addresses(0, 'private')").raises(Fog::Compute::HP::NotFound) do
|
||||
Fog::Compute[:hp].list_server_private_addresses(0, 'private')
|
||||
end
|
||||
|
||||
tests("#list_server_public_addresses(0, 'private')").raises(Fog::Compute::HP::NotFound) do
|
||||
Fog::Compute[:hp].list_server_public_addresses(0, 'private')
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
Loading…
Add table
Reference in a new issue