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:
parent
54f1c92184
commit
42f2d81455
5 changed files with 71 additions and 1 deletions
|
@ -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 => {
|
||||
|
|
18
tests/compute/models/volume_tests.rb
Normal file
18
tests/compute/models/volume_tests.rb
Normal 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
|
10
tests/compute/models/volumes_tests.rb
Normal file
10
tests/compute/models/volumes_tests.rb
Normal 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
|
22
tests/helpers/compute/volume_helper.rb
Normal file
22
tests/helpers/compute/volume_helper.rb
Normal 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
|
11
tests/helpers/compute/volumes_helper.rb
Normal file
11
tests/helpers/compute/volumes_helper.rb
Normal 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
|
Loading…
Reference in a new issue