Commit 562a8f85 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki Committed by Kazuhiko Shiozaki

CMFActivity: unhardcode -2 and -10.

parent 2419299d
...@@ -49,6 +49,7 @@ MAX_VALIDATED_LIMIT = 1000 ...@@ -49,6 +49,7 @@ MAX_VALIDATED_LIMIT = 1000
# Read this many messages to validate. # Read this many messages to validate.
READ_MESSAGE_LIMIT = 1000 READ_MESSAGE_LIMIT = 1000
INVOKE_ERROR_STATE = -2 INVOKE_ERROR_STATE = -2
DEPENDENCY_IGNORED_ERROR_STATE = -10
# Activity uids are stored as 64 bits unsigned integers. # Activity uids are stored as 64 bits unsigned integers.
# No need to depend on a database that supports unsigned integers. # No need to depend on a database that supports unsigned integers.
# Numbers are far big enough without using the MSb. Assuming a busy activity # Numbers are far big enough without using the MSb. Assuming a busy activity
...@@ -281,17 +282,17 @@ CREATE TABLE %s ( ...@@ -281,17 +282,17 @@ CREATE TABLE %s (
for line in result] for line in result]
def countMessageSQL(self, quote, **kw): def countMessageSQL(self, quote, **kw):
return "SELECT count(*) FROM %s WHERE processing_node > -10 AND %s" % ( return "SELECT count(*) FROM %s WHERE processing_node > %d AND %s" % (
self.sql_table, " AND ".join( self.sql_table, DEPENDENCY_IGNORED_ERROR_STATE, " AND ".join(
sqltest_dict[k](v, quote) for (k, v) in kw.iteritems() if v sqltest_dict[k](v, quote) for (k, v) in kw.iteritems() if v
) or "1") ) or "1")
def hasActivitySQL(self, quote, only_valid=False, only_invalid=False, **kw): def hasActivitySQL(self, quote, only_valid=False, only_invalid=False, **kw):
where = [sqltest_dict[k](v, quote) for (k, v) in kw.iteritems() if v] where = [sqltest_dict[k](v, quote) for (k, v) in kw.iteritems() if v]
if only_valid: if only_valid:
where.append('processing_node > -2') where.append('processing_node > %d' % INVOKE_ERROR_STATE)
if only_invalid: if only_invalid:
where.append('processing_node < -1') where.append('processing_node <= %d' % INVOKE_ERROR_STATE)
return "SELECT 1 FROM %s WHERE %s LIMIT 1" % ( return "SELECT 1 FROM %s WHERE %s LIMIT 1" % (
self.sql_table, " AND ".join(where) or "1") self.sql_table, " AND ".join(where) or "1")
...@@ -347,8 +348,9 @@ CREATE TABLE %s ( ...@@ -347,8 +348,9 @@ CREATE TABLE %s (
if validate_list: if validate_list:
return ("SELECT '%s' as activity, uid, date, processing_node," return ("SELECT '%s' as activity, uid, date, processing_node,"
" priority, group_method_id, message FROM %s" " priority, group_method_id, message FROM %s"
" WHERE processing_node > -10 AND (%s) LIMIT %s" % ( " WHERE processing_node > %d AND (%s) LIMIT %s" % (
type(self).__name__, self.sql_table, type(self).__name__, self.sql_table,
DEPENDENCY_IGNORED_ERROR_STATE,
' OR '.join(validate_list), ' OR '.join(validate_list),
READ_MESSAGE_LIMIT if same_queue else 1)) READ_MESSAGE_LIMIT if same_queue else 1))
......
...@@ -1176,7 +1176,7 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor): ...@@ -1176,7 +1176,7 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
self.flushAllActivities(silent=1, loop_size=100) self.flushAllActivities(silent=1, loop_size=100)
message, = activity_tool.getMessageList( message, = activity_tool.getMessageList(
activity=activity, method_id='failingMethod') activity=activity, method_id='failingMethod')
self.assertEqual(message.processing_node, -2) self.assertEqual(message.processing_node, INVOKE_ERROR_STATE)
self.assertTrue(message.retry) self.assertTrue(message.retry)
activity_tool.manageDelete(message.uid, activity) activity_tool.manageDelete(message.uid, activity)
self.commit() self.commit()
......
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