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 ...@@ -17,7 +17,7 @@ SELECT
FROM FROM
message message
WHERE WHERE
processing_node >= -1 processing_node >= -2
<dtml-if method_id> <dtml-if method_id>
AND ( AND (
<dtml-in method_id> <dtml-in method_id>
......
...@@ -17,7 +17,7 @@ SELECT ...@@ -17,7 +17,7 @@ SELECT
FROM FROM
message_queue message_queue
WHERE WHERE
processing_node >= -1 processing_node >= -2
<dtml-if method_id> <dtml-if method_id>
AND ( AND (
<dtml-in method_id> <dtml-in method_id>
......
...@@ -1200,7 +1200,7 @@ class TestCMFActivity(ERP5TypeTestCase): ...@@ -1200,7 +1200,7 @@ class TestCMFActivity(ERP5TypeTestCase):
LOG('Testing... ',0,message) LOG('Testing... ',0,message)
self.TryAfterTag('SQLDict') 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 # Test if after_tag can be used
if not run: return if not run: return
if not quiet: if not quiet:
...@@ -1245,7 +1245,7 @@ class TestCMFActivity(ERP5TypeTestCase): ...@@ -1245,7 +1245,7 @@ class TestCMFActivity(ERP5TypeTestCase):
LOG('Testing... ',0,message) LOG('Testing... ',0,message)
self.CheckClearActivities('SQLQueue') self.CheckClearActivities('SQLQueue')
def flushAllActivities(self): def flushAllActivities(self, silent=0, loop_size=1000):
"""Executes all messages until the queue only contains failed """Executes all messages until the queue only contains failed
messages. messages.
""" """
...@@ -1254,7 +1254,9 @@ class TestCMFActivity(ERP5TypeTestCase): ...@@ -1254,7 +1254,9 @@ class TestCMFActivity(ERP5TypeTestCase):
# flush activities # flush activities
while 1: while 1:
loop_count += 1 loop_count += 1
if loop_count >= 1000: if loop_count >= loop_size:
if silent:
return
self.fail('flushAllActivities maximum loop count reached') self.fail('flushAllActivities maximum loop count reached')
activity_tool.distribute(node_count=1) activity_tool.distribute(node_count=1)
...@@ -1277,15 +1279,22 @@ class TestCMFActivity(ERP5TypeTestCase): ...@@ -1277,15 +1279,22 @@ class TestCMFActivity(ERP5TypeTestCase):
Tests that if we have an active method scheduled by Tests that if we have an active method scheduled by
after_method_id and a failed activity with this method id, the 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 run: return
if not quiet: if not quiet:
message = '\nafter_method_id and failed activities' message = '\nafter_method_id and failed activities'
ZopeTestCase._print(message) ZopeTestCase._print(message)
LOG('Testing... ', 0, message) LOG('Testing... ', 0, message)
activity_tool = self.getPortal().portal_activities activity_tool = self.getPortal().portal_activities
original_title = 'something'
obj = self.getPortal().organisation_module.newContent( obj = self.getPortal().organisation_module.newContent(
portal_type='Organisation') portal_type='Organisation',
title=original_title)
# Monkey patch Organisation to add a failing method # Monkey patch Organisation to add a failing method
def failingMethod(self): def failingMethod(self):
...@@ -1302,31 +1311,43 @@ class TestCMFActivity(ERP5TypeTestCase): ...@@ -1302,31 +1311,43 @@ class TestCMFActivity(ERP5TypeTestCase):
activity_list = ['SQLQueue', 'SQLDict', ] activity_list = ['SQLQueue', 'SQLDict', ]
for activity in activity_list: for activity in activity_list:
# reset # reset
activity_tool.manageClearActivities() activity_tool.manageClearActivities(keep=0)
obj.setTitle('something') obj.setTitle(original_title)
get_transaction().commit() get_transaction().commit()
# activate failing message and flush # activate failing message and flush
for fail_activity in activity_list: for fail_activity in activity_list:
obj.activate(activity = fail_activity).failingMethod() obj.activate(activity = fail_activity).failingMethod()
get_transaction().commit() get_transaction().commit()
self.flushAllActivities() self.flushAllActivities(silent=1, loop_size=100)
message_count = len(activity_tool.getMessageList()) full_message_list = activity_tool.getMessageList()
if message_count == 0: remaining_messages = [a for a in full_message_list if a.method_id !=
self.fail('Activity tool should have remaining messages') '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 # activate our message
new_title = 'nothing' new_title = 'nothing'
obj.activate(after_method_id = ['failingMethod'], obj.activate(after_method_id = ['failingMethod'],
activity = activity ).setTitle(new_title) activity = activity ).setTitle(new_title)
get_transaction().commit() get_transaction().commit()
self.flushAllActivities() self.flushAllActivities(silent=1, loop_size=100)
self.assertEquals(message_count, full_message_list = activity_tool.getMessageList()
len(activity_tool.getMessageList())) remaining_messages = [a for a in full_message_list if a.method_id !=
self.assertEquals(obj.getTitle(), new_title) 'failingMethod']
if len(full_message_list) != 3:
# restore notification 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 Message.notifyUser = originalNotifyUser
activity_tool.manageClearActivities(keep=0)
def test_66_TestCountMessageWithTagWithSQLDict(self, quiet=0, run=run_all_test): 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