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

[rackspace] setting default fog timeout to 2000 for testing; removing specific hard coded timeouts.

This commit is contained in:
Kyle Rames 2013-06-26 09:31:00 -05:00
parent 604b4a625f
commit bb7b39afd6
6 changed files with 32 additions and 26 deletions

View file

@ -1,6 +1,11 @@
module Shindo module Shindo
class Tests class Tests
unless Fog.mocking?
Fog.timeout = 2000
Fog::Logger.warning "Setting default fog timeout to #{Fog.timeout} seconds"
end
def given_a_load_balancer_service(&block) def given_a_load_balancer_service(&block)
@service = Fog::Rackspace::LoadBalancers.new @service = Fog::Rackspace::LoadBalancers.new
instance_eval(&block) instance_eval(&block)

View file

@ -4,7 +4,7 @@ Shindo.tests('Fog::Rackspace::BlockStorage | volume', ['rackspace']) do
options = { :display_name => "fog_#{Time.now.to_i.to_s}", :size => 100 } options = { :display_name => "fog_#{Time.now.to_i.to_s}", :size => 100 }
model_tests(service.volumes, options, true) do model_tests(service.volumes, options, true) do
@instance.wait_for(timeout=1200) { ready? } @instance.wait_for{ ready? }
tests('double save').raises(Fog::Rackspace::BlockStorage::IdentifierTaken) do tests('double save').raises(Fog::Rackspace::BlockStorage::IdentifierTaken) do
@instance.save @instance.save
@ -18,7 +18,7 @@ Shindo.tests('Fog::Rackspace::BlockStorage | volume', ['rackspace']) do
tests('#snapshots').succeeds do tests('#snapshots').succeeds do
begin begin
snapshot = @instance.create_snapshot snapshot = @instance.create_snapshot
snapshot.wait_for(timeout=1200) { ready? } snapshot.wait_for { ready? }
returns(true) { @instance.snapshots.first.id == snapshot.id } returns(true) { @instance.snapshots.first.id == snapshot.id }
ensure ensure

View file

@ -11,7 +11,7 @@ Shindo.tests('Fog::Compute::RackspaceV2 | metadata', ['rackspace']) do
:flavor_id => rackspace_test_flavor_id(service), :flavor_id => rackspace_test_flavor_id(service),
:image_id => rackspace_test_image_id(service)) :image_id => rackspace_test_image_id(service))
@server.wait_for(timeout=1500) { ready? } @server.wait_for { ready? }
tests('server') do tests('server') do
collection_tests(@server.metadata, {:key => 'my_key', :value => 'my_value'}) do collection_tests(@server.metadata, {:key => 'my_key', :value => 'my_value'}) do
@ -21,7 +21,7 @@ Shindo.tests('Fog::Compute::RackspaceV2 | metadata', ['rackspace']) do
tests('image') do tests('image') do
@image = @server.create_image("fog_image_#{test_time}", :metadata => {:my_key => 'my_value'}) @image = @server.create_image("fog_image_#{test_time}", :metadata => {:my_key => 'my_value'})
@image.wait_for(timeout = 1500) { ready? } @image.wait_for { ready? }
tests("#all").succeeds do tests("#all").succeeds do
pending if Fog.mocking? && !mocks_implemented pending if Fog.mocking? && !mocks_implemented
metadata = @image.metadata.all metadata = @image.metadata.all

View file

@ -66,7 +66,7 @@ Shindo.tests('Fog::Compute::RackspaceV2 | server', ['rackspace']) do
end end
model_tests(service.servers, options, true) do model_tests(service.servers, options, true) do
@instance.wait_for(timeout=1500) { ready? } @instance.wait_for { ready? }
tests('#metadata[\'fog_test\']').returns('true') do tests('#metadata[\'fog_test\']').returns('true') do
@instance.metadata['fog_test'] @instance.metadata['fog_test']
@ -93,13 +93,13 @@ Shindo.tests('Fog::Compute::RackspaceV2 | server', ['rackspace']) do
returns('REBOOT') { @instance.state } returns('REBOOT') { @instance.state }
end end
@instance.wait_for(timeout=1500) { ready? } @instance.wait_for { ready? }
tests('#reboot("HARD")').succeeds do tests('#reboot("HARD")').succeeds do
@instance.reboot('HARD') @instance.reboot('HARD')
returns('HARD_REBOOT') { @instance.state } returns('HARD_REBOOT') { @instance.state }
end end
@instance.wait_for(timeout=1500) { ready? } @instance.wait_for { ready? }
@test_image = nil @test_image = nil
begin begin
tests('#create_image').succeeds do tests('#create_image').succeeds do
@ -112,7 +112,7 @@ Shindo.tests('Fog::Compute::RackspaceV2 | server', ['rackspace']) do
end end
sleep 30 unless Fog.mocking? sleep 30 unless Fog.mocking?
@instance.wait_for(timeout=1500) { ready? } @instance.wait_for { ready? }
sleep 60 unless Fog.mocking? sleep 60 unless Fog.mocking?
tests('#rebuild').succeeds do tests('#rebuild').succeeds do
@instance.rebuild rackspace_test_image_id(service) @instance.rebuild rackspace_test_image_id(service)
@ -120,7 +120,7 @@ Shindo.tests('Fog::Compute::RackspaceV2 | server', ['rackspace']) do
end end
sleep 30 unless Fog.mocking? sleep 30 unless Fog.mocking?
@instance.wait_for(timeout=1500) { ready? } @instance.wait_for { ready? }
sleep 60 unless Fog.mocking? sleep 60 unless Fog.mocking?
tests('#resize').succeeds do tests('#resize').succeeds do
@instance.resize(3) @instance.resize(3)
@ -128,37 +128,37 @@ Shindo.tests('Fog::Compute::RackspaceV2 | server', ['rackspace']) do
end end
sleep 30 unless Fog.mocking? sleep 30 unless Fog.mocking?
@instance.wait_for(timeout=1500) { ready?('VERIFY_RESIZE', ['ACTIVE', 'ERROR']) } @instance.wait_for { ready?('VERIFY_RESIZE', ['ACTIVE', 'ERROR']) }
sleep 60 unless Fog.mocking? sleep 60 unless Fog.mocking?
tests('#confirm_resize').succeeds do tests('#confirm_resize').succeeds do
@instance.confirm_resize @instance.confirm_resize
end end
sleep 30 unless Fog.mocking? sleep 30 unless Fog.mocking?
@instance.wait_for(timeout=1500) { ready? } @instance.wait_for { ready? }
sleep 60 unless Fog.mocking? sleep 60 unless Fog.mocking?
tests('#resize').succeeds do tests('#resize').succeeds do
@instance.resize(2) @instance.resize(2)
returns('RESIZE') { @instance.state } returns('RESIZE') { @instance.state }
end end
@instance.wait_for(timeout=1500) { ready?('VERIFY_RESIZE') } @instance.wait_for { ready?('VERIFY_RESIZE') }
sleep 60 unless Fog.mocking? sleep 60 unless Fog.mocking?
tests('#revert_resize').succeeds do tests('#revert_resize').succeeds do
@instance.revert_resize @instance.revert_resize
end end
@instance.wait_for(timeout=1500) { ready? } @instance.wait_for { ready? }
tests('#rescue').succeeds do tests('#rescue').succeeds do
@instance.rescue @instance.rescue
end end
@instance.wait_for(timeout=1500) { ready?('RESCUE') } @instance.wait_for { ready?('RESCUE') }
tests('#unrescue').succeeds do tests('#unrescue').succeeds do
@instance.unrescue @instance.unrescue
end end
@instance.wait_for(timeout=1500) { ready? } @instance.wait_for { ready? }
tests('#change_admin_password').succeeds do tests('#change_admin_password').succeeds do
@instance.change_admin_password('somerandompassword') @instance.change_admin_password('somerandompassword')
returns('PASSWORD') { @instance.state } returns('PASSWORD') { @instance.state }
@ -168,28 +168,29 @@ Shindo.tests('Fog::Compute::RackspaceV2 | server', ['rackspace']) do
tests('attachments') do tests('attachments') do
begin begin
@volume = cbs_service.volumes.create(:size => 100, :display_name => "fog-#{Time.now.to_i.to_s}") @volume = cbs_service.volumes.create(:size => 100, :display_name => "fog-#{Time.now.to_i.to_s}")
@volume.wait_for(timeout=1500) { ready? } @volume.wait_for { ready? }
tests('#attach_volume').succeeds do tests('#attach_volume').succeeds do
@instance.attach_volume(@volume) @instance.attach_volume(@volume)
end end
tests('#attachments').returns(true) do tests('#attachments').returns(true) do
@instance.wait_for(timeout=1500) do @instance.wait_for do
!attachments.empty? !attachments.empty?
end end
@instance.attachments.any? {|a| a.volume_id == @volume.id } @instance.attachments.any? {|a| a.volume_id == @volume.id }
end end
ensure ensure
@volume.wait_for(timeout=1500) { !attachments.empty? } @volume.wait_for { !attachments.empty? }
@instance.attachments.each {|a| a.detach } @instance.attachments.each {|a| a.detach }
@volume.wait_for(timeout=1500) { ready? && attachments.empty? } @volume.wait_for { ready? && attachments.empty? }
@volume.destroy if @volume @volume.destroy if @volume
end end
end end
@instance.wait_for(timeout=1500) { ready? } @instance.wait_for { ready? }
end end
wait_for_server_deletion(@instance) wait_for_server_deletion(@instance)
sleep 60 unless Fog.mocking?
tests("delete network #{@network.label}").succeeds do tests("delete network #{@network.label}").succeeds do
@network.destroy if @network @network.destroy if @network
@ -197,17 +198,17 @@ Shindo.tests('Fog::Compute::RackspaceV2 | server', ['rackspace']) do
#When after testing resize/resize_confirm we get a 409 when we try to resize_revert so I am going to split it into two blocks #When after testing resize/resize_confirm we get a 409 when we try to resize_revert so I am going to split it into two blocks
model_tests(service.servers, options, true) do model_tests(service.servers, options, true) do
@instance.wait_for(timeout=1500) { ready? } @instance.wait_for { ready? }
tests('#resize').succeeds do tests('#resize').succeeds do
@instance.resize(4) @instance.resize(4)
returns('RESIZE') { @instance.state } returns('RESIZE') { @instance.state }
end end
@instance.wait_for(timeout=1500) { ready?('VERIFY_RESIZE') } @instance.wait_for { ready?('VERIFY_RESIZE') }
sleep 60 unless Fog.mocking? sleep 60 unless Fog.mocking?
tests('#revert_resize').succeeds do tests('#revert_resize').succeeds do
@instance.revert_resize @instance.revert_resize
end end
@instance.wait_for(timeout=1500) { ready? } @instance.wait_for { ready? }
end end
end end

View file

@ -5,7 +5,7 @@ Shindo.tests('Fog::Compute::RackspaceV2 | address requests', ['rackspace']) do
tests('success') do tests('success') do
unless Fog.mocking? unless Fog.mocking?
@server = @service.servers.create(:flavor_id => 2, :image_id => "8a3a9f96-b997-46fd-b7a8-a9e740796ffd", :name => "address-tests-#{Time.now.to_i}") @server = @service.servers.create(:flavor_id => 2, :image_id => "8a3a9f96-b997-46fd-b7a8-a9e740796ffd", :name => "address-tests-#{Time.now.to_i}")
@server.wait_for(timeout=1200) { ready? } @server.wait_for { ready? }
@server_id = @server.id @server_id = @server.id
else else
@server_id = 42 @server_id = 42

View file

@ -12,7 +12,7 @@ Shindo.tests('Fog::Compute::RackspaceV2 | metadata_tests', ['rackspace']) do
:flavor_id => 2, :flavor_id => 2,
:image_id => '3afe97b2-26dc-49c5-a2cc-a2fc8d80c001', :image_id => '3afe97b2-26dc-49c5-a2cc-a2fc8d80c001',
:metadata => metadata) :metadata => metadata)
@server.wait_for(timeout = 1500) { ready? } @server.wait_for { ready? }
@server_id = @server.id @server_id = @server.id