Commit 40ad2f2f authored by Vincent Pelletier's avatar Vincent Pelletier

Update test_undo2 to follow changes from r1877.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@1886 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent b49d4179
...@@ -721,7 +721,8 @@ class ClientApplicationTests(NeoTestBase): ...@@ -721,7 +721,8 @@ class ClientApplicationTests(NeoTestBase):
app = self.getApp() app = self.getApp()
app.num_partitions = 2 app.num_partitions = 2
oid1, oid2 = self.makeOID(1), self.makeOID(2) oid1, oid2 = self.makeOID(1), self.makeOID(2)
tid2 = self.makeTID(2) oid3 = self.makeOID(3)
tid1, tid2 = self.makeTID(1), self.makeTID(2)
tid3, tid4 = self.makeTID(3), self.makeTID(4) tid3, tid4 = self.makeTID(3), self.makeTID(4)
# commit version 1 of object 2 # commit version 1 of object 2
txn2 = self.beginTransaction(app, tid=tid2) txn2 = self.beginTransaction(app, tid=tid2)
...@@ -736,28 +737,34 @@ class ClientApplicationTests(NeoTestBase): ...@@ -736,28 +737,34 @@ class ClientApplicationTests(NeoTestBase):
# undo 2 -> not end tid # undo 2 -> not end tid
u2p1 = Packets.AnswerTransactionInformation(tid2, '', '', '', u2p1 = Packets.AnswerTransactionInformation(tid2, '', '', '',
False, (oid2, )) False, (oid2, ))
u2p2 = Packets.AnswerObject(oid2, tid2, tid3, 0, makeChecksum('O2V1'), 'O2V1') u2p2 = Packets.AnswerObject(oid2, tid1, tid2, 0, makeChecksum('O2V1'), 'O2V1')
u2p3 = Packets.AnswerObject(oid2, tid2, tid3, 0, makeChecksum('O2V2'), 'O2V2')
# undo 3 -> conflict # undo 3 -> conflict
u3p1 = Packets.AnswerTransactionInformation(tid3, '', '', '', u3p1 = Packets.AnswerTransactionInformation(tid3, '', '', '',
False, (oid2, )) False, (oid3, ))
u3p2 = Packets.AnswerObject(oid2, tid3, tid3, 0, makeChecksum('O2V2'), 'O2V2') u3p2 = Packets.AnswerObject(oid3, tid3, tid3, 0, makeChecksum('O3V1'), 'O3V1')
u3p3 = Packets.AnswerStoreObject(conflicting=1, oid=oid2, serial=tid2) u3p3 = Packets.AnswerObject(oid3, tid3, tid3, 0, makeChecksum('O3V1'), 'O3V1')
u3p4 = Packets.AnswerObject(oid3, tid3, tid3, 0, makeChecksum('O3V1'), 'O3V1')
u3p5 = Packets.AnswerStoreObject(conflicting=1, oid=oid3, serial=tid2)
# undo 4 -> ok # undo 4 -> ok
u4p1 = Packets.AnswerTransactionInformation(tid3, '', '', '', u4p1 = Packets.AnswerTransactionInformation(tid3, '', '', '',
False, (oid2, )) False, (oid1, ))
u4p2 = Packets.AnswerObject(oid2, tid3, tid3, 0, makeChecksum('O2V2'), 'O2V2') u4p2 = Packets.AnswerObject(oid1, tid3, tid3, 0, makeChecksum('O1V1'), 'O1V1')
u4p3 = Packets.AnswerStoreObject(conflicting=0, oid=oid2, serial=tid2) u4p3 = Packets.AnswerObject(oid1, tid3, tid3, 0, makeChecksum('O1V1'), 'O1V1')
u4p4 = Packets.AnswerObject(oid1, tid3, tid3, 0, makeChecksum('O1V1'), 'O1V1')
u4p5 = Packets.AnswerStoreObject(conflicting=0, oid=oid1, serial=tid2)
# test logic # test logic
packets = (u2p1, u2p2, u3p1, u3p2, u3p3, u4p1, u4p2, u4p3) packets = (u2p1, u2p2, u2p3, u3p1, u3p2, u3p3, u3p4, u3p5, u4p1, u4p2,
u4p3, u4p4, u4p5)
for i, p in enumerate(packets): for i, p in enumerate(packets):
p.setId(p) p.setId(p)
storage_address = ('127.0.0.1', 10010) storage_address = ('127.0.0.1', 10010)
conn = Mock({ conn = Mock({
'getNextId': 1, 'getNextId': 1,
'fakeReceived': ReturnValues( 'fakeReceived': ReturnValues(
u2p1, u2p2, u2p1, u2p2, u2p3,
u4p1, u4p2, u4p1, u4p2, u4p3, u4p4,
u3p1, u3p2, u3p1, u3p2, u3p3, u3p4,
), ),
'getAddress': storage_address, 'getAddress': storage_address,
}) })
...@@ -779,10 +786,10 @@ class ClientApplicationTests(NeoTestBase): ...@@ -779,10 +786,10 @@ class ClientApplicationTests(NeoTestBase):
# all start here # all start here
self.assertRaises(UndoError, app.undo, tid2, txn4, self.assertRaises(UndoError, app.undo, tid2, txn4,
tryToResolveConflict) tryToResolveConflict)
app.local_var.queue.put((conn, u4p3)) app.local_var.queue.put((conn, u4p5))
self.assertEquals(app.undo(tid3, txn4, tryToResolveConflict), self.assertEquals(app.undo(tid3, txn4, tryToResolveConflict),
(tid4, [oid2, ])) (tid4, [oid1, ]))
app.local_var.queue.put((conn, u3p3)) app.local_var.queue.put((conn, u3p5))
self.assertRaises(ConflictError, app.undo, tid3, txn4, self.assertRaises(ConflictError, app.undo, tid3, txn4,
tryToResolveConflict) tryToResolveConflict)
self.assertEquals(marker, [1]) self.assertEquals(marker, [1])
......
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