Commit 1f541a2d authored by Julien Muchembled's avatar Julien Muchembled

Test order of commit of ZODB, compared to other resources

parent 649a5769
...@@ -595,6 +595,10 @@ class SimulableMixin(Base): ...@@ -595,6 +595,10 @@ class SimulableMixin(Base):
portal.portal_simulation, is_indexable=False) portal.portal_simulation, is_indexable=False)
applied_rule._setCausalityValue(self) applied_rule._setCausalityValue(self)
del applied_rule.isIndexable del applied_rule.isIndexable
# To prevent duplicate root Applied Rule, we reindex immediately and
# lock ZODB, and we rely on the fact that ZODB is committed after
# catalog. This way, we guarantee the catalog is up-to-date as soon as
# ZODB is unlocked.
applied_rule.immediateReindexObject() applied_rule.immediateReindexObject()
self.serialize() # prevent duplicate root Applied Rule self.serialize() # prevent duplicate root Applied Rule
return applied_rule return applied_rule
......
...@@ -70,28 +70,30 @@ class TestInvalidationBug(ERP5TypeTestCase): ...@@ -70,28 +70,30 @@ class TestInvalidationBug(ERP5TypeTestCase):
len(manage_test(query))) len(manage_test(query)))
result_list = [map(apply, test_list)] result_list = [map(apply, test_list)]
Transaction_commitResources = transaction.Transaction._commitResources Transaction_commitResources = transaction.Transaction._commitResources
connection = module._p_jar
def _commitResources(self): def _commitResources(self):
orig_tpc_finish_dict = dict((rm.__class__, rm.__class__.tpc_finish) def tpc_finish(rm, txn):
for rm in self._resources) rm.__class__.tpc_finish(rm, txn)
def tpc_finish(self, txn): result_list.append(None if rm is connection else map(apply, test_list))
orig_tpc_finish_dict[self.__class__](self, txn)
result_list.append(map(apply, test_list))
try: try:
for cls in orig_tpc_finish_dict: for rm in self._resources:
cls.tpc_finish = tpc_finish rm.tpc_finish = lambda txn, rm=rm: tpc_finish(rm, txn)
return Transaction_commitResources(self) return Transaction_commitResources(self)
finally: finally:
for cls, tpc_finish in orig_tpc_finish_dict.iteritems(): for rm in self._resources:
cls.tpc_finish = tpc_finish del rm.tpc_finish
try: try:
transaction.Transaction._commitResources = _commitResources transaction.Transaction._commitResources = _commitResources
self.commit() self.commit()
finally: finally:
transaction.Transaction._commitResources = Transaction_commitResources transaction.Transaction._commitResources = Transaction_commitResources
self.tic() self.tic()
# Whether ZODB should be committed before or after catalog is not obvious.
# Current behaviour is required to avoid creating duplicated applied rules.
self.assertEqual(result_list[0], [0,0]) self.assertEqual(result_list[0], [0,0])
self.assertEqual(result_list[1], [0,0]) # activity buffer first self.assertEqual(result_list[1], [0,0]) # activity buffer first
self.assertEqual(result_list[-2], [1,0]) # catalog self.assertEqual(result_list[-3], [1,0]) # catalog
self.assertEqual(result_list[-2], None) # ZODB
self.assertEqual(result_list[-1], [1,1]) # activity tables last self.assertEqual(result_list[-1], [1,1]) # activity tables last
def testLateInvalidationFromZEO(self): def testLateInvalidationFromZEO(self):
......
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