Commit f107e6dc authored by Alexandre Boeglin's avatar Alexandre Boeglin

When an activity fails, all activities that depend on it should not be

executed.

Note: earlier version of this test checked exactly the contrary, but it was
eventually agreed that this was a bug. If an activity fails, all the
activities that depend on it should be block until the first one is resolved.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@9994 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 516318b8
......@@ -17,7 +17,7 @@ SELECT
FROM
message
WHERE
processing_node >= -1
processing_node >= -2
<dtml-if method_id>
AND (
<dtml-in method_id>
......
......@@ -17,7 +17,7 @@ SELECT
FROM
message_queue
WHERE
processing_node >= -1
processing_node >= -2
<dtml-if method_id>
AND (
<dtml-in method_id>
......
......@@ -1200,7 +1200,7 @@ class TestCMFActivity(ERP5TypeTestCase):
LOG('Testing... ',0,message)
self.TryAfterTag('SQLDict')
def test_60_TryAfterTagWithSQLDict(self, quiet=0, run=run_all_test):
def test_60_TryAfterTagWithSQLQueue(self, quiet=0, run=run_all_test):
# Test if after_tag can be used
if not run: return
if not quiet:
......@@ -1245,7 +1245,7 @@ class TestCMFActivity(ERP5TypeTestCase):
LOG('Testing... ',0,message)
self.CheckClearActivities('SQLQueue')
def flushAllActivities(self):
def flushAllActivities(self, silent=0, loop_size=1000):
"""Executes all messages until the queue only contains failed
messages.
"""
......@@ -1254,7 +1254,9 @@ class TestCMFActivity(ERP5TypeTestCase):
# flush activities
while 1:
loop_count += 1
if loop_count >= 1000:
if loop_count >= loop_size:
if silent:
return
self.fail('flushAllActivities maximum loop count reached')
activity_tool.distribute(node_count=1)
......@@ -1277,15 +1279,22 @@ class TestCMFActivity(ERP5TypeTestCase):
Tests that if we have an active method scheduled by
after_method_id and a failed activity with this method id, the
method is executed."""
method is NOT executed.
Note: earlier version of this test checked exactly the contrary, but it
was eventually agreed that this was a bug. If an activity fails, all the
activities that depend on it should be block until the first one is
resolved."""
if not run: return
if not quiet:
message = '\nafter_method_id and failed activities'
ZopeTestCase._print(message)
LOG('Testing... ', 0, message)
activity_tool = self.getPortal().portal_activities
original_title = 'something'
obj = self.getPortal().organisation_module.newContent(
portal_type='Organisation')
portal_type='Organisation',
title=original_title)
# Monkey patch Organisation to add a failing method
def failingMethod(self):
......@@ -1302,31 +1311,43 @@ class TestCMFActivity(ERP5TypeTestCase):
activity_list = ['SQLQueue', 'SQLDict', ]
for activity in activity_list:
# reset
activity_tool.manageClearActivities()
obj.setTitle('something')
activity_tool.manageClearActivities(keep=0)
obj.setTitle(original_title)
get_transaction().commit()
# activate failing message and flush
for fail_activity in activity_list:
obj.activate(activity = fail_activity).failingMethod()
get_transaction().commit()
self.flushAllActivities()
message_count = len(activity_tool.getMessageList())
if message_count == 0:
self.fail('Activity tool should have remaining messages')
self.flushAllActivities(silent=1, loop_size=100)
full_message_list = activity_tool.getMessageList()
remaining_messages = [a for a in full_message_list if a.method_id !=
'failingMethod']
if len(full_message_list) != 2:
self.fail('failingMethod should not have been flushed')
if len(remaining_messages) != 0:
self.fail('Activity tool should have no other remaining messages')
# activate our message
new_title = 'nothing'
obj.activate(after_method_id = ['failingMethod'],
activity = activity ).setTitle(new_title)
get_transaction().commit()
self.flushAllActivities()
self.assertEquals(message_count,
len(activity_tool.getMessageList()))
self.assertEquals(obj.getTitle(), new_title)
# restore notification
self.flushAllActivities(silent=1, loop_size=100)
full_message_list = activity_tool.getMessageList()
remaining_messages = [a for a in full_message_list if a.method_id !=
'failingMethod']
if len(full_message_list) != 3:
self.fail('failingMethod should not have been flushed')
if len(remaining_messages) != 1:
self.fail('Activity tool should have one blocked setTitle activity')
self.assertEquals(remaining_messages[0].activity_kw['after_method_id'],
['failingMethod'])
self.assertEquals(obj.getTitle(), original_title)
# restore notification and flush failed and blocked activities
Message.notifyUser = originalNotifyUser
activity_tool.manageClearActivities(keep=0)
def test_66_TestCountMessageWithTagWithSQLDict(self, quiet=0, run=run_all_test):
"""
......
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