Commit 208b11ad authored by Vincent Pelletier's avatar Vincent Pelletier

erp5_ui_test_core: Make waitForActivities independent from the number of...

erp5_ui_test_core: Make waitForActivities independent from the number of activities processed per tic.

That number was vastly decreased, causing UI tests to bail with "tic is
looping forever" for no good reason.
Convert such logic into a deadline one.
parent e71090b9
Pipeline #19052 failed with stage
in 0 seconds
import itertools
import time
from Products.CMFActivity.Activity.Queue import VALIDATION_ERROR_DELAY from Products.CMFActivity.Activity.Queue import VALIDATION_ERROR_DELAY
def waitForActivities(self, count=1000): def waitForActivities(self, delay=100, count=None):
""" """
We wait until all activities are finished We wait until all activities are finished
RuntimeError is raised in case there is no way RuntimeError is raised in case there is no way
to finish activities. to finish activities.
""" """
if count is not None: # BBB
# completely arbitrary conversion factor: count used to default to 1000
# and I (just as arbitrarily) converted that into a 100s default maximum
# tolerable wait delay before bailing.
delay = count / 10.
deadline = time.time() + delay
activity_tool = self.getPortalObject().portal_activities activity_tool = self.getPortalObject().portal_activities
while count > 0: for call_count in itertools.count():
count -= 1
x = activity_tool.getMessageList() x = activity_tool.getMessageList()
if not x: if not x:
return 'Done.' return 'Done.'
if all(x.processing_node == -2 for x in x): if all(x.processing_node == -2 for x in x):
break break
activity_tool.process_timer(None, None) activity_tool.process_timer(None, None)
if count % 10 == 0: if time.time() > deadline:
break
if call_count % 10 == 0:
activity_tool.timeShift(3 * VALIDATION_ERROR_DELAY) activity_tool.timeShift(3 * VALIDATION_ERROR_DELAY)
raise RuntimeError('tic is looping forever.') raise RuntimeError('tic is looping forever.')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment