[Neo-report] r1851 gregory - in /trunk/neo: ./ storage/database/ tests/ tests/client/ test...
nobody at svn.erp5.org
nobody at svn.erp5.org
Tue Feb 23 17:00:57 CET 2010
Author: gregory
Date: Tue Feb 23 17:00:55 2010
New Revision: 1851
Log:
Fixes after r1833.
Modified:
trunk/neo/protocol.py
trunk/neo/storage/database/mysqldb.py
trunk/neo/tests/client/testClientApp.py
trunk/neo/tests/client/testStorageHandler.py
trunk/neo/tests/master/testVerification.py
trunk/neo/tests/storage/testClientHandler.py
trunk/neo/tests/storage/testStorageHandler.py
trunk/neo/tests/storage/testStorageMySQLdb.py
trunk/neo/tests/storage/testTransactions.py
trunk/neo/tests/storage/testVerificationHandler.py
trunk/neo/tests/testProtocol.py
Modified: trunk/neo/protocol.py
==============================================================================
--- trunk/neo/protocol.py [iso-8859-1] (original)
+++ trunk/neo/protocol.py [iso-8859-1] Tue Feb 23 17:00:55 2010
@@ -916,10 +916,10 @@
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]
Modified: trunk/neo/storage/database/mysqldb.py
==============================================================================
--- trunk/neo/storage/database/mysqldb.py [iso-8859-1] (original)
+++ trunk/neo/storage/database/mysqldb.py [iso-8859-1] Tue Feb 23 17:00:55 2010
@@ -424,7 +424,7 @@
% 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 = []
Modified: trunk/neo/tests/client/testClientApp.py
==============================================================================
--- trunk/neo/tests/client/testClientApp.py [iso-8859-1] (original)
+++ trunk/neo/tests/client/testClientApp.py [iso-8859-1] Tue Feb 23 17:00:55 2010
@@ -733,17 +733,21 @@
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 @@
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 @@
# 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)
Modified: trunk/neo/tests/client/testStorageHandler.py
==============================================================================
--- trunk/neo/tests/client/testStorageHandler.py [iso-8859-1] (original)
+++ trunk/neo/tests/client/testStorageHandler.py [iso-8859-1] Tue Feb 23 17:00:55 2010
@@ -124,7 +124,7 @@
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)
Modified: trunk/neo/tests/master/testVerification.py
==============================================================================
--- trunk/neo/tests/master/testVerification.py [iso-8859-1] (original)
+++ trunk/neo/tests/master/testVerification.py [iso-8859-1] Tue Feb 23 17:00:55 2010
@@ -157,7 +157,7 @@
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 @@
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 @@
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 @@
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):
Modified: trunk/neo/tests/storage/testClientHandler.py
==============================================================================
--- trunk/neo/tests/storage/testClientHandler.py [iso-8859-1] (original)
+++ trunk/neo/tests/storage/testClientHandler.py [iso-8859-1] Tue Feb 23 17:00:55 2010
@@ -93,7 +93,7 @@
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)
Modified: trunk/neo/tests/storage/testStorageHandler.py
==============================================================================
--- trunk/neo/tests/storage/testStorageHandler.py [iso-8859-1] (original)
+++ trunk/neo/tests/storage/testStorageHandler.py [iso-8859-1] Tue Feb 23 17:00:55 2010
@@ -65,7 +65,7 @@
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)
Modified: trunk/neo/tests/storage/testStorageMySQLdb.py
==============================================================================
--- trunk/neo/tests/storage/testStorageMySQLdb.py [iso-8859-1] (original)
+++ trunk/neo/tests/storage/testStorageMySQLdb.py [iso-8859-1] Tue Feb 23 17:00:55 2010
@@ -402,7 +402,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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)
@@ -594,7 +594,7 @@
oid = '\x00' * 8
for tid in tids:
self.db.query("replace into obj values (%d, %d, 0, 0, '')" %
- (u64(oid), u64(tid)))
+ (u64(oid), u64(tid)))
# unkwown object
result = self.db.getObjectHistory(oid='\x01' * 8)
self.assertEquals(result, None)
@@ -616,8 +616,8 @@
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 @@
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 @@
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)
Modified: trunk/neo/tests/storage/testTransactions.py
==============================================================================
--- trunk/neo/tests/storage/testTransactions.py [iso-8859-1] (original)
+++ trunk/neo/tests/storage/testTransactions.py [iso-8859-1] Tue Feb 23 17:00:55 2010
@@ -45,7 +45,7 @@
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 @@
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)
Modified: trunk/neo/tests/storage/testVerificationHandler.py
==============================================================================
--- trunk/neo/tests/storage/testVerificationHandler.py [iso-8859-1] (original)
+++ trunk/neo/tests/storage/testVerificationHandler.py [iso-8859-1] Tue Feb 23 17:00:55 2010
@@ -244,7 +244,7 @@
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 @@
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 @@
'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')
Modified: trunk/neo/tests/testProtocol.py
==============================================================================
--- trunk/neo/tests/testProtocol.py [iso-8859-1] (original)
+++ trunk/neo/tests/testProtocol.py [iso-8859-1] Tue Feb 23 17:00:55 2010
@@ -421,13 +421,14 @@
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()
More information about the Neo-report
mailing list