Commit 27ceb80f authored by Grégory Wisniewski's avatar Grégory Wisniewski

Fix bug where new UUID was never stored in the database, since it can change

when the primary master supplied a new UUID. Database manager use 'REPLACE' SQL
statement instead of 'INSERT' to avoid DuplicateEntry errors. Tests updated.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@454 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 9735d7d0
......@@ -25,6 +25,7 @@ from neo.connection import ClientConnection
from neo.protocol import Packet
from neo.pt import PartitionTable
from neo.storage.verification import VerificationEventHandler
from neo.util import dump
class BootstrapEventHandler(StorageEventHandler):
"""This class deals with events for a bootstrap phase."""
......@@ -190,6 +191,8 @@ class BootstrapEventHandler(StorageEventHandler):
if your_uuid != INVALID_UUID and app.uuid != your_uuid:
# got an uuid from the primary master
app.uuid = your_uuid
app.dm.setUUID(app.uuid)
logging.info('Got a new UUID from master : %s' % dump(app.uuid))
conn.setUUID(uuid)
node.setUUID(uuid)
......
......@@ -183,7 +183,7 @@ class MySQLDatabaseManager(DatabaseManager):
e = self.escape
key = e(str(key))
value = e(str(value))
q("""INSERT config VALUES ('%s', '%s')""" % (key, value))
q("""REPLACE INTO config VALUES ('%s', '%s')""" % (key, value))
def getUUID(self):
return self.getConfiguration('uuid')
......
......@@ -198,8 +198,8 @@ class StorageMySQSLdbTests(unittest.TestCase):
self.assertEquals(get_call(), None)
set_call(value)
self.assertEquals(get_call(), value)
self.assertRaises(MySQLdb.IntegrityError, set_call, value * 2)
self.assertEquals(get_call(), value)
set_call(value * 2)
self.assertEquals(get_call(), value * 2)
def test_12_UUID(self):
self.checkConfigEntry(
......@@ -225,8 +225,8 @@ class StorageMySQSLdbTests(unittest.TestCase):
self.assertEquals(self.db.getPTID(), INVALID_PTID)
self.db.setPTID(test)
self.assertEquals(self.db.getPTID(), test)
self.assertRaises(MySQLdb.IntegrityError, self.db.setPTID, test * 2)
self.assertEquals(self.db.getPTID(), test)
self.db.setPTID(test * 2)
self.assertEquals(self.db.getPTID(), test * 2)
def test_16_getPartitionTable(self):
# insert an entry and check it
......
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