You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by rl...@redhat.com on 2013/04/04 19:19:47 UTC

CIMI - Tests - modfiying test_helper.rb cleanup code to work with Openstack provider

With this patch, all machex*_test.rb and rmd*_test.rb in deltacloud/tests/cimi should pass, when run against the mock and Openstack providers.


[PATCH] CIMI - Tests - modfiying test_helper.rb cleanup code to work with Openstack provider

Posted by rl...@redhat.com.
From: Ronelle Landy <rl...@redhat.com>

---
 tests/cimi/test_helper.rb | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/tests/cimi/test_helper.rb b/tests/cimi/test_helper.rb
index 5cfceb6..19f0b2c 100644
--- a/tests/cimi/test_helper.rb
+++ b/tests/cimi/test_helper.rb
@@ -346,17 +346,24 @@ module CIMI::Test::Methods
             machine = get(machine.json["id"], :accept => :json)
           end
 
-          while not machine.json["state"].upcase.eql?("STOPPED")
+          cep_json = cep(:accept => :json)
+          while (get(cep_json.json["machines"]["href"], {:accept=>:json}).include?(machine.json["id"]) && (not machine.json["state"].upcase.eql?("STOPPED"))
             puts 'waiting for machine to be STOPPED'
-            sleep(1)
-            machine = get(machine.json["id"], :accept => :json)
+            sleep(3)
+            unless (not get(cep_json.json["machines"]["href"], {:accept=>:json}).include?(machine.json["id"]))
+              machine = get(machine.json["id"], :accept => :json)
+            end
           end
 
-          delete_op = machine.json["operations"].find { |op| op["rel"] =~ /delete$/ }
-          if delete_op
-            delete_res = RestClient.delete( delete_op["href"],
-                {'Authorization' => api_basic_auth, :accept => :json} )
-            @@created_resources[:machines][i] = nil if (200..207).include? delete_res.code
+          if get(cep_json.json["machines"]["href"], {:accept=>:json}).include?(machine.json["id"])
+            delete_op = machine.json["operations"].find { |op| op["rel"] =~ /delete$/ }
+            if delete_op
+              delete_res = RestClient.delete( delete_op["href"],
+                  {'Authorization' => api_basic_auth, :accept => :json} )
+              @@created_resources[:machines][i] = nil if (200..207).include? delete_res.code
+            end
+          else
+            @@created_resources[:machines][i] = nil
           end
         end
 
-- 
1.8.1.4