deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <di...@fast.au.fujitsu.com>
Subject [PATCH] Api-tests: wait for instances to leave PENDING state before continuing tests to resolve system reconfiguring failures on fgcp
Date Fri, 25 Jan 2013 07:41:02 GMT
From: Dies Koper <diesk@fast.au.fujitsu.com>

---
 tests/deltacloud/instances_test.rb | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/tests/deltacloud/instances_test.rb b/tests/deltacloud/instances_test.rb
index 9a0a060..19c4edc 100644
--- a/tests/deltacloud/instances_test.rb
+++ b/tests/deltacloud/instances_test.rb
@@ -33,6 +33,13 @@ describe 'Deltacloud API instances collection' do
     end
     @@my_instance_id = (res.xml/'instance')[0][:id]
     @@created_resources[:instances] << @@my_instance_id
+    #wait for it to come out of pending state so as to not affect
+    #subsequent tests (such as locked system for fgcp)
+    for attempts in 0..15
+      instance_xml = get(INSTANCES + '/' + @@my_instance_id).xml
+      break if /(RUNNING|STOPPED)/ =~ (instance_xml/'instance/state').text
+      sleep(10)
+    end
   end
 
   #stop/destroy the resources we created for the tests
@@ -182,6 +189,13 @@ puts "CLEANUP attempt finished... resources looks like: #{@@created_resources.in
     (res.xml/'instance/image').first[:id].must_equal image_id
     #mark it for stopping after tests run:
     @@created_resources[:instances] << created_instance_id
+    #wait for it to come out of pending state so as to not affect
+    #subsequent tests (such as locked system for fgcp)
+    for attempts in 0..15
+      break if /(RUNNING|STOPPED)/ =~ (res.xml/'instance/state').text
+      sleep(10)
+      instance_xml = get(INSTANCES + '/' + created_instance_id).xml
+    end
   end
 
   it 'should allow to create new instance using image and realm' do
@@ -202,6 +216,13 @@ puts "CLEANUP attempt finished... resources looks like: #{@@created_resources.in
     (res.xml/'instance/realm').first[:id].must_equal realm_id
     #mark it for stopping after tests run:
     @@created_resources[:instances] << created_instance_id
+    #wait for it to come out of pending state so as to not affect
+    #subsequent tests (such as locked system for fgcp)
+    for attempts in 0..15
+      break if /(RUNNING|STOPPED)/ =~ (res.xml/'instance/state').text
+      sleep(10)
+      instance_xml = get(INSTANCES + '/' + created_instance_id).xml
+    end
   end
 
   it 'should allow to create new instance using image, realm and hardware_profile' do
@@ -232,6 +253,13 @@ puts "CLEANUP attempt finished... resources looks like: #{@@created_resources.in
     (res.xml/'instance/hardware_profile').first[:id].must_equal hwp_id
     #mark it for stopping after tests run:
     @@created_resources[:instances] << created_instance_id
+    #wait for it to come out of pending state so as to not affect
+    #subsequent tests (such as locked system for fgcp)
+    for attempts in 0..15
+      break if /(RUNNING|STOPPED)/ =~ (res.xml/'instance/state').text
+      sleep(10)
+      instance_xml = get(INSTANCES + '/' + created_instance_id).xml
+    end
   end
 
 #snapshot (make image)
-- 
1.8.0.msysgit.0



Mime
View raw message