diff --git a/lib/fog/rackspace/models/compute_v2/server.rb b/lib/fog/rackspace/models/compute_v2/server.rb index 0feb5455b..4a8b5fdd2 100644 --- a/lib/fog/rackspace/models/compute_v2/server.rb +++ b/lib/fog/rackspace/models/compute_v2/server.rb @@ -145,8 +145,12 @@ module Fog ipv4_address end - def ready? - state == ACTIVE + def ready?(ready_state = ACTIVE, error_states=[ERROR]) + if error_states + error_states = Array(error_states) + raise "ERROR: Server is in error State '#{state}'" if error_states.include?(state) + end + state == ready_state end def reboot(type = 'SOFT') diff --git a/tests/rackspace/models/compute_v2/server_tests.rb b/tests/rackspace/models/compute_v2/server_tests.rb index 66a5721d6..ceb2ef29a 100644 --- a/tests/rackspace/models/compute_v2/server_tests.rb +++ b/tests/rackspace/models/compute_v2/server_tests.rb @@ -10,13 +10,14 @@ Shindo.tests('Fog::Compute::RackspaceV2 | server', ['rackspace']) do } model_tests(service.servers, options, false) do - @instance.wait_for { ready? } + @instance.wait_for(timeout=1500) { ready? } tests('#update').succeeds do @instance.name = "fog_server_update" @instance.access_ipv4_address= "10.10.0.1" @instance.access_ipv6_address= "0:0:0:0:0:0:0:1" @instance.save + sleep 60 @instance.reload returns("10.10.0.1") { @instance.access_ipv4_address } returns("0:0:0:0:0:0:0:1") { @instance.access_ipv6_address } @@ -34,33 +35,39 @@ Shindo.tests('Fog::Compute::RackspaceV2 | server', ['rackspace']) do returns('HARD_REBOOT') { @instance.state } end - @instance.wait_for(timeout=1500) { ready? } + sleep 30 + @instance.wait_for(timeout=1500) { ready? } + sleep 60 tests('#rebuild').succeeds do @instance.rebuild('5cebb13a-f783-4f8c-8058-c4182c724ccd') returns('REBUILD') { @instance.state } end + sleep 30 @instance.wait_for(timeout=1500) { ready? } + sleep 60 tests('#resize').succeeds do @instance.resize(3) returns('RESIZE') { @instance.state } end - @instance.wait_for(timeout=1500) do - raise "ERROR: Server is in ACTIVE state and it should be in VERIFY_RESIZE" if state == 'ACTIVE' - state == 'VERIFY_RESIZE' - end + sleep 30 + @instance.wait_for(timeout=1500) { ready?('VERIFY_RESIZE', ['ACTIVE', 'ERROR']) } + sleep 60 tests('#confirm_resize').succeeds do @instance.confirm_resize end + sleep 30 @instance.wait_for(timeout=1500) { ready? } + sleep 60 tests('#resize').succeeds do @instance.resize(2) returns('RESIZE') { @instance.state } end - @instance.wait_for(timeout=1500) { state == 'VERIFY_RESIZE' } + @instance.wait_for(timeout=1500) { ready?('VERIFY_RESIZE') } + sleep 60 tests('#revert_resize').succeeds do @instance.revert_resize end @@ -83,7 +90,8 @@ Shindo.tests('Fog::Compute::RackspaceV2 | server', ['rackspace']) do returns('RESIZE') { @instance.state } end - @instance.wait_for(timeout=1500) { state == 'VERIFY_RESIZE' } + @instance.wait_for(timeout=1500) { ready?('VERIFY_RESIZE') } + sleep 60 tests('#revert_resize').succeeds do @instance.revert_resize end diff --git a/tests/rackspace/requests/compute_v2/server_tests.rb b/tests/rackspace/requests/compute_v2/server_tests.rb index 889f5b5ae..fea3fc0dc 100644 --- a/tests/rackspace/requests/compute_v2/server_tests.rb +++ b/tests/rackspace/requests/compute_v2/server_tests.rb @@ -98,6 +98,7 @@ Shindo.tests('Fog::Compute::RackspaceV2 | server_tests', ['rackspace']) do service.rebuild_server(server_id, rebuild_image_id) end wait_for_server_state(service, server_id, 'ACTIVE', 'ERROR') + sleep 60 tests('#resize_server').succeeds do resize_flavor_id = 3 # 1GB