You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by mf...@apache.org on 2013/02/27 20:38:46 UTC

[1/2] git commit: Deltacloud - Tests - adding testpoint for creating an image from a stopped instance - if supported

Deltacloud - Tests - adding testpoint for creating an image from a stopped instance - if supported

TrackedAt: http://tracker.deltacloud.org/patch/7f7d5800cbdfe3f288da30cb0050166c3a86b047


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/a4e196e4
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/a4e196e4
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/a4e196e4

Branch: refs/heads/master
Commit: a4e196e47ab6f4e537911e119b11665c3984ab81
Parents: a8d19ea
Author: Ronelle Landy <rl...@redhat.com>
Authored: Tue Feb 26 17:55:07 2013 -0500
Committer: Michal fojtik <mf...@redhat.com>
Committed: Wed Feb 27 20:35:52 2013 +0100

----------------------------------------------------------------------
 tests/deltacloud/instances_test.rb |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a4e196e4/tests/deltacloud/instances_test.rb
----------------------------------------------------------------------
diff --git a/tests/deltacloud/instances_test.rb b/tests/deltacloud/instances_test.rb
index 7395062..0edf359 100644
--- a/tests/deltacloud/instances_test.rb
+++ b/tests/deltacloud/instances_test.rb
@@ -295,6 +295,13 @@ puts "CLEANUP attempt finished... resources looks like: #{@@created_resources.in
     (res.xml/'instance/state').text.must_match /RUNNING/
     #check if created instance allows creating image
     instance_actions = (res.xml/'actions/link').to_a.inject([]){|actions, current| actions << current[:rel]; actions}
+    #check if the create_image action is available for stopped instances
+    unless instance_actions.include?("create_image")
+      stop_res = post(INSTANCES+"/"+@@my_instance_id+"/stop", "")
+      res = get(INSTANCES+"/"+@@my_instance_id)
+      wait_until_running_or_stopped(res, @@my_instance_id)
+      instance_actions = (res.xml/'actions/link').to_a.inject([]){|actions, current| actions << current[:rel]; actions}
+    end
     skip "no create image support for instance #{@@my_instance_id}" unless instance_actions.include?("create_image")
     #create image
     res = post("/images", :instance_id => @@my_instance_id, :name => random_name)
@@ -302,7 +309,15 @@ puts "CLEANUP attempt finished... resources looks like: #{@@created_resources.in
     my_image_id = (res.xml/'image')[0][:id]
     #mark for deletion later:
     @@created_resources[:images] << my_image_id
+    res = get(INSTANCES+"/"+@@my_instance_id)
+    #start instance if it was stopped
+    if (res.xml/'instance/state').text  == "STOPPED"
+      start_res = post(INSTANCES+"/"+@@my_instance_id+"/start", "")
+      res = get(INSTANCES+"/"+@@my_instance_id)
+      wait_until_running_or_stopped(res, @@my_instance_id)
+    end
   end
+
 #
 #create with key