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

Make log message report more informations.

Signed-off-by: default avatarGrégory <gregory@nexedi.com>

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2644 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent e97427e9
......@@ -80,17 +80,20 @@ class StorageAnswersHandler(AnswerBaseHandler):
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
......
......@@ -122,15 +122,16 @@ class ClientApplicationTests(NeoUnitTestBase):
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(NeoUnitTestBase):
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(NeoUnitTestBase):
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(NeoUnitTestBase):
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'])
......
......@@ -119,7 +119,7 @@ class StorageAnswerHandlerTests(NeoUnitTestBase):
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(NeoUnitTestBase):
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(NeoUnitTestBase):
{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(NeoUnitTestBase):
).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()
......
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