]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Change safe_while defaults to 6s 10x no increment
authorZack Cerza <zack@cerza.org>
Fri, 7 Mar 2014 19:33:27 +0000 (13:33 -0600)
committerZack Cerza <zack@cerza.org>
Fri, 7 Mar 2014 19:33:27 +0000 (13:33 -0600)
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
teuthology/contextutil.py
teuthology/test/test_contextutil.py

index 513147fa0c374a8753a7e6b2431d6ee963c0071b..39626dc840be9e42deef11ef3c721f0115c853d2 100644 (file)
@@ -55,8 +55,7 @@ class safe_while(object):
     that need a given number of tries and some seconds to sleep between each
     one of those tries.
 
-    The most simple example possible will try 5 times sleeping for 5 seconds
-    and increasing the sleep time by 5 each time::
+    The most simple example possible will try 10 times sleeping for 6 seconds:
 
         >>> from teuthology.contexutil import safe_while
         >>> with safe_while() as bomb:
@@ -73,13 +72,13 @@ class safe_while(object):
     indentation level and one extra call. Everything else stays the same,
     code-wise. So adding this helper to existing code is simpler.
 
-    The defaults are to start the sleeping time in seconds at 5s and to add
-    5 more seconds at every point in the loop. Setting the increment value to
-    0 makes the sleep time in seconds stay the same throughout the calls.
+    The defaults are to start the sleeping time at 6 seconds and try 10 times.
+    Setting the increment value will cause the sleep time to increase by that
+    value at each step.
 
     """
 
-    def __init__(self, sleep=5, increment=5, tries=5, _sleeper=None):
+    def __init__(self, sleep=6, increment=0, tries=10, _sleeper=None):
         self.sleep = sleep
         self.increment = increment
         self.tries = tries
index 656f1f5c92acf3ca5ac96f1153daf91b7ce2bfc2..d9bb08f99df82057bc43279cb0aff850d2eb0eb7 100644 (file)
@@ -8,13 +8,13 @@ class TestSafeWhile(object):
         self.fake_sleep = lambda s: True
         self.s_while = contextutil.safe_while
 
-    def test_5_5_5_deal(self):
+    def test_6_5_10_deal(self):
         with raises(contextutil.MaxWhileTries):
             with self.s_while(_sleeper=self.fake_sleep) as bomb:
                 while 1:
                     bomb()
 
-    def test_5_5_1_deal(self):
+    def test_6_0_1_deal(self):
         with raises(contextutil.MaxWhileTries) as error:
             with self.s_while(
                 tries=1,
@@ -24,9 +24,9 @@ class TestSafeWhile(object):
                     bomb()
 
         msg = error.value[0]
-        assert 'waiting for 5 seconds' in msg
+        assert 'waiting for 6 seconds' in msg
 
-    def test_1_5_5_deal(self):
+    def test_1_0_10_deal(self):
         with raises(contextutil.MaxWhileTries) as error:
             with self.s_while(
                 sleep=1,
@@ -36,9 +36,9 @@ class TestSafeWhile(object):
                     bomb()
 
         msg = error.value[0]
-        assert 'waiting for 55 seconds' in msg
+        assert 'waiting for 10 seconds' in msg
 
-    def test_5_1_5_deal(self):
+    def test_6_1_10_deal(self):
         with raises(contextutil.MaxWhileTries) as error:
             with self.s_while(
                 increment=1,
@@ -48,4 +48,4 @@ class TestSafeWhile(object):
                     bomb()
 
         msg = error.value[0]
-        assert 'waiting for 35 seconds' in msg
+        assert 'waiting for 105 seconds' in msg