Selaa lähdekoodia

Made wait interval conditional - mocks use 0 and actual backend tests
use 5

nuwan_ag 10 vuotta sitten
vanhempi
sitoutus
15a8a481b6
2 muutettua tiedostoa jossa 20 lisäystä ja 17 poistoa
  1. 7 9
      cloudbridge/providers/base.py
  2. 13 8
      test/helpers.py

+ 7 - 9
cloudbridge/providers/base.py

@@ -115,15 +115,13 @@ class BaseObjectLifeCycleMixin(ObjectLifeCycleMixin):
                     "Object: {0} is in state: {1} which is a terminal state"
                     " and cannot be waited on.".format(self, self.state))
             else:
-                # print output every 30 seconds to avoid spamming log
-                if (int(end_time - time.time()) % 15 == 0):
-                    log.debug(
-                        "Object {0} is in state: {1}. Waiting another {2}"
-                        " seconds to reach target state(s): {3}...".format(
-                            self,
-                            self.state,
-                            int(end_time - time.time()),
-                            target_states))
+                log.debug(
+                    "Object {0} is in state: {1}. Waiting another {2}"
+                    " seconds to reach target state(s): {3}...".format(
+                        self,
+                        self.state,
+                        int(end_time - time.time()),
+                        target_states))
                 time.sleep(interval)
                 if time.time() > end_time:
                     raise WaitStateException(

+ 13 - 8
test/helpers.py

@@ -6,7 +6,18 @@ from six import reraise
 
 from cloudbridge.providers.factory import CloudProviderFactory
 
-TEST_WAIT_INTERVAL = 0
+
+def parse_bool(val):
+    if val:
+        return str(val).upper() in ['TRUE', 'YES']
+    else:
+        return False
+
+
+TEST_WAIT_INTERVAL = 0 if parse_bool(
+    os.environ.get(
+        "CB_USE_MOCK_DRIVERS",
+        True)) else 5
 
 
 @contextmanager
@@ -142,19 +153,13 @@ class ProviderTestCaseGenerator():
         map(suite.addTest, suites)
         return suite
 
-    def _parse_bool(self, val):
-        if val:
-            return str(val).upper() in ['TRUE', 'YES']
-        else:
-            return False
-
     def generate_tests(self):
         """
         Generate and return a suite of tests for all provider and test class
         combinations
         """
         factory = CloudProviderFactory()
-        use_mock_drivers = self._parse_bool(
+        use_mock_drivers = parse_bool(
             os.environ.get("CB_USE_MOCK_DRIVERS", True))
         provider_name = os.environ.get("CB_TEST_PROVIDER", None)
         if provider_name: