1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[compute] volume tests

This commit is contained in:
Josh Lane & Jason Hansen 2012-05-22 16:52:17 -07:00
parent 54f1c92184
commit 42f2d81455
5 changed files with 71 additions and 1 deletions

View file

@ -24,7 +24,16 @@ def compute_providers
:provider_attributes => {
:cloudstack_host => 'http://host.foo'
},
:server_attributes => Fog.credentials[:cloudstack],
:server_attributes => {}.tap do |hash|
[:zone_id, :network_ids, :image_id, :flavor_id].each do |k|
hash[k]= Fog.credentials[:cloudstack][k]
end
end,
:volume_attributes => {:name => "somevolume"}.tap do |hash|
[:zone_id, :disk_offering_id].each do |k|
hash[k]= Fog.credentials[:cloudstack][k]
end
end,
:mocked => true
},
:glesys => {

View file

@ -0,0 +1,18 @@
for provider, config in compute_providers
Shindo.tests("Fog::Compute[:#{provider}] | volume", [provider.to_s]) do
volume_tests(Fog::Compute[provider], config, config[:mocked]) do
if Fog.mocking? && !config[:mocked]
pending
else
responds_to(:ready?)
responds_to(:flavor)
end
end
end
end

View file

@ -0,0 +1,10 @@
for provider, config in compute_providers
Shindo.tests("Fog::Compute[:#{provider}] | volumes", [provider.to_s]) do
volumes_tests(Fog::Compute[provider], (config[:volume_attributes] || {}), config[:mocked])
end
end

View file

@ -0,0 +1,22 @@
def volume_tests(connection, params = {}, mocks_implemented = true)
model_tests(connection.volumes, params[:volume_attributes], mocks_implemented) do
if !Fog.mocking? || mocks_implemented
@instance.wait_for { ready? }
end
@server = connection.servers.create(params[:server_attributes])
@server.wait_for { ready? }
tests('attach').succeeds do
@instance.attach(@server)
end
tests('detach').succeeds do
@instance.detach
end
@server.destroy
end
end

View file

@ -0,0 +1,11 @@
def volumes_tests(connection, params = {}, mocks_implemented = true)
collection_tests(connection.volumes, params, mocks_implemented) do
if !Fog.mocking? || mocks_implemented
@instance.wait_for { ready? }
end
end
end