Commit 3db57034 authored by Jérome Perrin's avatar Jérome Perrin Committed by Kazuhiko Shiozaki

ERP5TypeFunctionalTestCase: make sure activities are not subscribed

Invoking Zuite_waitForActivities when portal_activities is already
subscribed and while another thread from this process is already
executing activities causes infinite "Got a lock error, retrying...".

This situation happens when developer makes a mistake (runs the
tests without unsubscribing activities), so be nice to the developer
so that they don't have to restart Zope.
parent 5e08678a
import itertools
import time
from Products.CMFActivity.Activity.Queue import VALIDATION_ERROR_DELAY
from Products.CMFActivity.ActivityTool import getCurrentNode
def waitForActivities(self, delay=100, count=None):
"""
......@@ -9,13 +10,17 @@ def waitForActivities(self, delay=100, count=None):
RuntimeError is raised in case there is no way
to finish activities.
"""
activity_tool = self.getPortalObject().portal_activities
assert not (
activity_tool.isSubscribed()
and getCurrentNode() in activity_tool.getProcessingNodeList())
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
for call_count in itertools.count():
x = activity_tool.getMessageList()
if not x:
......
......@@ -420,6 +420,9 @@ class ERP5TypeFunctionalTestCase(ERP5TypeTestCase):
# create browser_id_manager
if not "browser_id_manager" in self.portal.objectIds():
self.portal.manage_addProduct['Sessions'].constructBrowserIdManager()
# unsubscribe from activities, we'll use Zuite_waitForActivities to
# process activities
self.portal.portal_activities.unsubscribe()
self.commit()
self.setSystemPreference()
# non-recursive results clean of portal_tests/ or portal_tests/``run_only``
......
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