From 0e59a6a8904e324b5656dbe0f0926171ff9fb91e Mon Sep 17 00:00:00 2001 From: Vincent Pelletier <vincent@nexedi.com> Date: Mon, 24 Dec 2007 21:53:17 +0000 Subject: [PATCH] Add a test for abusive commits during the processing of message batches in SQLQueue. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@18503 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/CMFActivity/tests/testCMFActivity.py | 36 ++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/product/CMFActivity/tests/testCMFActivity.py b/product/CMFActivity/tests/testCMFActivity.py index c0728bb1eb..fe72b5c63d 100644 --- a/product/CMFActivity/tests/testCMFActivity.py +++ b/product/CMFActivity/tests/testCMFActivity.py @@ -2142,6 +2142,42 @@ class TestCMFActivity(ERP5TypeTestCase): self.flushAllActivities(silent=1, loop_size=100) self.assertEquals(activity_tool.countMessage(method_id='dummy_activity'), 0) + def test_88_ProcessingMultipleMessagesMustRevertIndividualMessagesOnError(self, quiet=0, run=run_all_test): + """ + Check that, on queues which support it, processing a batch of multiple + messages doesn't cause failed ones to becommited along with succesful + ones. + + Queues supporting message batch processing: + - SQLQueue + """ + if not run: return + if not quiet: + message = '\nCheck processing a batch of messages with failures' + ZopeTestCase._print(message) + LOG('Testing... ',0,message) + get_transaction().commit() + self.tic() + activity_tool = self.getActivityTool() + obj = self.getPortal().organisation_module.newContent(portal_type='Organisation') + active_obj = obj.activate(activity='SQLQueue') + def appendToTitle(self, to_append, fail=False): + self.setTitle(self.getTitle() + to_append) + if fail: + raise ValueError, 'This method always fail' + Organisation.appendToTitle = appendToTitle + obj.setTitle('a') + active_obj.appendToTitle('b') + active_obj.appendToTitle('c', fail=True) + active_obj.appendToTitle('d') + object_id = obj.getId() + get_transaction().commit() + self.assertEqual(obj.getTitle(), 'a') + self.assertEqual(activity_tool.countMessage(method_id='appendToTitle'), 3) + self.flushAllActivities(silent=1, loop_size=100) + self.assertEqual(activity_tool.countMessage(method_id='appendToTitle'), 1) + self.assertEqual(obj.getTitle(), 'abd') + def test_suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(TestCMFActivity)) -- 2.30.9