[Erp5-report] r15138 - in /erp5/trunk/products: CMFActivity/skins/activity/ ERP5/Document/ ...
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed Jul 4 14:45:34 CEST 2007
Author: vincent
Date: Wed Jul 4 14:45:33 2007
New Revision: 15138
URL: http://svn.erp5.org?rev=15138&view=rev
Log:
Alarms must not be blocked by failed activities, and though portal activities must provide a way to count "valid" pending activities without counting failed activities.
Add unit test at alarm document level.
Modified:
erp5/trunk/products/CMFActivity/skins/activity/SQLDict_hasMessage.zsql
erp5/trunk/products/CMFActivity/skins/activity/SQLQueue_hasMessage.zsql
erp5/trunk/products/ERP5/Document/Alarm.py
erp5/trunk/products/ERP5/tests/testAlarm.py
Modified: erp5/trunk/products/CMFActivity/skins/activity/SQLDict_hasMessage.zsql
URL: http://svn.erp5.org/erp5/trunk/products/CMFActivity/skins/activity/SQLDict_hasMessage.zsql?rev=15138&r1=15137&r2=15138&view=diff
==============================================================================
--- erp5/trunk/products/CMFActivity/skins/activity/SQLDict_hasMessage.zsql (original)
+++ erp5/trunk/products/CMFActivity/skins/activity/SQLDict_hasMessage.zsql Wed Jul 4 14:45:33 2007
@@ -8,13 +8,13 @@
class_file:
</dtml-comment>
<params>path
-method_id</params>
+method_id
+only_valid</params>
SELECT count(path) as message_count FROM
message
-<dtml-if "path or method_id">
WHERE
-<dtml-if path> path = <dtml-sqlvar path type="string"></dtml-if>
+1 = 1
+<dtml-if path> AND path = <dtml-sqlvar path type="string"></dtml-if>
<dtml-if method_id>AND method_id = <dtml-sqlvar method_id type="string"></dtml-if>
-</dtml-if>
+<dtml-if only_valid>AND processing_node > -2</dtml-if>
-
Modified: erp5/trunk/products/CMFActivity/skins/activity/SQLQueue_hasMessage.zsql
URL: http://svn.erp5.org/erp5/trunk/products/CMFActivity/skins/activity/SQLQueue_hasMessage.zsql?rev=15138&r1=15137&r2=15138&view=diff
==============================================================================
--- erp5/trunk/products/CMFActivity/skins/activity/SQLQueue_hasMessage.zsql (original)
+++ erp5/trunk/products/CMFActivity/skins/activity/SQLQueue_hasMessage.zsql Wed Jul 4 14:45:33 2007
@@ -8,12 +8,13 @@
class_file:
</dtml-comment>
<params>path
-method_id</params>
+method_id
+only_valid</params>
SELECT count(path) as message_count FROM
message_queue
-<dtml-if "path or method_id">
WHERE
-<dtml-if path> path = <dtml-sqlvar path type="string"></dtml-if>
+1 = 1
+<dtml-if path>AND path = <dtml-sqlvar path type="string"></dtml-if>
<dtml-if method_id>AND method_id = <dtml-sqlvar method_id type="string"></dtml-if>
-</dtml-if>
-
+<dtml-if only_valid>AND processing_node > -2</dtml-if>
+
Modified: erp5/trunk/products/ERP5/Document/Alarm.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/Alarm.py?rev=15138&r1=15137&r2=15138&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/Alarm.py (original)
+++ erp5/trunk/products/ERP5/Document/Alarm.py Wed Jul 4 14:45:33 2007
@@ -264,7 +264,7 @@
active or not. It is activated when it is doing some calculation with
activeSense or solve.
"""
- return self.hasActivity()
+ return self.hasActivity(only_valid=1)
security.declareProtected(Permissions.ModifyPortalContent, 'activeSense')
def activeSense(self):
Modified: erp5/trunk/products/ERP5/tests/testAlarm.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/testAlarm.py?rev=15138&r1=15137&r2=15138&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/tests/testAlarm.py (original)
+++ erp5/trunk/products/ERP5/tests/testAlarm.py Wed Jul 4 14:45:33 2007
@@ -421,7 +421,51 @@
get_transaction().commit()
self.tic()
self.assertEquals(active_process, alarm.getLastActiveProcess())
-
+
+ def test_15_FailedAlarmsDoNotBlockFutureAlarms(self, quiet=0, run=run_all_test):
+ if not run: return
+ if not quiet:
+ message = 'Test Failed Alarms Do Not Block Future Alarms'
+ ZopeTestCase._print('\n%s ' % message)
+ LOG('Testing... ',0,message)
+ sense_method_id = 'Alarm_testSenseMethod'
+ skin_folder_id = 'custom'
+ skin_folder = self.getPortal().portal_skins[skin_folder_id]
+ skin_folder.manage_addProduct['PythonScripts'].manage_addPythonScript(id=sense_method_id)
+ # Make the sense method fail
+ skin_folder[sense_method_id].ZPythonScript_edit('*args,**kw', 'raise Exception')
+ del skin_folder
+ alarm = self.newAlarm()
+ now = DateTime()
+ alarm.setActiveSenseMethodId(sense_method_id)
+ self.assertEquals(alarm.isActive(), 0)
+ alarm.activeSense()
+ get_transaction().commit()
+ try:
+ self.tic()
+ except RuntimeError:
+ pass
+ else:
+ raise Exception, 'Tic did not raise though activity was supposed to fail'
+ # Check that the alarm is not considered active, although there is a remaining activity.
+ self.assertEquals(alarm.hasActivity(), 1)
+ self.assertEquals(alarm.isActive(), 0)
+ self.assertEquals(alarm.getLastActiveProcess(), None)
+ # Make the sense method succeed and leave a trace
+ self.getPortal().portal_skins[skin_folder_id][sense_method_id].ZPythonScript_edit('*args,**kw', 'context.newActiveProcess()')
+ alarm.activeSense()
+ get_transaction().commit()
+ # Note: this call to tic will not fail, because the same method on the same
+ # object is activated again in SQLDict. When the new message will be
+ # -successfully- processed, the previous -failed- message will get removed
+ # in the cleanup. This behaviour is logical if we consider that manually
+ # executing the failed message to get the error will lead to no error.
+ # But it can also be considered illogical if failed messages are supposed
+ # to be preserved for future analysis.
+ self.tic()
+ # Chen that the second alarm execution did happen
+ self.assertNotEquals(alarm.getLastActiveProcess(), None)
+
if __name__ == '__main__':
framework()
else:
More information about the Erp5-report
mailing list