deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject [3/13] git commit: Core: Moved wait_for! method to test_helper
Date Tue, 24 Jul 2012 07:39:47 GMT
Core: Moved wait_for! method to test_helper


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

Branch: refs/heads/master
Commit: 9a0601b129aa09078427824460c0465742a3a486
Parents: 3e9b13a
Author: Michal Fojtik <mfojtik@redhat.com>
Authored: Tue Jul 24 09:34:40 2012 +0200
Committer: Michal fojtik <mfojtik@redhat.com>
Committed: Tue Jul 24 09:38:05 2012 +0200

----------------------------------------------------------------------
 server/lib/deltacloud/models/instance.rb |   35 -----------------------
 server/tests/drivers/ec2/common.rb       |   37 +++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/9a0601b1/server/lib/deltacloud/models/instance.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/models/instance.rb b/server/lib/deltacloud/models/instance.rb
index 9bf9f4a..421b4ef 100644
--- a/server/lib/deltacloud/models/instance.rb
+++ b/server/lib/deltacloud/models/instance.rb
@@ -77,39 +77,4 @@ class Instance < BaseModel
     return true unless authn_error.nil?
   end
 
-  # This method will pool the instance until condition is true
-  # Will raise 'Timeout' when it reach retry count
-  #
-  # default opts[:retries] => 10
-  # default opts[:time_between_retry] => 10 (seconds)
-  # default opts[:timeout] => 60 (seconds) -> single request timeout
-  #
-  # opts[:before] => Proc -> executed 'before' making each request
-  # opts[:after] => Proc -> executed 'after' making each request
-  #
-  def wait_for!(driver, opts={}, &block)
-    opts[:retries] ||= 10
-    opts[:time_between_retry] ||= 10
-    opts[:timeout] ||= 60
-    opts[:retries].downto(0) do |r|
-      result = begin
-        timeout(opts[:timeout]) do
-          if opts[:before]
-            new_instance = opts[:before].call(r) { driver.instance(:id => self.id) }
-          else
-            new_instance = driver.instance(:id => self.id)
-          end
-          ((yield new_instance) == true) ? new_instance : false
-        end
-      rescue Timeout::Error
-        false
-      ensure
-        opts[:after].call(r) if opts[:after]
-      end
-      return result unless result == false
-      sleep(opts[:time_between_retry])
-    end
-    raise Timeout::Error
-  end
-
 end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/9a0601b1/server/tests/drivers/ec2/common.rb
----------------------------------------------------------------------
diff --git a/server/tests/drivers/ec2/common.rb b/server/tests/drivers/ec2/common.rb
index 08baed1..5434c61 100644
--- a/server/tests/drivers/ec2/common.rb
+++ b/server/tests/drivers/ec2/common.rb
@@ -35,6 +35,43 @@ class Time
   end
 end
 
+class Instance
+  # This method will pool the instance until condition is true
+  # Will raise 'Timeout' when it reach retry count
+  #
+  # default opts[:retries] => 10
+  # default opts[:time_between_retry] => 10 (seconds)
+  # default opts[:timeout] => 60 (seconds) -> single request timeout
+  #
+  # opts[:before] => Proc -> executed 'before' making each request
+  # opts[:after] => Proc -> executed 'after' making each request
+  #
+  def wait_for!(driver, opts={}, &block)
+    opts[:retries] ||= 10
+    opts[:time_between_retry] ||= 10
+    opts[:timeout] ||= 60
+    opts[:retries].downto(0) do |r|
+      result = begin
+        timeout(opts[:timeout]) do
+          if opts[:before]
+            new_instance = opts[:before].call(r) { driver.instance(:id => self.id) }
+          else
+            new_instance = driver.instance(:id => self.id)
+          end
+          ((yield new_instance) == true) ? new_instance : false
+        end
+      rescue Timeout::Error
+        false
+      ensure
+        opts[:after].call(r) if opts[:after]
+      end
+      return result unless result == false
+      sleep(opts[:time_between_retry])
+    end
+    raise Timeout::Error
+  end
+end
+
 # Freeze time, so EC2 signatures have all the same time
 # This will avoid IncorrectSignature exceptions
 


Mime
View raw message