From 36aec8d52f3a77a5404debe7c7ed068a7bd1f9c8 Mon Sep 17 00:00:00 2001 From: Yusei Tahara <yusei@nexedi.com> Date: Mon, 31 Aug 2009 13:00:06 +0000 Subject: [PATCH] Add a test to show that there is a bug on serialization tag and SQLDict. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@28693 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/CMFActivity/tests/testCMFActivity.py | 71 ++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/product/CMFActivity/tests/testCMFActivity.py b/product/CMFActivity/tests/testCMFActivity.py index 8035716926..3b6b6a86d4 100644 --- a/product/CMFActivity/tests/testCMFActivity.py +++ b/product/CMFActivity/tests/testCMFActivity.py @@ -3357,6 +3357,77 @@ class TestCMFActivity(ERP5TypeTestCase): method_name = 'dummy_counter_%s' % i delattr(Organisation, method_name) + def test_115_TestSerializationTagSQLDictPreventsParallelExecution(self, quiet=0, run=run_all_test): + """ + Test if there are multiple activities with the same serialization tag, + then serialization tag guarantees that only one of the same serialization + tagged activities can be processed at the same time. + """ + if not run: return + if not quiet: + message = '\n' + ZopeTestCase._print(message) + LOG('Testing... ',0,message) + from Products.CMFActivity import ActivityTool + + portal = self.getPortal() + activity_tool = portal.portal_activities + get_transaction().commit() + self.tic() + + # Add 6 activities + portal.organisation_module.activate(activity='SQLDict', tag='', serialization_tag='test_115').getId() + get_transaction().commit() + portal.organisation_module.activate(activity='SQLDict', serialization_tag='test_115').getTitle() + get_transaction().commit() + portal.organisation_module.activate(activity='SQLDict', tag='tag_1', serialization_tag='test_115').getId() + get_transaction().commit() + portal.person_module.activate(activity='SQLDict', serialization_tag='test_115').getId() + get_transaction().commit() + portal.person_module.activate(activity='SQLDict', tag='tag_2').getId() + get_transaction().commit() + portal.organisation_module.activate(activity='SQLDict', tag='', serialization_tag='test_115').getId() + get_transaction().commit() + + # distribute and assign them to 3 nodes + activity_tool.distribute() + get_transaction().commit() + + from Products.CMFActivity import ActivityTool + ActivityTool.activity_dict['SQLDict'].getProcessableMessageList(activity_tool, 1) + get_transaction().commit() + ActivityTool.activity_dict['SQLDict'].getProcessableMessageList(activity_tool, 2) + get_transaction().commit() + ActivityTool.activity_dict['SQLDict'].getProcessableMessageList(activity_tool, 3) + get_transaction().commit() + + result = activity_tool.SQLDict_readMessageList(include_processing=1, + processing_node=None, + path=None, + method_id=None, + to_date=None, + offset=0, + count=1000) + + self.assertEqual(len([message + for message in result + if (message.processing_node>0 and + message.processing==1 and + message.serialization_tag=='test_115')]), + 1) + + self.assertEqual(len([message + for message in result + if (message.processing_node==-1 and + message.serialization_tag=='test_115')]), + 3) + + self.assertEqual(len([message + for message in result + if (message.processing_node>0 and + message.processing==1 and + message.serialization_tag=='')]), + 1) def test_suite(): suite = unittest.TestSuite() -- 2.30.9