From e7209de8446a105fb91839574a83d9b97beeb72f Mon Sep 17 00:00:00 2001
From: Benjamin Blanc <benjamin.blanc@tiolive.com>
Date: Wed, 31 Jul 2013 13:32:40 +0200
Subject: [PATCH] scalability/runScalabilityTestSuite: add controls

---
 erp5/util/scalability/runScalabilityTestSuite.py | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/erp5/util/scalability/runScalabilityTestSuite.py b/erp5/util/scalability/runScalabilityTestSuite.py
index 86ae648725..e7c88055a3 100644
--- a/erp5/util/scalability/runScalabilityTestSuite.py
+++ b/erp5/util/scalability/runScalabilityTestSuite.py
@@ -53,7 +53,8 @@ def waitFor0PendingActivities(erp5_url, log):
   base64.encodestring('%s:%s' % (user, password)).strip()}
 
   count = 0
-  while MAX_INSTALLATION_TIME > time.time()-start_time:
+  ok = False
+  while MAX_INSTALLATION_TIME > time.time()-start_time and not ok:
     zope_connection = getConnection(erp5_url, log)
     try:
       count = count + 1
@@ -66,19 +67,20 @@ def waitFor0PendingActivities(erp5_url, log):
       message_list = [s.strip() for s in message_list_text[1:-1].split(',')]
       if len(message_list)==0:
         log("There is no pending activities.")
-        break
-      log("There is %d pending activities" %len(message_list))
-      time.sleep(5)
-
+        ok = True
       #Hack to do not take into account persistent Alarm_installMailServer acitivities
       if len(message_list)==1 :
         log("1 pending activity but ok.")
-        break
+        ok = True
+        
+      log("There is %d pending activities" %len(message_list))
+      time.sleep(5)
     except:
       time.sleep(5)
       log("Getting activities failed, retry.")
 
-  raise ValueError("Cannot waitFor0PendingActivities after %d try (for %s s)" %(count, str(time.time()-start_time)))
+  if not ok:
+    raise ValueError("Cannot waitFor0PendingActivities after %d try (for %s s)" %(count, str(time.time()-start_time)))
 
 
 
-- 
2.30.9