Commit d798a8ec authored by Grégory Wisniewski's avatar Grégory Wisniewski

Fixes after r1833.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@1851 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 715bfd9d
......@@ -916,10 +916,10 @@ class AnswerTransactionInformation(Packet):
return ''.join(body)
def _decode(self, body):
r = unpack('!8sHHHBL', body[:18])
r = unpack('!8sHHHBL', body[:19])
tid, user_len, desc_len, ext_len, packed, oid_len = r
packed = bool(packed)
body = body[18:]
body = body[19:]
user = body[:user_len]
body = body[user_len:]
desc = body[:desc_len]
......
......@@ -424,7 +424,7 @@ class MySQLDatabaseManager(DatabaseManager):
% tid)
self.commit()
if r:
oids, user, desc, exti, packed = r[0]
oids, user, desc, ext, packed = r[0]
if (len(oids) % 8) != 0 or len(oids) == 0:
raise DatabaseFailure('invalid oids for tid %x' % tid)
oid_list = []
......
......@@ -733,17 +733,21 @@ class ClientApplicationTests(NeoTestBase):
self.voteTransaction(app)
self.askFinishTransaction(app)
# undo 1 -> no previous revision
u1p1 = Packets.AnswerTransactionInformation(tid1, '', '', '', (oid1, ))
u1p1 = Packets.AnswerTransactionInformation(tid1, '', '', '',
False, (oid1, ))
u1p2 = Errors.OidNotFound('oid not found')
# undo 2 -> not end tid
u2p1 = Packets.AnswerTransactionInformation(tid2, '', '', '', (oid2, ))
u2p1 = Packets.AnswerTransactionInformation(tid2, '', '', '',
False, (oid2, ))
u2p2 = Packets.AnswerObject(oid2, tid2, tid3, 0, makeChecksum('O2V1'), 'O2V1')
# undo 3 -> conflict
u3p1 = Packets.AnswerTransactionInformation(tid3, '', '', '', (oid2, ))
u3p1 = Packets.AnswerTransactionInformation(tid3, '', '', '',
False, (oid2, ))
u3p2 = Packets.AnswerObject(oid2, tid3, tid3, 0, makeChecksum('O2V2'), 'O2V2')
u3p3 = Packets.AnswerStoreObject(conflicting=1, oid=oid2, serial=tid2)
# undo 4 -> ok
u4p1 = Packets.AnswerTransactionInformation(tid3, '', '', '', (oid2, ))
u4p1 = Packets.AnswerTransactionInformation(tid3, '', '', '',
False, (oid2, ))
u4p2 = Packets.AnswerObject(oid2, tid3, tid3, 0, makeChecksum('O2V2'), 'O2V2')
u4p3 = Packets.AnswerStoreObject(conflicting=0, oid=oid2, serial=tid2)
# test logic
......@@ -801,8 +805,10 @@ class ClientApplicationTests(NeoTestBase):
oid1, oid2 = self.makeOID(1), self.makeOID(2)
# TIDs packets supplied by _waitMessage hook
# TXN info packets
p3 = Packets.AnswerTransactionInformation(tid1, '', '', '', (oid1, ))
p4 = Packets.AnswerTransactionInformation(tid2, '', '', '', (oid2, ))
p3 = Packets.AnswerTransactionInformation(tid1, '', '', '',
False, (oid1, ))
p4 = Packets.AnswerTransactionInformation(tid2, '', '', '',
False, (oid2, ))
p3.setId(0)
p4.setId(1)
conn = Mock({
......@@ -836,8 +842,10 @@ class ClientApplicationTests(NeoTestBase):
# object history, first is a wrong oid, second is valid
p2 = Packets.AnswerObjectHistory(oid, object_history)
# transaction history
p3 = Packets.AnswerTransactionInformation(tid1, 'u', 'd', 'e', (oid, ))
p4 = Packets.AnswerTransactionInformation(tid2, 'u', 'd', 'e', (oid, ))
p3 = Packets.AnswerTransactionInformation(tid1, 'u', 'd', 'e',
False, (oid, ))
p4 = Packets.AnswerTransactionInformation(tid2, 'u', 'd', 'e',
False, (oid, ))
p2.setId(0)
p3.setId(1)
p4.setId(2)
......
......@@ -124,7 +124,7 @@ class StorageAnswerHandlerTests(NeoTestBase):
oid_list = [self.getOID(0), self.getOID(1)]
self.app.local_var.txn_info = None
self.handler.answerTransactionInformation(conn, tid, user, desc, ext,
oid_list)
False, oid_list)
txn_info = self.app.local_var.txn_info
self.assertTrue(isinstance(txn_info, dict))
self.assertEqual(txn_info['user_name'], user)
......
......@@ -157,7 +157,7 @@ class MasterVerificationTests(NeoTestBase):
oid = unpack('!Q', self.app.loid)[0]
new_oid = pack('!Q', oid + 1)
verification.answerTransactionInformation(conn, new_tid,
"user", "desc", "ext", [new_oid,])
"user", "desc", "ext", False, [new_oid,])
self.assertEquals(self.verification._oid_set, None)
# do nothing as asking_uuid_dict is True
conn = self.getFakeConnection(uuid, self.storage_address)
......@@ -167,7 +167,7 @@ class MasterVerificationTests(NeoTestBase):
self.assertTrue(self.verification._uuid_dict.has_key(uuid))
self.assertEquals(len(self.verification._oid_set), 0)
verification.answerTransactionInformation(conn, new_tid,
"user", "desc", "ext", [new_oid,])
"user", "desc", "ext", False, [new_oid,])
self.assertEquals(len(self.verification._oid_set), 0)
# do work
conn = self.getFakeConnection(uuid, self.storage_address)
......@@ -176,7 +176,7 @@ class MasterVerificationTests(NeoTestBase):
self.assertTrue(self.verification._uuid_dict.has_key(uuid))
self.assertEquals(len(self.verification._oid_set), 0)
verification.answerTransactionInformation(conn, new_tid,
"user", "desc", "ext", [new_oid,])
"user", "desc", "ext", False, [new_oid,])
self.assertEquals(len(self.verification._oid_set), 1)
self.assertTrue(new_oid in self.verification._oid_set)
# do not work as oid is diff
......@@ -190,7 +190,7 @@ class MasterVerificationTests(NeoTestBase):
new_oid = pack('!Q', oid + 1)
self.assertNotEqual(new_oid, old_oid)
verification.answerTransactionInformation(conn, new_tid,
"user", "desc", "ext", [new_oid,])
"user", "desc", "ext", False, [new_oid,])
self.assertEquals(self.verification._oid_set, None)
def test_13_tidNotFound(self):
......
......@@ -93,7 +93,7 @@ class StorageClientHandlerTests(NeoTestBase):
def test_18_askTransactionInformation2(self):
# answer
conn = Mock({ })
dm = Mock({ "getTransaction": (INVALID_TID, 'user', 'desc', '', ), })
dm = Mock({ "getTransaction": (INVALID_TID, 'user', 'desc', '', False), })
self.app.dm = dm
self.operation.askTransactionInformation(conn, INVALID_TID)
self.checkAnswerTransactionInformation(conn)
......
......@@ -65,7 +65,7 @@ class StorageStorageHandlerTests(NeoTestBase):
def test_18_askTransactionInformation2(self):
# answer
conn = Mock({ })
dm = Mock({ "getTransaction": (INVALID_TID, 'user', 'desc', '', ), })
dm = Mock({"getTransaction": (INVALID_TID, 'user', 'desc', '', False), })
self.app.dm = dm
self.operation.askTransactionInformation(conn, INVALID_TID)
self.checkAnswerTransactionInformation(conn)
......
......@@ -402,7 +402,7 @@ class StorageMySQSLdbTests(NeoTestBase):
tid = '\x00' * 7 + '\x01'
oid1, oid2 = '\x00' * 7 + '\x01', '\x00' * 7 + '\x02'
object_list = ( (oid1, 0, 0, ''), (oid2, 0, 0, ''),)
transaction = ((oid1, oid2), 'user', 'desc', 'ext')
transaction = ((oid1, oid2), 'user', 'desc', 'ext', False)
# store objects in temporary table
self.db.setup()
self.db.storeTransaction(tid, object_list, transaction=None, temporary=True)
......@@ -443,7 +443,7 @@ class StorageMySQSLdbTests(NeoTestBase):
tid1, tid2 = '\x00' * 7 + '\x01', '\x00' * 7 + '\x02'
oid1, oid2 = '\x00' * 7 + '\x01', '\x00' * 7 + '\x02'
object_list = ( (oid1, 0, 0, ''), (oid2, 0, 0, ''),)
transaction = ((oid1, oid2), 'u', 'd', 'e')
transaction = ((oid1, oid2), 'u', 'd', 'e', False)
self.db.setup(reset=True)
# store two temporary transactions
self.db.storeTransaction(tid1, object_list, transaction, temporary=True)
......@@ -461,7 +461,7 @@ class StorageMySQSLdbTests(NeoTestBase):
self.assertEquals(result[1], (2L, 1L, 0, 0, ''))
result = self.db.query('select * from trans')
self.assertEquals(len(result), 1)
self.assertEquals(result[0], (1L, oid1 + oid2, 'u', 'd', 'e',))
self.assertEquals(result[0], (1L, 0, oid1 + oid2, 'u', 'd', 'e',))
# t2 should stay in temporary tables
result = self.db.query('select * from tobj order by oid asc')
self.assertEquals(len(result), 2)
......@@ -469,14 +469,14 @@ class StorageMySQSLdbTests(NeoTestBase):
self.assertEquals(result[1], (2L, 2L, 0, 0, ''))
result = self.db.query('select * from ttrans')
self.assertEquals(len(result), 1)
self.assertEquals(result[0], (2L, oid1 + oid2, 'u', 'd', 'e',))
self.assertEquals(result[0], (2L, 0, oid1 + oid2, 'u', 'd', 'e',))
def test_26_deleteTransaction(self):
# data set
tid1, tid2 = '\x00' * 7 + '\x01', '\x00' * 7 + '\x02'
oid1, oid2 = '\x00' * 7 + '\x01', '\x00' * 7 + '\x02'
object_list = ( (oid1, 0, 0, ''), (oid2, 0, 0, ''),)
transaction = ((oid1, oid2), 'u', 'd', 'e')
transaction = ((oid1, oid2), 'u', 'd', 'e', False)
self.db.setup(reset=True)
# store two transactions in both state
self.db.storeTransaction(tid1, object_list, transaction, temporary=True)
......@@ -500,14 +500,14 @@ class StorageMySQSLdbTests(NeoTestBase):
self.assertEquals(result[1], (2L, 2L, 0, 0, ''))
result = self.db.query('select * from ttrans')
self.assertEquals(len(result), 1)
self.assertEquals(result[0], (2L, oid1 + oid2, 'u', 'd', 'e',))
self.assertEquals(result[0], (2L, 0, oid1 + oid2, 'u', 'd', 'e',))
result = self.db.query('select * from obj order by oid asc')
self.assertEquals(len(result), 2)
self.assertEquals(result[0], (1L, 2L, 0, 0, ''))
self.assertEquals(result[1], (2L, 2L, 0, 0, ''))
result = self.db.query('select * from trans')
self.assertEquals(len(result), 1)
self.assertEquals(result[0], (2L, oid1 + oid2, 'u', 'd', 'e',))
self.assertEquals(result[0], (2L, 0, oid1 + oid2, 'u', 'd', 'e',))
# store t1 again
self.db.storeTransaction(tid1, object_list, transaction, temporary=True)
self.db.storeTransaction(tid1, object_list, transaction, temporary=False)
......@@ -520,7 +520,7 @@ class StorageMySQSLdbTests(NeoTestBase):
self.assertEquals(result[1], (2L, 2L, 0, 0, ''))
result = self.db.query('select * from ttrans')
self.assertEquals(len(result), 1)
self.assertEquals(result[0], (2L, oid1 + oid2, 'u', 'd', 'e',))
self.assertEquals(result[0], (2L, 0, oid1 + oid2, 'u', 'd', 'e',))
result = self.db.query('select * from obj order by oid, serial asc')
self.assertEquals(len(result), 4)
self.assertEquals(result[0], (1L, 1L, 0, 0, ''))
......@@ -529,30 +529,30 @@ class StorageMySQSLdbTests(NeoTestBase):
self.assertEquals(result[3], (2L, 2L, 0, 0, ''))
result = self.db.query('select * from trans order by tid asc')
self.assertEquals(len(result), 2)
self.assertEquals(result[0], (1L, oid1 + oid2, 'u', 'd', 'e',))
self.assertEquals(result[1], (2L, oid1 + oid2, 'u', 'd', 'e',))
self.assertEquals(result[0], (1L, 0, oid1 + oid2, 'u', 'd', 'e',))
self.assertEquals(result[1], (2L, 0, oid1 + oid2, 'u', 'd', 'e',))
def test_27_getTransaction(self):
# data set
tid1, tid2 = '\x00' * 7 + '\x01', '\x00' * 7 + '\x02'
oid1, oid2 = '\x00' * 7 + '\x01', '\x00' * 7 + '\x02'
oids = [oid1, oid2]
transaction = ((oid1, oid2), 'u', 'd', 'e')
transaction = ((oid1, oid2), 'u', 'd', 'e', False)
self.db.setup(reset=True)
# store t1 in temporary and t2 in persistent tables
self.db.storeTransaction(tid1, (), transaction, temporary=True)
self.db.storeTransaction(tid2, (), transaction, temporary=False)
# get t1 from all -> OK
t = self.db.getTransaction(tid1, all=True)
self.assertEquals(t, (oids, 'u', 'd', 'e'))
self.assertEquals(t, (oids, 'u', 'd', 'e', False))
# get t1 from no tmp only -> fail
t = self.db.getTransaction(tid1, all=False)
self.assertEquals(t, None)
# get t2 from all or not -> always OK
t = self.db.getTransaction(tid2, all=True)
self.assertEquals(t, (oids, 'u', 'd', 'e'))
self.assertEquals(t, (oids, 'u', 'd', 'e', False))
t = self.db.getTransaction(tid2, all=False)
self.assertEquals(t, (oids, 'u', 'd', 'e'))
self.assertEquals(t, (oids, 'u', 'd', 'e', False))
# store wrong oids -> DatabaseFailure
self.db.setup(reset=True)
self.db.query("""replace into trans (tid, oids, user, description, ext)
......@@ -616,8 +616,8 @@ class StorageMySQSLdbTests(NeoTestBase):
tids = ['\x00' * 7 + chr(i) for i in xrange(4)]
tid1, tid2, tid3, tid4 = tids
for tid in tids:
self.db.query("replace into trans values (%d, '', 'u', 'd', 'e')" %
(u64(tid)))
self.db.query("""replace into trans values (%d, '', 'u', 'd', 'e',
False)""" % (u64(tid)))
# get all tids for all partitions
result = self.db.getTIDList(0, 4, 2, (0, 1))
self.assertEquals(result, [tid1, tid2, tid3, tid4])
......@@ -643,8 +643,8 @@ class StorageMySQSLdbTests(NeoTestBase):
tid = '\x00' * 7 + '\x01'
tid1, tid2, tid3, tid4 = ['\x00' * 7 + chr(i) for i in xrange(4)]
for tid in (tid1, tid2, tid3, tid4):
self.db.query("replace into trans values (%d, '', 'u', 'd', 'e')" %
(u64(tid)))
self.db.query("""replace into trans values (%d, '', 'u', 'd', 'e',
False)""" % (u64(tid)))
# all match
result = self.db.getTIDListPresent((tid1, tid2, tid3, tid4))
expected = [tid1, tid2, tid3, tid4]
......@@ -663,8 +663,8 @@ class StorageMySQSLdbTests(NeoTestBase):
tid1, tid2, tid3, tid4 = tids
oid = '\x00' * 8
for tid in tids:
self.db.query("replace into obj values (%d, %d, 0, 0, '')" %
(u64(oid), u64(tid)))
self.db.query("replace into obj values (%d, %d, 0, 0, '')" % (u64(oid),
u64(tid)))
# all match
result = self.db.getSerialListPresent(oid, tids)
expected = list(tids)
......
......@@ -45,7 +45,7 @@ class TransactionTests(NeoTestBase):
def testTransaction(self):
txn = Transaction(self.getNewUUID(), self.getNextTID())
oid_list = [self.getOID(1), self.getOID(2)]
txn_info = (oid_list, 'USER', 'DESC', 'EXT')
txn_info = (oid_list, 'USER', 'DESC', 'EXT', False)
txn.prepare(*txn_info)
self.assertEqual(txn.getTransactionInformations(), txn_info)
......@@ -76,7 +76,7 @@ class TransactionManagerTests(NeoTestBase):
def _getTransaction(self):
tid = self.getNextTID(self.ltid)
oid_list = [self.getOID(1), self.getOID(2)]
return (tid, (oid_list, 'USER', 'DESC', 'EXT'))
return (tid, (oid_list, 'USER', 'DESC', 'EXT', False))
def _getObject(self, value):
oid = self.getOID(value)
......
......@@ -244,7 +244,7 @@ class StorageVerificationHandlerTests(NeoTestBase):
conn = Mock({ "getAddress" : ("127.0.0.1", self.master_port),
'isServer': False })
self.verification.askTransactionInformation(conn, p64(1))
tid, user, desc, ext, oid_list = self.checkAnswerTransactionInformation(conn, decode=True)
tid, user, desc, ext, packed, oid_list = self.checkAnswerTransactionInformation(conn, decode=True)
self.assertEqual(u64(tid), 1)
self.assertEqual(user, 'u2')
self.assertEqual(desc, 'd2')
......@@ -255,7 +255,7 @@ class StorageVerificationHandlerTests(NeoTestBase):
conn = Mock({ "getAddress" : ("127.0.0.1", self.master_port),
'isServer': False })
self.verification.askTransactionInformation(conn, p64(3))
tid, user, desc, ext, oid_list = self.checkAnswerTransactionInformation(conn, decode=True)
tid, user, desc, ext, packed, oid_list = self.checkAnswerTransactionInformation(conn, decode=True)
self.assertEqual(u64(tid), 3)
self.assertEqual(user, 'u1')
self.assertEqual(desc, 'd1')
......@@ -268,7 +268,7 @@ class StorageVerificationHandlerTests(NeoTestBase):
'isServer': True })
# find the one in trans
self.verification.askTransactionInformation(conn, p64(1))
tid, user, desc, ext, oid_list = self.checkAnswerTransactionInformation(conn, decode=True)
tid, user, desc, ext, packed, oid_list = self.checkAnswerTransactionInformation(conn, decode=True)
self.assertEqual(u64(tid), 1)
self.assertEqual(user, 'u2')
self.assertEqual(desc, 'd2')
......
......@@ -421,13 +421,14 @@ class ProtocolTests(NeoTestBase):
oid4 = self.getNextTID()
oid_list = [oid1, oid2, oid3, oid4]
p = Packets.AnswerTransactionInformation(tid, "moi",
"transaction", "exti", oid_list)
ptid, user, desc, ext, p_oid_list = p.decode()
"transaction", "exti", False, oid_list)
ptid, user, desc, ext, packed, p_oid_list = p.decode()
self.assertEqual(ptid, tid)
self.assertEqual(p_oid_list, oid_list)
self.assertEqual(user, "moi")
self.assertEqual(desc, "transaction")
self.assertEqual(ext, "exti")
self.assertFalse(packed)
def test_53_askObjectHistory(self):
oid = self.getNextTID()
......
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