Commit 2f9dae45 authored by Yoshinori Okuji's avatar Yoshinori Okuji

This new test confirms a bug which made messages pending permanently when...

This new test confirms a bug which made messages pending permanently when conflict errors happen in retrieving objects.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@12022 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 1fa56f44
...@@ -674,6 +674,49 @@ class TestCMFActivity(ERP5TypeTestCase): ...@@ -674,6 +674,49 @@ class TestCMFActivity(ERP5TypeTestCase):
self.flushAllActivities(silent = 1, loop_size = i + 10) self.flushAllActivities(silent = 1, loop_size = i + 10)
self.assertEquals(len(activity_tool.getMessageList()), 0) self.assertEquals(len(activity_tool.getMessageList()), 0)
def TryConflictErrorsWhileValidating(self, activity):
"""Try to execute active objects which may throw conflict errors
while validating, and check if they are still executed."""
# Make sure that no active object is installed.
activity_tool = self.getPortal().portal_activities
activity_tool.manageClearActivities(keep=0)
# Need an object.
organisation_module = self.getOrganisationModule()
if not organisation_module.hasContent(self.company_id):
organisation_module.newContent(id=self.company_id)
o = organisation_module._getOb(self.company_id)
get_transaction().commit()
self.flushAllActivities(silent = 1, loop_size = 10)
self.assertEquals(len(activity_tool.getMessageList()), 0)
# Monkey patch Queue to induce conflict errors artificially.
def validate(self, *args, **kwargs):
from Products.CMFActivity.Activity.Queue import Queue
if Queue.current_num_conflict_errors < Queue.conflict_errors_limit:
Queue.current_num_conflict_errors += 1
# LOG('TryConflictErrorsWhileValidating', 0, 'causing a conflict error artificially')
raise ConflictError
return self.original_validate(*args, **kwargs)
from Products.CMFActivity.Activity.Queue import Queue
Queue.original_validate = Queue.validate
Queue.validate = validate
try:
# Test some range of conflict error occurences.
for i in xrange(10):
Queue.current_num_conflict_errors = 0
Queue.conflict_errors_limit = i
o.activate(activity = activity).getId()
get_transaction().commit()
self.flushAllActivities(silent = 1, loop_size = i + 10)
self.assertEquals(len(activity_tool.getMessageList()), 0)
finally:
Queue.validate = Queue.original_validate
del Queue.original_validate
del Queue.current_num_conflict_errors
del Queue.conflict_errors_limit
def test_01_DeferedSetTitleSQLDict(self, quiet=0, run=run_all_test): def test_01_DeferedSetTitleSQLDict(self, quiet=0, run=run_all_test):
# Test if we can add a complete sales order # Test if we can add a complete sales order
if not run: return if not run: return
...@@ -1462,6 +1505,28 @@ class TestCMFActivity(ERP5TypeTestCase): ...@@ -1462,6 +1505,28 @@ class TestCMFActivity(ERP5TypeTestCase):
LOG('Testing... ', 0, message) LOG('Testing... ', 0, message)
self.TryConflictErrorsWhileProcessing('SQLQueue') self.TryConflictErrorsWhileProcessing('SQLQueue')
def test_70_TestConflictErrorsWhileValidatingWithSQLDict(self, quiet=0, run=run_all_test):
"""
Test if conflict errors spoil out active objects with SQLDict.
"""
if not run: return
if not quiet:
message = '\nTest Conflict Errors While Validating With SQLDict'
ZopeTestCase._print(message)
LOG('Testing... ', 0, message)
self.TryConflictErrorsWhileValidating('SQLDict')
def test_71_TestConflictErrorsWhileValidatingWithSQLQueue(self, quiet=0, run=run_all_test):
"""
Test if conflict errors spoil out active objects with SQLQueue.
"""
if not run: return
if not quiet:
message = '\nTest Conflict Errors While Validating With SQLQueue'
ZopeTestCase._print(message)
LOG('Testing... ', 0, message)
self.TryConflictErrorsWhileValidating('SQLQueue')
if __name__ == '__main__': if __name__ == '__main__':
framework() framework()
......
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