[Neo-report] r2644 gregory - in /trunk/neo: client/handlers/ tests/client/

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Feb 8 15:06:40 CET 2011


Author: gregory
Date: Tue Feb  8 15:06:39 2011
New Revision: 2644

Log:
Make log message report more informations.

Signed-off-by: Grégory <gregory at nexedi.com>

Modified:
    trunk/neo/client/handlers/storage.py
    trunk/neo/tests/client/testClientApp.py
    trunk/neo/tests/client/testStorageHandler.py

Modified: trunk/neo/client/handlers/storage.py
==============================================================================
--- trunk/neo/client/handlers/storage.py [iso-8859-1] (original)
+++ trunk/neo/client/handlers/storage.py [iso-8859-1] Tue Feb  8 15:06:39 2011
@@ -80,17 +80,20 @@ class StorageAnswersHandler(AnswerBaseHa
                         dump(oid), dump(serial))
             conflict_serial_dict = txn_context['conflict_serial_dict']
             if serial in object_stored_counter_dict:
-                raise NEOStorageError, 'A storage accepted object for ' \
-                    'serial %s but another reports a conflict for it.' % (
-                        dump(serial), )
+                raise NEOStorageError, 'Storages %s accepted object %s for ' \
+                    'serial %s but %s reports a conflict for it.' % (
+                    [dump(uuid) for uuid in object_stored_counter_dict[serial]],
+                    dump(oid), dump(serial),
+                    dump(conn.getUUID()),
+                )
             # If this conflict is not already resolved, mark it for
             # resolution.
             if serial not in txn_context[
                     'resolved_conflict_serial_dict'].get(oid, ()):
                 conflict_serial_dict.setdefault(oid, set()).add(serial)
         else:
-            object_stored_counter_dict[serial] = \
-                object_stored_counter_dict.get(serial, 0) + 1
+            uuid_set = object_stored_counter_dict.setdefault(serial, set())
+            uuid_set.add(conn.getUUID())
 
     answerCheckCurrentSerial = answerStoreObject
 

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  8 15:06:39 2011
@@ -122,15 +122,16 @@ class ClientApplicationTests(NeoUnitTest
         return '\00' * 7 + chr(value)
     makeTID = makeOID
 
-    def getNodeCellConn(self, index=1, address=('127.0.0.1', 10000)):
+    def getNodeCellConn(self, index=1, address=('127.0.0.1', 10000), uuid=None):
         conn = Mock({
             'getAddress': address,
-            '__repr__': 'connection mock'
+            '__repr__': 'connection mock',
+            'getUUID': uuid,
         })
         node = Mock({
             '__repr__': 'node%s' % index,
             '__hash__': index,
-            'getConnection': conn,
+             'getConnection': conn,
         })
         cell = Mock({
             'getAddress': 'FakeServer',
@@ -442,6 +443,7 @@ class ClientApplicationTests(NeoUnitTest
 
     def test_store3(self):
         app = self.getApp()
+        uuid = self.getNewUUID()
         oid = self.makeOID(11)
         tid = self.makeTID()
         txn = self.makeTransactionObject()
@@ -450,7 +452,8 @@ class ClientApplicationTests(NeoUnitTest
         packet = Packets.AnswerStoreObject(conflicting=0, oid=oid, serial=tid)
         packet.setId(0)
         storage_address = ('127.0.0.1', 10020)
-        node, cell, conn = self.getNodeCellConn(address=storage_address)
+        node, cell, conn = self.getNodeCellConn(address=storage_address,
+            uuid=uuid)
         app.cp = self.getConnectionPool([(node, conn)])
         app.pt = Mock({ 'getCellListForOID': (cell, cell, ) })
         class Dispatcher(object):
@@ -463,7 +466,7 @@ class ClientApplicationTests(NeoUnitTest
         txn_context['queue'].put((conn, packet))
         app.waitStoreResponses(txn_context, resolving_tryToResolveConflict)
         self.assertEquals(txn_context['object_stored_counter_dict'][oid],
-            {tid: 1})
+            {tid: set([uuid])})
         self.assertEquals(txn_context['data_dict'].get(oid, None), 'DATA')
         self.assertFalse(oid in txn_context['conflict_serial_dict'])
 

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  8 15:06:39 2011
@@ -119,7 +119,7 @@ class StorageAnswerHandlerTests(NeoUnitT
         self.assertEqual(object_stored_counter_dict[oid], {})
         self.assertFalse(oid in resolved_conflict_serial_dict)
         # object was already accepted by another storage, raise
-        handler = self._getAnswerStoreObjectHandler({oid: {tid: 1}}, {}, {})
+        handler = self._getAnswerStoreObjectHandler({oid: {tid: set([1])}}, {}, {})
         self.assertRaises(NEOStorageError, handler.answerStoreObject,
             conn, 1, oid, tid)
 
@@ -139,7 +139,7 @@ class StorageAnswerHandlerTests(NeoUnitT
         self.assertFalse(oid in resolved_conflict_serial_dict)
         self.assertEqual(object_stored_counter_dict[oid], {})
         # object was already accepted by another storage, raise
-        handler = self._getAnswerStoreObjectHandler({oid: {tid: 1}},
+        handler = self._getAnswerStoreObjectHandler({oid: {tid: set([1])}},
             {oid: set([tid, ])}, {})
         self.assertRaises(NEOStorageError, handler.answerStoreObject,
             conn, 1, oid, tid)
@@ -171,7 +171,8 @@ class StorageAnswerHandlerTests(NeoUnitT
             {oid: set([tid, ])}).answerStoreObject(conn, 1, oid, tid_2)
 
     def test_answerStoreObject_4(self):
-        conn = self.getConnection()
+        uuid = self.getNewUUID()
+        conn = self.getFakeConnection(uuid=uuid)
         oid = self.getOID(0)
         tid = self.getNextTID()
         # no conflict
@@ -183,7 +184,7 @@ class StorageAnswerHandlerTests(NeoUnitT
             ).answerStoreObject(conn, 0, oid, tid)
         self.assertFalse(oid in conflict_serial_dict)
         self.assertFalse(oid in resolved_conflict_serial_dict)
-        self.assertEqual(object_stored_counter_dict[oid], {tid: 1})
+        self.assertEqual(object_stored_counter_dict[oid], {tid: set([uuid])})
 
     def test_answerTransactionInformation(self):
         conn = self.getConnection()




More information about the Neo-report mailing list