[tracker/wip/carlosg/sandbox-fixes] testutils: wait-for-miner fixes




commit 30a111da485b697fb4c31db743451d976e5b91d9
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sat Aug 22 17:59:35 2020 +0200

    testutils: wait-for-miner fixes

 utils/trackertestutils/__main__.py | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/utils/trackertestutils/__main__.py b/utils/trackertestutils/__main__.py
index 078c3fe85..678fe4aeb 100644
--- a/utils/trackertestutils/__main__.py
+++ b/utils/trackertestutils/__main__.py
@@ -320,20 +320,21 @@ class MinerStatusWatch():
 
         cursor = len(self._status_log) - 1
         previous_delta_from_now = 0
-        while True:
-            if cursor < 0 or self._status_log[cursor][1] != 'Idle':
-                if previous_delta_from_now >= period_seconds:
+        while cursor >= 0:
+            if self._status_log[cursor][1] != 'Idle':
+                return False
+
+            if self._status_log[cursor][1] == 'Idle':
+                if (now - self._status_log[cursor][0]) >= period_seconds:
                     return True
-                else:
-                    return False
-            previous_delta_from_now = (now - self._status_log[cursor][0])
+
             cursor -= 1
 
 
 def wait_for_miners(watches):
     # We wait 1 second after "Idle" status is seen before exiting, because the
     # extractor goes to/from Idle frequently.
-    wait_for_idle_time = 1
+    wait_for_idle_time = 2
     while True:
         status = [watch.check_was_idle_for_time_period(wait_for_idle_time) for watch in watches.values()]
         if all(status):


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]